Skip to content

Commit

Permalink
Pass registered resource names to config.Validate (#423)
Browse files Browse the repository at this point in the history
[fixes aws-controllers-k8s/community#1647]

Completes aws-controllers-k8s/runtime#117

This patch adds a tiny modification to the controllers `main.go` that
passes the resource names to `ackCfg.Validate` method.

Needs a new runtime release.
/hold

Signed-off-by: Amine Hilaly <hilalyamine@gmail.com>

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
a-hilaly committed May 1, 2023
1 parent e69321e commit 6657565
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion templates/cmd/controller/main.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
ackrtutil "github.com/aws-controllers-k8s/runtime/pkg/util"
ackrtwebhook "github.com/aws-controllers-k8s/runtime/pkg/webhook"
flag "github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrlrt "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -62,7 +63,13 @@ func main() {
flag.Parse()
ackCfg.SetupLogger()
if err := ackCfg.Validate(); err != nil {
managerFactories := svcresource.GetManagerFactories()
resourceGVKs := make([]schema.GroupVersionKind, 0, len(managerFactories))
for _, mf := range managerFactories {
resourceGVKs = append(resourceGVKs, mf.ResourceDescriptor().GroupVersionKind())
}

if err := ackCfg.Validate(ackcfg.WithGVKs(resourceGVKs)); err != nil {
setupLog.Error(
err, "Unable to create controller manager",
"aws.service", awsServiceAlias,
Expand Down

0 comments on commit 6657565

Please sign in to comment.