Skip to content

Commit

Permalink
Passe registred resource names to config.Validate
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
a-hilaly committed Mar 6, 2023
1 parent 9fbf8c4 commit 6ef3d4f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion templates/cmd/controller/main.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import (
ackrtutil "github.com/aws-controllers-k8s/runtime/pkg/util"
ackrtwebhook "github.com/aws-controllers-k8s/runtime/pkg/webhook"
flag "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrlrt "sigs.k8s.io/controller-runtime"
ctrlrtmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
"k8s.io/apimachinery/pkg/runtime/schema"
svcsdk "github.com/aws/aws-sdk-go/service/{{ .ServicePackageName }}"
{{- /* Import the go types from service controllers whose resources are referenced in this service controller.
If these referenced types are not added to scheme, this service controller will not be able to read
Expand Down Expand Up @@ -62,7 +64,13 @@ func main() {
flag.Parse()
ackCfg.SetupLogger()
if err := ackCfg.Validate(); err != nil {
managerFactories := svcresource.GetManagerFactories()
resourceGroupKinds := make([]*metav1.GroupKind, 0, len(managerFactories))
for _, mf := range managerFactories {
resourceGroupKinds = append(resourceGroupKinds, mf.ResourceDescriptor().GroupKind())
}

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

0 comments on commit 6ef3d4f

Please sign in to comment.