From eebb52d7bc2ad60d84f545529697e1950e901bb6 Mon Sep 17 00:00:00 2001 From: michaelhtm <98621731+michaelhtm@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:05:38 -0700 Subject: [PATCH] Include additional keys to adopt identityProviderConfig This change ensures users are required to provide an identityProviderConfigName when adopting the resource, as it is a required input field. Not sure if we should change that to the primary NameOrID, and make clusterName and additional Key.. --- apis/v1alpha1/ack-generate-metadata.yaml | 10 +++++----- apis/v1alpha1/generator.yaml | 2 ++ generator.yaml | 2 ++ pkg/resource/identity_provider_config/resource.go | 12 ++++++++++++ .../post_set_resource_identifiers.go.tpl | 12 ++++++++++++ 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 templates/hooks/identity_provider_config/post_set_resource_identifiers.go.tpl diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 487050f..9b05619 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,13 +1,13 @@ ack_generate_info: - build_date: "2024-10-10T03:55:41Z" - build_hash: 36c2d234498c2bc4f60773ab8df632af4067f43b + build_date: "2024-10-17T18:18:29Z" + build_hash: ab15f9206796e9660c51695fab0ff07a09ea28e2 go_version: go1.23.2 - version: v0.39.1 -api_directory_checksum: d736919240d3843865e860f7cb685cec30921bd4 + version: v0.39.1-2-gab15f92 +api_directory_checksum: 4cfe0b6ec81b65719c1f165983b84116135f5e40 api_version: v1alpha1 aws_sdk_go_version: v1.55.5 generator_config_info: - file_checksum: 157f31e5a8ce8e0e922e4e5c2e406841ec1a8136 + file_checksum: 5b5c72cb103e99a0dd19beffb8863f16e4fd163e original_file_name: generator.yaml last_modification: reason: API generation diff --git a/apis/v1alpha1/generator.yaml b/apis/v1alpha1/generator.yaml index b30742e..e3c3e77 100644 --- a/apis/v1alpha1/generator.yaml +++ b/apis/v1alpha1/generator.yaml @@ -145,6 +145,8 @@ resources: template_path: hooks/identity_provider_config/sdk_create_post_set_output.go.tpl sdk_read_one_post_set_output: template_path: hooks/identity_provider_config/sdk_read_one_post_set_output.go.tpl + post_set_resource_identifiers: + template_path: hooks/identity_provider_config/post_set_resource_identifiers.go.tpl update_operation: custom_method_name: customUpdate Cluster: diff --git a/generator.yaml b/generator.yaml index b30742e..e3c3e77 100644 --- a/generator.yaml +++ b/generator.yaml @@ -145,6 +145,8 @@ resources: template_path: hooks/identity_provider_config/sdk_create_post_set_output.go.tpl sdk_read_one_post_set_output: template_path: hooks/identity_provider_config/sdk_read_one_post_set_output.go.tpl + post_set_resource_identifiers: + template_path: hooks/identity_provider_config/post_set_resource_identifiers.go.tpl update_operation: custom_method_name: customUpdate Cluster: diff --git a/pkg/resource/identity_provider_config/resource.go b/pkg/resource/identity_provider_config/resource.go index c3c58d6..b25a4c4 100644 --- a/pkg/resource/identity_provider_config/resource.go +++ b/pkg/resource/identity_provider_config/resource.go @@ -90,6 +90,18 @@ func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error } r.ko.Spec.ClusterName = &identifier.NameOrID + if identifier.AdditionalKeys == nil { + return fmt.Errorf("expected additional key `identityProviderConfigName` identifier, found nil") + } + f0, f0ok := identifier.AdditionalKeys["identityProviderConfigName"] + if f0ok { + r.ko.Spec.OIDC = &svcapitypes.OIDCIdentityProviderConfigRequest{ + IdentityProviderConfigName: &f0, + } + } else { + return fmt.Errorf("expected additional key `identityProviderConfigName` identifier, found empty") + } + return nil } diff --git a/templates/hooks/identity_provider_config/post_set_resource_identifiers.go.tpl b/templates/hooks/identity_provider_config/post_set_resource_identifiers.go.tpl new file mode 100644 index 0000000..54a94db --- /dev/null +++ b/templates/hooks/identity_provider_config/post_set_resource_identifiers.go.tpl @@ -0,0 +1,12 @@ + + if identifier.AdditionalKeys == nil { + return fmt.Errorf("expected additional key `identityProviderConfigName` identifier, found nil") + } + f0, f0ok := identifier.AdditionalKeys["identityProviderConfigName"] + if f0ok { + r.ko.Spec.OIDC = &svcapitypes.OIDCIdentityProviderConfigRequest{ + IdentityProviderConfigName: &f0, + } + } else { + return fmt.Errorf("expected additional key `identityProviderConfigName` identifier, found empty") + }