Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"

istionetworkingv1 "istio.io/client-go/pkg/apis/networking/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -44,6 +45,8 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
externaldnsv1alpha1 "sigs.k8s.io/external-dns/apis/v1alpha1"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gwapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"sigs.k8s.io/external-dns/source/annotations"

Expand Down Expand Up @@ -120,6 +123,13 @@ func init() {

utilruntime.Must(sreportalv1alpha1.AddToScheme(scheme))
utilruntime.Must(sreportalv1alpha2.AddToScheme(scheme))

// External source types listed by the DNS source resolvers. Without these
// the SourceReconciler's List fails client-side ("no kind is registered for
// the type ...") whenever the matching source is enabled on a DNS CR.
utilruntime.Must(istionetworkingv1.AddToScheme(scheme)) // Istio Gateway, VirtualService
utilruntime.Must(gwapiv1.Install(scheme)) // Gateway API HTTPRoute, GRPCRoute
utilruntime.Must(gwapiv1alpha2.Install(scheme)) // Gateway API TCPRoute, TLSRoute, UDPRoute
// +kubebuilder:scaffold:scheme
}

Expand Down
52 changes: 52 additions & 0 deletions cmd/scheme_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright 2026.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"testing"

"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/golgoth31/sreportal/internal/source/gatewaygrpcroute"
"github.com/golgoth31/sreportal/internal/source/gatewayhttproute"
"github.com/golgoth31/sreportal/internal/source/gatewaytcproute"
"github.com/golgoth31/sreportal/internal/source/gatewaytlsroute"
"github.com/golgoth31/sreportal/internal/source/gatewayudproute"
"github.com/golgoth31/sreportal/internal/source/istiogateway"
"github.com/golgoth31/sreportal/internal/source/istiovirtualservice"
)

// TestSchemeRegistersExternalSourceTypes guards against the SourceReconciler
// failing client-side ("no kind is registered for the type ...") when a source
// backed by an external API (Istio, Gateway API) is enabled on a DNS CR. Each
// resolver's list type must be recognized by the manager scheme built in init().
func TestSchemeRegistersExternalSourceTypes(t *testing.T) {
lists := map[string]client.ObjectList{
"istio-gateway": istiogateway.NewResolver().ObjectList(),
"istio-virtualservice": istiovirtualservice.NewResolver().ObjectList(),
"gateway-httproute": gatewayhttproute.NewResolver().ObjectList(),
"gateway-grpcroute": gatewaygrpcroute.NewResolver().ObjectList(),
"gateway-tcproute": gatewaytcproute.NewResolver().ObjectList(),
"gateway-tlsroute": gatewaytlsroute.NewResolver().ObjectList(),
"gateway-udproute": gatewayudproute.NewResolver().ObjectList(),
}
for name, list := range lists {
if _, _, err := scheme.ObjectKinds(list); err != nil {
t.Errorf("scheme does not recognize %s list type %T: %v", name, list, err)
}
}
}