Skip to content

Commit 650538f

Browse files
authored
always use ValidationMethod=DNS (#13)
Not sure when, but at some point in the past year or so, the code generator was changed in a way that when you add fields to the `ignore` list, that field is literally `delete`d from the associated `aws-sdk-go/private/model/api.Shape` object. This means that you cannot have *both* a field that is in the `ignore` list (because you don't want it to appear in the CRD's fields) *AND* have that field referenced in the `override_values` map for an `Operation`. Because the code that sets an Input shape for an Operation iterates over the Input shape's `MemberNames()` collection, and the code generator has literally `delete`d the ignored field from the shape, meaning it cannot be referenced in the override_values code :( This fixes an issue in the ACM controller where the `generator.yaml` file had the ValidationMethod field both ignored and in override_values by adding a `sdk_create_post_build_request` hook that manually sets the `RequestCertificateInput.ValidationMethod` field to "DNS". Closes Issue aws-controllers-k8s/community#1701 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 04859fb commit 650538f

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2023-02-10T00:03:07Z"
3-
build_hash: d0f3d78cbea8061f822cbceac3786128f091efe6
4-
go_version: go1.19
5-
version: v0.24.2
2+
build_date: "2023-02-17T15:23:41Z"
3+
build_hash: 3c89a32e92496e196b6a1d213d338f4e37b37926
4+
go_version: go1.19.4
5+
version: v0.24.2-2-g3c89a32
66
api_directory_checksum: 202e02932e71256f27a9cd0f6454e508c5b7e9b6
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.177
99
generator_config_info:
10-
file_checksum: cf8ed525d9422f011b706c0edf1984d5f70853e5
10+
file_checksum: 5394dff577561d72517cec97192a6d2ea88f4244
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ operations:
66
RequestCertificate:
77
resource_name: Certificate
88
operation_type: CREATE
9-
override_values:
10-
# NOTE(jaypipes): We only support DNS-based validation, because
11-
# certificate renewal is not really automatable when email verification
12-
# is used.
13-
#
14-
# See discussion here:
15-
# https://docs.aws.amazon.com/acm/latest/userguide/email-validation.html
16-
ValidationMethod: DNS
179
# NOTE(jaypipes): There is a GetCertificate API call, but that returns the
1810
# actual cert bytes, not the attributes of the certificate request
1911
DescribeCertificate:
@@ -27,6 +19,18 @@ resources:
2719
hooks:
2820
sdk_create_pre_build_request:
2921
template_path: hooks/certificate/sdk_create_pre_build_request.go.tpl
22+
sdk_create_post_build_request:
23+
# NOTE(jaypipes): We only support DNS-based validation, because
24+
# certificate renewal is not really automatable when email verification
25+
# is used.
26+
#
27+
# See discussion here:
28+
# https://docs.aws.amazon.com/acm/latest/userguide/email-validation.html
29+
#
30+
# Unfortunately, because fields in the "ignore" configuration list are
31+
# now deleted from the aws-sdk-go private/model/api.Shape object,
32+
# setting `override_values` above does not work :(
33+
code: input.SetValidationMethod("DNS")
3034
exceptions:
3135
terminal_codes:
3236
- InvalidParameter

generator.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ operations:
66
RequestCertificate:
77
resource_name: Certificate
88
operation_type: CREATE
9-
override_values:
10-
# NOTE(jaypipes): We only support DNS-based validation, because
11-
# certificate renewal is not really automatable when email verification
12-
# is used.
13-
#
14-
# See discussion here:
15-
# https://docs.aws.amazon.com/acm/latest/userguide/email-validation.html
16-
ValidationMethod: DNS
179
# NOTE(jaypipes): There is a GetCertificate API call, but that returns the
1810
# actual cert bytes, not the attributes of the certificate request
1911
DescribeCertificate:
@@ -27,6 +19,18 @@ resources:
2719
hooks:
2820
sdk_create_pre_build_request:
2921
template_path: hooks/certificate/sdk_create_pre_build_request.go.tpl
22+
sdk_create_post_build_request:
23+
# NOTE(jaypipes): We only support DNS-based validation, because
24+
# certificate renewal is not really automatable when email verification
25+
# is used.
26+
#
27+
# See discussion here:
28+
# https://docs.aws.amazon.com/acm/latest/userguide/email-validation.html
29+
#
30+
# Unfortunately, because fields in the "ignore" configuration list are
31+
# now deleted from the aws-sdk-go private/model/api.Shape object,
32+
# setting `override_values` above does not work :(
33+
code: input.SetValidationMethod("DNS")
3034
exceptions:
3135
terminal_codes:
3236
- InvalidParameter

pkg/resource/certificate/sdk.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)