From 3f2f271beb5f40a435b6cfd2382dc37fb8656a10 Mon Sep 17 00:00:00 2001 From: ci-robot Date: Mon, 9 Dec 2024 17:21:05 +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 | 2 +- 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/api/descriptor.go | 10 +++++----- pkg/resource/api/resource.go | 11 +++++++++++ pkg/resource/api_mapping/descriptor.go | 10 +++++----- pkg/resource/api_mapping/resource.go | 16 ++++++++++++++++ pkg/resource/authorizer/descriptor.go | 10 +++++----- pkg/resource/authorizer/resource.go | 16 ++++++++++++++++ pkg/resource/deployment/descriptor.go | 10 +++++----- pkg/resource/deployment/resource.go | 16 ++++++++++++++++ pkg/resource/domain_name/descriptor.go | 10 +++++----- pkg/resource/domain_name/resource.go | 11 +++++++++++ pkg/resource/integration/descriptor.go | 10 +++++----- pkg/resource/integration/resource.go | 16 ++++++++++++++++ pkg/resource/route/descriptor.go | 10 +++++----- pkg/resource/route/resource.go | 16 ++++++++++++++++ pkg/resource/stage/descriptor.go | 10 +++++----- pkg/resource/stage/resource.go | 16 ++++++++++++++++ pkg/resource/vpc_link/descriptor.go | 10 +++++----- pkg/resource/vpc_link/resource.go | 11 +++++++++++ 27 files changed, 196 insertions(+), 61 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index ead97f1..49147c6 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-10T03:55:13Z" - build_hash: 36c2d234498c2bc4f60773ab8df632af4067f43b - go_version: go1.23.2 - version: v0.39.1 + build_date: "2024-12-09T17:17:08Z" + build_hash: 631aeb190e332addb8379672df6367a0875dce88 + go_version: go1.23.3 + version: v0.40.0 api_directory_checksum: 1ec0ec190e4702c6e71245aba52bf8119d32641a api_version: v1alpha1 aws_sdk_go_version: v1.49.0 diff --git a/config/controller/deployment.yaml b/config/controller/deployment.yaml index 1662756..6743692 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 df53652..c8236a9 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/apigatewayv2-controller - newTag: 1.0.17 + newTag: 1.0.18 diff --git a/go.mod b/go.mod index 9eb883e..244ee0f 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.0 toolchain go1.22.5 require ( - github.com/aws-controllers-k8s/runtime v0.39.0 + github.com/aws-controllers-k8s/runtime v0.40.0 github.com/aws/aws-sdk-go v1.49.0 github.com/go-logr/logr v1.4.2 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index 0ee8ad5..6a1eba4 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -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.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY= github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 11f627a..9e50268 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 name: apigatewayv2-chart description: A Helm chart for the ACK service controller for Amazon API Gateway (APIGWv2) -version: 1.0.17 -appVersion: 1.0.17 +version: 1.0.18 +appVersion: 1.0.18 home: https://github.com/aws-controllers-k8s/apigatewayv2-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 06a4332..cdfcde0 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/apigatewayv2-controller:1.0.17". +This chart deploys "public.ecr.aws/aws-controllers-k8s/apigatewayv2-controller:1.0.18". 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 56f57b0..2b51323 100644 --- a/helm/templates/caches-role-binding.yaml +++ b/helm/templates/caches-role-binding.yaml @@ -8,7 +8,7 @@ roleRef: name: ack-namespaces-cache-apigatewayv2-controller subjects: - kind: ServiceAccount - name: ack-apigatewayv2-controller + name: {{ include "ack-apigatewayv2-controller.service-account.name" . }} namespace: {{ .Release.Namespace }} --- apiVersion: rbac.authorization.k8s.io/v1 @@ -22,5 +22,5 @@ roleRef: name: ack-configmaps-cache-apigatewayv2-controller subjects: - kind: ServiceAccount - name: ack-apigatewayv2-controller - namespace: {{ .Release.Namespace }} \ No newline at end of file + name: {{ include "ack-apigatewayv2-controller.service-account.name" . }} + namespace: {{ .Release.Namespace }} diff --git a/helm/values.yaml b/helm/values.yaml index 22c3dc2..aca51cb 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -4,7 +4,7 @@ image: repository: public.ecr.aws/aws-controllers-k8s/apigatewayv2-controller - tag: 1.0.17 + tag: 1.0.18 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/api/descriptor.go b/pkg/resource/api/descriptor.go index d7da7e7..4efef33 100644 --- a/pkg/resource/api/descriptor.go +++ b/pkg/resource/api/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/API" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/API" ) 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/api/resource.go b/pkg/resource/api/resource.go index 50e97a1..a000c3b 100644 --- a/pkg/resource/api/resource.go +++ b/pkg/resource/api/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["apiID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.APIID = &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/api_mapping/descriptor.go b/pkg/resource/api_mapping/descriptor.go index 84eb610..a699df4 100644 --- a/pkg/resource/api_mapping/descriptor.go +++ b/pkg/resource/api_mapping/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/APIMapping" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/APIMapping" ) 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/api_mapping/resource.go b/pkg/resource/api_mapping/resource.go index 15a9fa9..d82418d 100644 --- a/pkg/resource/api_mapping/resource.go +++ b/pkg/resource/api_mapping/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["apiMappingID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.APIMappingID = &tmp + + f1, f1ok := fields["domainName"] + if f1ok { + r.ko.Spec.DomainName = &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/authorizer/descriptor.go b/pkg/resource/authorizer/descriptor.go index ed09326..395d5d8 100644 --- a/pkg/resource/authorizer/descriptor.go +++ b/pkg/resource/authorizer/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/Authorizer" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/Authorizer" ) 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/authorizer/resource.go b/pkg/resource/authorizer/resource.go index 967b9c9..7e76d05 100644 --- a/pkg/resource/authorizer/resource.go +++ b/pkg/resource/authorizer/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["authorizerID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.AuthorizerID = &tmp + + f0, f0ok := fields["apiID"] + if f0ok { + r.ko.Spec.APIID = &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/deployment/descriptor.go b/pkg/resource/deployment/descriptor.go index 5be08fc..9033fa8 100644 --- a/pkg/resource/deployment/descriptor.go +++ b/pkg/resource/deployment/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/Deployment" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/Deployment" ) 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/deployment/resource.go b/pkg/resource/deployment/resource.go index 84d2c70..3238b45 100644 --- a/pkg/resource/deployment/resource.go +++ b/pkg/resource/deployment/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["deploymentID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.DeploymentID = &tmp + + f0, f0ok := fields["apiID"] + if f0ok { + r.ko.Spec.APIID = &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/domain_name/descriptor.go b/pkg/resource/domain_name/descriptor.go index 16ae0c3..fa489ee 100644 --- a/pkg/resource/domain_name/descriptor.go +++ b/pkg/resource/domain_name/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/DomainName" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/DomainName" ) 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/domain_name/resource.go b/pkg/resource/domain_name/resource.go index affa92b..89bc83c 100644 --- a/pkg/resource/domain_name/resource.go +++ b/pkg/resource/domain_name/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["domainName"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.DomainName = &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/integration/descriptor.go b/pkg/resource/integration/descriptor.go index 887f2bf..e5bcc36 100644 --- a/pkg/resource/integration/descriptor.go +++ b/pkg/resource/integration/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/Integration" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/Integration" ) 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/integration/resource.go b/pkg/resource/integration/resource.go index 7799f7f..c48015d 100644 --- a/pkg/resource/integration/resource.go +++ b/pkg/resource/integration/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["integrationID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.IntegrationID = &tmp + + f0, f0ok := fields["apiID"] + if f0ok { + r.ko.Spec.APIID = &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/route/descriptor.go b/pkg/resource/route/descriptor.go index 6114e03..b0a431f 100644 --- a/pkg/resource/route/descriptor.go +++ b/pkg/resource/route/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/Route" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/Route" ) 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/route/resource.go b/pkg/resource/route/resource.go index cd2c24c..79d0f3c 100644 --- a/pkg/resource/route/resource.go +++ b/pkg/resource/route/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["routeID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.RouteID = &tmp + + f0, f0ok := fields["apiID"] + if f0ok { + r.ko.Spec.APIID = &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/stage/descriptor.go b/pkg/resource/stage/descriptor.go index b7aca09..93d32f1 100644 --- a/pkg/resource/stage/descriptor.go +++ b/pkg/resource/stage/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/Stage" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/Stage" ) 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/stage/resource.go b/pkg/resource/stage/resource.go index 34c18cc..7a39c07 100644 --- a/pkg/resource/stage/resource.go +++ b/pkg/resource/stage/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["stageName"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Spec.StageName = &tmp + + f0, f0ok := fields["apiID"] + if f0ok { + r.ko.Spec.APIID = &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/vpc_link/descriptor.go b/pkg/resource/vpc_link/descriptor.go index 59b41c9..d9d31ba 100644 --- a/pkg/resource/vpc_link/descriptor.go +++ b/pkg/resource/vpc_link/descriptor.go @@ -28,7 +28,7 @@ import ( ) const ( - finalizerString = "finalizers.apigatewayv2.services.k8s.aws/VPCLink" + FinalizerString = "finalizers.apigatewayv2.services.k8s.aws/VPCLink" ) 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/vpc_link/resource.go b/pkg/resource/vpc_link/resource.go index 303712f..55b861e 100644 --- a/pkg/resource/vpc_link/resource.go +++ b/pkg/resource/vpc_link/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["vpcLinkID"] + if !ok { + return ackerrors.MissingNameIdentifier + } + r.ko.Status.VPCLinkID = &tmp + + return nil +} + // DeepCopy will return a copy of the resource func (r *resource) DeepCopy() acktypes.AWSResource { koCopy := r.ko.DeepCopy()