From 65cea5dd4522bd82cd1c7c3707ed5c47bdbbc580 Mon Sep 17 00:00:00 2001 From: Nicholas Thomson Date: Tue, 21 Mar 2023 22:54:02 +0000 Subject: [PATCH 1/2] Add GVK to ResourceDescriptor --- templates/pkg/resource/descriptor.go.tpl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/pkg/resource/descriptor.go.tpl b/templates/pkg/resource/descriptor.go.tpl index 5733a5c4..5cf38851 100644 --- a/templates/pkg/resource/descriptor.go.tpl +++ b/templates/pkg/resource/descriptor.go.tpl @@ -3,6 +3,7 @@ package {{ .CRD.Names.Snake }} import ( + "k8s.io/apimachinery/pkg/runtime/schema" ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare" @@ -36,6 +37,12 @@ func (d *resourceDescriptor) GroupKind() *metav1.GroupKind { return &GroupKind } +// GroupVersionKind returns a Kubernetes schema.GroupVersionKind struct that +// describes the API Group, Version and Kind of CRs described by the descriptor +func (d *resourceDescriptor) GroupVersionKind() schema.GroupVersionKind { + return svcapitypes.GroupVersion.WithKind(GroupKind.Kind) +} + // EmptyRuntimeObject returns an empty object prototype that may be used in // apimachinery and k8s client operations func (d *resourceDescriptor) EmptyRuntimeObject() rtclient.Object { From eb94afebf57fb875c63051ac76ebef12bf2af504 Mon Sep 17 00:00:00 2001 From: Nicholas Thomson Date: Tue, 21 Mar 2023 23:17:15 +0000 Subject: [PATCH 2/2] Remove GroupKind --- templates/pkg/resource/descriptor.go.tpl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/templates/pkg/resource/descriptor.go.tpl b/templates/pkg/resource/descriptor.go.tpl index 5cf38851..4b8b2953 100644 --- a/templates/pkg/resource/descriptor.go.tpl +++ b/templates/pkg/resource/descriptor.go.tpl @@ -31,12 +31,6 @@ var ( type resourceDescriptor struct { } -// GroupKind returns a Kubernetes metav1.GroupKind struct that describes the -// API Group and Kind of CRs described by the descriptor -func (d *resourceDescriptor) GroupKind() *metav1.GroupKind { - return &GroupKind -} - // GroupVersionKind returns a Kubernetes schema.GroupVersionKind struct that // describes the API Group, Version and Kind of CRs described by the descriptor func (d *resourceDescriptor) GroupVersionKind() schema.GroupVersionKind {