From 79278d7c9c1881514f57eadb7cbdb371ea345743 Mon Sep 17 00:00:00 2001 From: ci-robot Date: Mon, 9 Dec 2024 17:24:29 +0000 Subject: [PATCH] Update to ACK runtime `v0.40.0`, code-generator `v0.40.0` --- apis/v1alpha1/ack-generate-metadata.yaml | 8 ++++---- config/controller/deployment.yaml | 4 ++++ config/controller/kustomization.yaml | 2 +- go.mod | 4 ++-- go.sum | 4 ++-- helm/Chart.yaml | 4 ++-- helm/templates/NOTES.txt | 2 +- helm/templates/caches-role-binding.yaml | 6 +++--- helm/values.yaml | 6 ++++-- pkg/resource/access_entry/descriptor.go | 10 +++++----- pkg/resource/access_entry/resource.go | 16 ++++++++++++++++ pkg/resource/addon/descriptor.go | 10 +++++----- pkg/resource/addon/resource.go | 16 ++++++++++++++++ pkg/resource/cluster/descriptor.go | 10 +++++----- pkg/resource/cluster/resource.go | 11 +++++++++++ pkg/resource/fargate_profile/descriptor.go | 10 +++++----- pkg/resource/fargate_profile/resource.go | 16 ++++++++++++++++ .../identity_provider_config/descriptor.go | 10 +++++----- .../identity_provider_config/resource.go | 11 +++++++++++ pkg/resource/nodegroup/descriptor.go | 10 +++++----- pkg/resource/nodegroup/resource.go | 16 ++++++++++++++++ .../pod_identity_association/descriptor.go | 10 +++++----- .../pod_identity_association/resource.go | 16 ++++++++++++++++ 23 files changed, 160 insertions(+), 52 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 4c358d1..23e467b 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,8 +1,8 @@ ack_generate_info: - build_date: "2024-10-21T22:52:48Z" - build_hash: ab15f9206796e9660c51695fab0ff07a09ea28e2 - go_version: go1.23.2 - version: v0.39.1-2-gab15f92 + build_date: "2024-12-09T17:24:14Z" + build_hash: 631aeb190e332addb8379672df6367a0875dce88 + go_version: go1.23.3 + version: v0.40.0 api_directory_checksum: 4cfe0b6ec81b65719c1f165983b84116135f5e40 api_version: v1alpha1 aws_sdk_go_version: v1.55.5 diff --git a/config/controller/deployment.yaml b/config/controller/deployment.yaml index c631c05..3343643 100644 --- a/config/controller/deployment.yaml +++ b/config/controller/deployment.yaml @@ -41,6 +41,8 @@ spec: - "$(LEADER_ELECTION_NAMESPACE)" - --reconcile-default-max-concurrent-syncs - "$(RECONCILE_DEFAULT_MAX_CONCURRENT_SYNCS)" + - --feature-gates + - "$(FEATURE_GATES)" image: controller:latest name: controller ports: @@ -76,6 +78,8 @@ spec: value: "ack-system" - name: "RECONCILE_DEFAULT_MAX_CONCURRENT_SYNCS" value: "1" + - name: "FEATURE_GATES" + value: "" securityContext: allowPrivilegeEscalation: false privileged: false diff --git a/config/controller/kustomization.yaml b/config/controller/kustomization.yaml index 28ccd5e..5fe8bd4 100644 --- a/config/controller/kustomization.yaml +++ b/config/controller/kustomization.yaml @@ -6,4 +6,4 @@ kind: Kustomization images: - name: controller newName: public.ecr.aws/aws-controllers-k8s/eks-controller - newTag: 1.5.2 + newTag: 1.5.3 diff --git a/go.mod b/go.mod index 308a5df..41e9c19 100644 --- a/go.mod +++ b/go.mod @@ -8,9 +8,9 @@ require ( github.com/aws-controllers-k8s/ec2-controller v1.1.0 github.com/aws-controllers-k8s/iam-controller v1.3.1 github.com/aws-controllers-k8s/kms-controller v1.0.9 - github.com/aws-controllers-k8s/runtime v0.39.0 - github.com/go-logr/logr v1.4.2 + github.com/aws-controllers-k8s/runtime v0.40.0 github.com/aws/aws-sdk-go v1.55.5 + github.com/go-logr/logr v1.4.2 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 k8s.io/api v0.31.0 diff --git a/go.sum b/go.sum index f11ed79..af8bbaf 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/aws-controllers-k8s/iam-controller v1.3.1 h1:/3yH3tAtSVAAt2ulIqsmutjW github.com/aws-controllers-k8s/iam-controller v1.3.1/go.mod h1:7nZzMtEN8xEL5fYhL9FKkBhqoP4QMmMp5x5dXDGwfYM= github.com/aws-controllers-k8s/kms-controller v1.0.9 h1:GZHSnuZBoWp9r6RaJ3siyDn5BRhDuaZJXtdBKeAiLSw= github.com/aws-controllers-k8s/kms-controller v1.0.9/go.mod h1:Pnz0d5sly7dUgmYMDJWSRIKASOujJFi/b8N2q1qCLqU= -github.com/aws-controllers-k8s/runtime v0.39.0 h1:IgOXluSzvb4UcDr9eU7SPw5MJnL7kt5R6DuF5Qu9zVQ= -github.com/aws-controllers-k8s/runtime v0.39.0/go.mod h1:G07g26y1cxyZO6Ngp+LwXf03CqFyLNL7os4Py4IdyGY= +github.com/aws-controllers-k8s/runtime v0.40.0 h1:FplFYgzCIbQsPafarP3dy/4bG1uGR8G1OLYOWO4a7Lc= +github.com/aws-controllers-k8s/runtime v0.40.0/go.mod h1:G07g26y1cxyZO6Ngp+LwXf03CqFyLNL7os4Py4IdyGY= github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU= github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/helm/Chart.yaml b/helm/Chart.yaml index fd08251..d093c6e 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 name: eks-chart description: A Helm chart for the ACK service controller for Amazon Elastic Kubernetes Service (EKS) -version: 1.5.2 -appVersion: 1.5.2 +version: 1.5.3 +appVersion: 1.5.3 home: https://github.com/aws-controllers-k8s/eks-controller icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png sources: diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index b7bcc01..718c0f9 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -1,5 +1,5 @@ {{ .Chart.Name }} has been installed. -This chart deploys "public.ecr.aws/aws-controllers-k8s/eks-controller:1.5.2". +This chart deploys "public.ecr.aws/aws-controllers-k8s/eks-controller:1.5.3". Check its status by running: kubectl --namespace {{ .Release.Namespace }} get pods -l "app.kubernetes.io/instance={{ .Release.Name }}" diff --git a/helm/templates/caches-role-binding.yaml b/helm/templates/caches-role-binding.yaml index 5af5233..c7a19ca 100644 --- a/helm/templates/caches-role-binding.yaml +++ b/helm/templates/caches-role-binding.yaml @@ -8,7 +8,7 @@ roleRef: name: ack-namespaces-cache-eks-controller subjects: - kind: ServiceAccount - name: ack-eks-controller + name: {{ include "ack-eks-controller.service-account.name" . }} namespace: {{ .Release.Namespace }} --- apiVersion: rbac.authorization.k8s.io/v1 @@ -22,5 +22,5 @@ roleRef: name: ack-configmaps-cache-eks-controller subjects: - kind: ServiceAccount - name: ack-eks-controller - namespace: {{ .Release.Namespace }} \ No newline at end of file + name: {{ include "ack-eks-controller.service-account.name" . }} + namespace: {{ .Release.Namespace }} diff --git a/helm/values.yaml b/helm/values.yaml index 65558e7..baf04f4 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -4,7 +4,7 @@ image: repository: public.ecr.aws/aws-controllers-k8s/eks-controller - tag: 1.5.2 + tag: 1.5.3 pullPolicy: IfNotPresent pullSecrets: [] @@ -163,4 +163,6 @@ featureGates: # Enables the Team level granularity for CARM. See https://github.com/aws-controllers-k8s/community/issues/2031 TeamLevelCARM: false # Enable ReadOnlyResources feature/annotation. - ReadOnlyResources: false \ No newline at end of file + ReadOnlyResources: false + # Enable ResourceAdoption feature/annotation. + ResourceAdoption: false \ No newline at end of file diff --git a/pkg/resource/access_entry/descriptor.go b/pkg/resource/access_entry/descriptor.go index 9e011d5..d7d5a58 100644 --- a/pkg/resource/access_entry/descriptor.go +++ b/pkg/resource/access_entry/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.eks.services.k8s.aws/AccessEntry" + FinalizerString = "finalizers.eks.services.k8s.aws/AccessEntry" ) var ( @@ -88,8 +88,8 @@ func (d *resourceDescriptor) IsManaged( // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is // fixed. This should be able to be: // - // return k8sctrlutil.ContainsFinalizer(obj, finalizerString) - return containsFinalizer(obj, finalizerString) + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) } // Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 @@ -118,7 +118,7 @@ func (d *resourceDescriptor) MarkManaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.AddFinalizer(obj, finalizerString) + k8sctrlutil.AddFinalizer(obj, FinalizerString) } // MarkUnmanaged removes the supplied resource from management by ACK. What @@ -133,7 +133,7 @@ func (d *resourceDescriptor) MarkUnmanaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.RemoveFinalizer(obj, finalizerString) + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) } // MarkAdopted places descriptors on the custom resource that indicate the diff --git a/pkg/resource/access_entry/resource.go b/pkg/resource/access_entry/resource.go index 4c4d049..8a0ee5c 100644 --- a/pkg/resource/access_entry/resource.go +++ b/pkg/resource/access_entry/resource.go @@ -98,6 +98,22 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error return nil } +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["clusterName"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.ClusterName = &tmp + + f1, f1ok := fields["principalARN"] + if f1ok { + r.ko.Spec.PrincipalARN = &f1 + } + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy() diff --git a/pkg/resource/addon/descriptor.go b/pkg/resource/addon/descriptor.go index f22bacc..3efe5c9 100644 --- a/pkg/resource/addon/descriptor.go +++ b/pkg/resource/addon/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.eks.services.k8s.aws/Addon" + FinalizerString = "finalizers.eks.services.k8s.aws/Addon" ) var ( @@ -88,8 +88,8 @@ func (d *resourceDescriptor) IsManaged( // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is // fixed. This should be able to be: // - // return k8sctrlutil.ContainsFinalizer(obj, finalizerString) - return containsFinalizer(obj, finalizerString) + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) } // Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 @@ -118,7 +118,7 @@ func (d *resourceDescriptor) MarkManaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.AddFinalizer(obj, finalizerString) + k8sctrlutil.AddFinalizer(obj, FinalizerString) } // MarkUnmanaged removes the supplied resource from management by ACK. What @@ -133,7 +133,7 @@ func (d *resourceDescriptor) MarkUnmanaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.RemoveFinalizer(obj, finalizerString) + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) } // MarkAdopted places descriptors on the custom resource that indicate the diff --git a/pkg/resource/addon/resource.go b/pkg/resource/addon/resource.go index d4d43a5..547763c 100644 --- a/pkg/resource/addon/resource.go +++ b/pkg/resource/addon/resource.go @@ -98,6 +98,22 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error return nil } +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["name"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.Name = &tmp + + f1, f1ok := fields["clusterName"] + if f1ok { + r.ko.Spec.ClusterName = &f1 + } + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy() diff --git a/pkg/resource/cluster/descriptor.go b/pkg/resource/cluster/descriptor.go index e4833a8..b066085 100644 --- a/pkg/resource/cluster/descriptor.go +++ b/pkg/resource/cluster/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.eks.services.k8s.aws/Cluster" + FinalizerString = "finalizers.eks.services.k8s.aws/Cluster" ) var ( @@ -88,8 +88,8 @@ func (d *resourceDescriptor) IsManaged( // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is // fixed. This should be able to be: // - // return k8sctrlutil.ContainsFinalizer(obj, finalizerString) - return containsFinalizer(obj, finalizerString) + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) } // Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 @@ -118,7 +118,7 @@ func (d *resourceDescriptor) MarkManaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.AddFinalizer(obj, finalizerString) + k8sctrlutil.AddFinalizer(obj, FinalizerString) } // MarkUnmanaged removes the supplied resource from management by ACK. What @@ -133,7 +133,7 @@ func (d *resourceDescriptor) MarkUnmanaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.RemoveFinalizer(obj, finalizerString) + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) } // MarkAdopted places descriptors on the custom resource that indicate the diff --git a/pkg/resource/cluster/resource.go b/pkg/resource/cluster/resource.go index 99b9cb6..68373de 100644 --- a/pkg/resource/cluster/resource.go +++ b/pkg/resource/cluster/resource.go @@ -93,6 +93,17 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error return nil } +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["name"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.Name = &tmp + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy() diff --git a/pkg/resource/fargate_profile/descriptor.go b/pkg/resource/fargate_profile/descriptor.go index d0ecf5a..a9afdac 100644 --- a/pkg/resource/fargate_profile/descriptor.go +++ b/pkg/resource/fargate_profile/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.eks.services.k8s.aws/FargateProfile" + FinalizerString = "finalizers.eks.services.k8s.aws/FargateProfile" ) var ( @@ -88,8 +88,8 @@ func (d *resourceDescriptor) IsManaged( // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is // fixed. This should be able to be: // - // return k8sctrlutil.ContainsFinalizer(obj, finalizerString) - return containsFinalizer(obj, finalizerString) + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) } // Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 @@ -118,7 +118,7 @@ func (d *resourceDescriptor) MarkManaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.AddFinalizer(obj, finalizerString) + k8sctrlutil.AddFinalizer(obj, FinalizerString) } // MarkUnmanaged removes the supplied resource from management by ACK. What @@ -133,7 +133,7 @@ func (d *resourceDescriptor) MarkUnmanaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.RemoveFinalizer(obj, finalizerString) + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) } // MarkAdopted places descriptors on the custom resource that indicate the diff --git a/pkg/resource/fargate_profile/resource.go b/pkg/resource/fargate_profile/resource.go index fdb5d86..0a35f24 100644 --- a/pkg/resource/fargate_profile/resource.go +++ b/pkg/resource/fargate_profile/resource.go @@ -98,6 +98,22 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error return nil } +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["name"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.Name = &tmp + + f0, f0ok := fields["clusterName"] + if f0ok { + r.ko.Spec.ClusterName = &f0 + } + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy() diff --git a/pkg/resource/identity_provider_config/descriptor.go b/pkg/resource/identity_provider_config/descriptor.go index 88149d5..eec7f0d 100644 --- a/pkg/resource/identity_provider_config/descriptor.go +++ b/pkg/resource/identity_provider_config/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.eks.services.k8s.aws/IdentityProviderConfig" + FinalizerString = "finalizers.eks.services.k8s.aws/IdentityProviderConfig" ) var ( @@ -88,8 +88,8 @@ func (d *resourceDescriptor) IsManaged( // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is // fixed. This should be able to be: // - // return k8sctrlutil.ContainsFinalizer(obj, finalizerString) - return containsFinalizer(obj, finalizerString) + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) } // Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 @@ -118,7 +118,7 @@ func (d *resourceDescriptor) MarkManaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.AddFinalizer(obj, finalizerString) + k8sctrlutil.AddFinalizer(obj, FinalizerString) } // MarkUnmanaged removes the supplied resource from management by ACK. What @@ -133,7 +133,7 @@ func (d *resourceDescriptor) MarkUnmanaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.RemoveFinalizer(obj, finalizerString) + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) } // MarkAdopted places descriptors on the custom resource that indicate the diff --git a/pkg/resource/identity_provider_config/resource.go b/pkg/resource/identity_provider_config/resource.go index f86da25..20087ad 100644 --- a/pkg/resource/identity_provider_config/resource.go +++ b/pkg/resource/identity_provider_config/resource.go @@ -105,6 +105,17 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error return nil } +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["clusterName"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.ClusterName = &tmp + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy() diff --git a/pkg/resource/nodegroup/descriptor.go b/pkg/resource/nodegroup/descriptor.go index ab3bc2b..e7edf86 100644 --- a/pkg/resource/nodegroup/descriptor.go +++ b/pkg/resource/nodegroup/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.eks.services.k8s.aws/Nodegroup" + FinalizerString = "finalizers.eks.services.k8s.aws/Nodegroup" ) var ( @@ -88,8 +88,8 @@ func (d *resourceDescriptor) IsManaged( // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is // fixed. This should be able to be: // - // return k8sctrlutil.ContainsFinalizer(obj, finalizerString) - return containsFinalizer(obj, finalizerString) + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) } // Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 @@ -118,7 +118,7 @@ func (d *resourceDescriptor) MarkManaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.AddFinalizer(obj, finalizerString) + k8sctrlutil.AddFinalizer(obj, FinalizerString) } // MarkUnmanaged removes the supplied resource from management by ACK. What @@ -133,7 +133,7 @@ func (d *resourceDescriptor) MarkUnmanaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.RemoveFinalizer(obj, finalizerString) + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) } // MarkAdopted places descriptors on the custom resource that indicate the diff --git a/pkg/resource/nodegroup/resource.go b/pkg/resource/nodegroup/resource.go index c4655b6..85337ce 100644 --- a/pkg/resource/nodegroup/resource.go +++ b/pkg/resource/nodegroup/resource.go @@ -98,6 +98,22 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error return nil } +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["name"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.Name = &tmp + + f0, f0ok := fields["clusterName"] + if f0ok { + r.ko.Spec.ClusterName = &f0 + } + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy() diff --git a/pkg/resource/pod_identity_association/descriptor.go b/pkg/resource/pod_identity_association/descriptor.go index 0241e7b..7434c56 100644 --- a/pkg/resource/pod_identity_association/descriptor.go +++ b/pkg/resource/pod_identity_association/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.eks.services.k8s.aws/PodIdentityAssociation" + FinalizerString = "finalizers.eks.services.k8s.aws/PodIdentityAssociation" ) var ( @@ -88,8 +88,8 @@ func (d *resourceDescriptor) IsManaged( // https://github.com/kubernetes-sigs/controller-runtime/issues/994 is // fixed. This should be able to be: // - // return k8sctrlutil.ContainsFinalizer(obj, finalizerString) - return containsFinalizer(obj, finalizerString) + // return k8sctrlutil.ContainsFinalizer(obj, FinalizerString) + return containsFinalizer(obj, FinalizerString) } // Remove once https://github.com/kubernetes-sigs/controller-runtime/issues/994 @@ -118,7 +118,7 @@ func (d *resourceDescriptor) MarkManaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.AddFinalizer(obj, finalizerString) + k8sctrlutil.AddFinalizer(obj, FinalizerString) } // MarkUnmanaged removes the supplied resource from management by ACK. What @@ -133,7 +133,7 @@ func (d *resourceDescriptor) MarkUnmanaged( // Should not happen. If it does, there is a bug in the code panic("nil RuntimeMetaObject in AWSResource") } - k8sctrlutil.RemoveFinalizer(obj, finalizerString) + k8sctrlutil.RemoveFinalizer(obj, FinalizerString) } // MarkAdopted places descriptors on the custom resource that indicate the diff --git a/pkg/resource/pod_identity_association/resource.go b/pkg/resource/pod_identity_association/resource.go index ded6f11..e4bc14a 100644 --- a/pkg/resource/pod_identity_association/resource.go +++ b/pkg/resource/pod_identity_association/resource.go @@ -98,6 +98,22 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error return nil } +// PopulateResourceFromAnnotation populates the fields passed from adoption annotation +func (r *resource) PopulateResourceFromAnnotation(fields map[string]string) error { + tmp, ok := fields["clusterName"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.ClusterName = &tmp + + f0, f0ok := fields["associationID"] + if f0ok { + r.ko.Status.AssociationID = &f0 + } + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy()