From eeb621ff6d3a2800b0af923ac599b11c2757f403 Mon Sep 17 00:00:00 2001 From: Nicholas Thomson Date: Wed, 12 May 2021 16:09:08 -0700 Subject: [PATCH 1/2] Add additional keys to adopted resource spec --- apis/core/v1alpha1/identifiers.go | 3 ++ apis/core/v1alpha1/zz_generated.deepcopy.go | 31 +++++++++++++++++++ .../services.k8s.aws_adoptedresources.yaml | 6 ++++ 3 files changed, 40 insertions(+) diff --git a/apis/core/v1alpha1/identifiers.go b/apis/core/v1alpha1/identifiers.go index ff3195af..6d05f9ba 100644 --- a/apis/core/v1alpha1/identifiers.go +++ b/apis/core/v1alpha1/identifiers.go @@ -21,6 +21,9 @@ type AWSIdentifiers struct { // NameOrId is a user-supplied string identifier for the resource. It may // or may not be globally unique, depending on the type of resource. NameOrID *string `json:"nameOrID,omitempty"` + // AdditionalKeys represents any additional arbitrary identifiers used when + // describing the target resource. + AdditionalKeys map[string]*string `json:"additionalKeys,omitempty"` } // TargetKubernetesResource provides all the values necessary to identify a given ACK type diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index 96cdba37..bdaa6c60 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -35,6 +35,21 @@ func (in *AWSIdentifiers) DeepCopyInto(out *AWSIdentifiers) { *out = new(string) **out = **in } + if in.AdditionalKeys != nil { + in, out := &in.AdditionalKeys, &out.AdditionalKeys + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSIdentifiers. @@ -247,6 +262,22 @@ func (in *ResourceMetadata) DeepCopy() *ResourceMetadata { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SecretKeyReference) DeepCopyInto(out *SecretKeyReference) { + *out = *in + out.SecretReference = in.SecretReference +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretKeyReference. +func (in *SecretKeyReference) DeepCopy() *SecretKeyReference { + if in == nil { + return nil + } + out := new(SecretKeyReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TargetKubernetesResource) DeepCopyInto(out *TargetKubernetesResource) { *out = *in diff --git a/config/crd/bases/services.k8s.aws_adoptedresources.yaml b/config/crd/bases/services.k8s.aws_adoptedresources.yaml index 310264dc..a64411af 100644 --- a/config/crd/bases/services.k8s.aws_adoptedresources.yaml +++ b/config/crd/bases/services.k8s.aws_adoptedresources.yaml @@ -40,6 +40,12 @@ spec: description: AWSIdentifiers provide all unique ways to reference an AWS resource. properties: + additionalKeys: + additionalProperties: + type: string + description: AdditionalKeys represents any additional arbitrary + identifiers used when describing the target resource. + type: object arn: description: ARN is the AWS Resource Name for the resource. It is a globally unique identifier. From 695b24bd33faad8dea627030090728af7f9eaf0b Mon Sep 17 00:00:00 2001 From: Nicholas Thomson Date: Mon, 28 Jun 2021 16:06:03 -0700 Subject: [PATCH 2/2] Migrate types from pointer to literals --- apis/core/v1alpha1/identifiers.go | 8 +++--- apis/core/v1alpha1/zz_generated.deepcopy.go | 27 ++------------------- pkg/runtime/adoption_reconciler.go | 4 +-- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/apis/core/v1alpha1/identifiers.go b/apis/core/v1alpha1/identifiers.go index 6d05f9ba..a04c7535 100644 --- a/apis/core/v1alpha1/identifiers.go +++ b/apis/core/v1alpha1/identifiers.go @@ -20,18 +20,18 @@ type AWSIdentifiers struct { ARN *AWSResourceName `json:"arn,omitempty"` // NameOrId is a user-supplied string identifier for the resource. It may // or may not be globally unique, depending on the type of resource. - NameOrID *string `json:"nameOrID,omitempty"` + NameOrID string `json:"nameOrID,omitempty"` // AdditionalKeys represents any additional arbitrary identifiers used when // describing the target resource. - AdditionalKeys map[string]*string `json:"additionalKeys,omitempty"` + AdditionalKeys map[string]string `json:"additionalKeys,omitempty"` } // TargetKubernetesResource provides all the values necessary to identify a given ACK type // and override any metadata values when creating a resource of that type. type TargetKubernetesResource struct { // +kubebuilder:validation:Required - Group *string `json:"group"` + Group string `json:"group"` // +kubebuilder:validation:Required - Kind *string `json:"kind"` + Kind string `json:"kind"` Metadata *PartialObjectMeta `json:"metadata,omitempty"` } diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/core/v1alpha1/zz_generated.deepcopy.go index bdaa6c60..aba268bb 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -30,24 +30,11 @@ func (in *AWSIdentifiers) DeepCopyInto(out *AWSIdentifiers) { *out = new(AWSResourceName) **out = **in } - if in.NameOrID != nil { - in, out := &in.NameOrID, &out.NameOrID - *out = new(string) - **out = **in - } if in.AdditionalKeys != nil { in, out := &in.AdditionalKeys, &out.AdditionalKeys - *out = make(map[string]*string, len(*in)) + *out = make(map[string]string, len(*in)) for key, val := range *in { - var outVal *string - if val == nil { - (*out)[key] = nil - } else { - in, out := &val, &outVal - *out = new(string) - **out = **in - } - (*out)[key] = outVal + (*out)[key] = val } } } @@ -281,16 +268,6 @@ func (in *SecretKeyReference) DeepCopy() *SecretKeyReference { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TargetKubernetesResource) DeepCopyInto(out *TargetKubernetesResource) { *out = *in - if in.Group != nil { - in, out := &in.Group, &out.Group - *out = new(string) - **out = **in - } - if in.Kind != nil { - in, out := &in.Kind, &out.Kind - *out = new(string) - **out = **in - } if in.Metadata != nil { in, out := &in.Metadata, &out.Metadata *out = new(PartialObjectMeta) diff --git a/pkg/runtime/adoption_reconciler.go b/pkg/runtime/adoption_reconciler.go index 29cfb817..fca7b7eb 100644 --- a/pkg/runtime/adoption_reconciler.go +++ b/pkg/runtime/adoption_reconciler.go @@ -337,8 +337,8 @@ func (r *adoptionReconciler) getTargetResourceGroupKind( res *ackv1alpha1.AdoptedResource, ) schema.GroupKind { return schema.GroupKind{ - Group: *res.Spec.Kubernetes.Group, - Kind: *res.Spec.Kubernetes.Kind, + Group: res.Spec.Kubernetes.Group, + Kind: res.Spec.Kubernetes.Kind, } }