Skip to content

Commit

Permalink
register direct controller for samples tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Aug 14, 2024
1 parent 3903cba commit 5ea1fff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/tests/samples/create/samples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
klog "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"

_ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/register"
)

func init() {
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/direct/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ func AdapterForURL(ctx context.Context, url string) (directbase.Adapter, error)
}
return nil, nil
}

func Init(ctx context.Context, config *config.ControllerConfig) error {
if singleton.registrations == nil {
return fmt.Errorf("unable to initialize registry")
}
for _, registration := range singleton.registrations {
model, err := registration.factory(ctx, config)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/registration/registration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func registerDefaultController(r *ReconcileRegistration, config *config.Controll
JitterGen: r.jitterGenerator,
Defaulters: r.defaulters,
}

var schemaUpdater k8s.SchemaReferenceUpdater
if kccfeatureflags.UseDirectReconciler(gvk.GroupKind()) {
groupKind := gvk.GroupKind()
Expand Down

0 comments on commit 5ea1fff

Please sign in to comment.