Skip to content

Commit 718d4e7

Browse files
authored
Add a DomainValidations field in Certificate status (#29)
Issue aws-controllers-k8s/community1797 Description of changes: Add a `DomainValidations` status field from the describe operation (`Certificate.DomainValidationOptions`). Both input & output operations contains a `DomainValidationOptions` field but with different contents. Currently the `DomainValidationOptions` in the CRD is from input and do not contains all info from the describe. We define a new field `DomainValidations` using [`from:`](https://aws-controllers-k8s.github.io/community/docs/contributor-docs/code-generator-config/#from-controlling-the-source-of-a-fields-definition) and a `sdk_read_one_pre_set_output` hook to populate it in order to expose these values. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent df3aad1 commit 718d4e7

File tree

9 files changed

+178
-4
lines changed

9 files changed

+178
-4
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2024-01-29T07:08:03Z"
2+
build_date: "2024-02-09T14:53:45Z"
33
build_hash: 92f531cde5631865cfc3dfa778cbc9611f3a64c3
4-
go_version: go1.21.5
4+
go_version: go1.21.6
55
version: v0.29.2
6-
api_directory_checksum: 202e02932e71256f27a9cd0f6454e508c5b7e9b6
6+
api_directory_checksum: eabe0fe64d57edf571ba0eb0217fc376f1185cc0
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.49.0
99
generator_config_info:
10-
file_checksum: 5394dff577561d72517cec97192a6d2ea88f4244
10+
file_checksum: 229489e50bc34730f31e2e0578bec6f9ea7d7215
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/certificate.go

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

apis/v1alpha1/generator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ resources:
3131
# now deleted from the aws-sdk-go private/model/api.Shape object,
3232
# setting `override_values` above does not work :(
3333
code: input.SetValidationMethod("DNS")
34+
sdk_read_one_pre_set_output:
35+
template_path: hooks/certificate/sdk_read_one_pre_set_output.go.tpl
3436
exceptions:
3537
terminal_codes:
3638
- InvalidParameter
@@ -59,6 +61,11 @@ resources:
5961
from:
6062
operation: DescribeCertificate
6163
path: Certificate.CreatedAt
64+
DomainValidations:
65+
is_read_only: true
66+
from:
67+
operation: DescribeCertificate
68+
path: Certificate.DomainValidationOptions
6269
ExtendedKeyUsages:
6370
is_read_only: true
6471
from:

apis/v1alpha1/zz_generated.deepcopy.go

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

config/crd/bases/acm.services.k8s.aws_certificates.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,41 @@ spec:
200200
description: The time at which the certificate was requested.
201201
format: date-time
202202
type: string
203+
domainValidations:
204+
description: |-
205+
Contains information about the initial validation of each domain name that
206+
occurs as a result of the RequestCertificate request. This field exists only
207+
when the certificate type is AMAZON_ISSUED.
208+
items:
209+
description: Contains information about the validation of each domain
210+
name in the certificate.
211+
properties:
212+
domainName:
213+
type: string
214+
resourceRecord:
215+
description: |-
216+
Contains a DNS record value that you can use to validate ownership or control
217+
of a domain. This is used by the DescribeCertificate action.
218+
properties:
219+
name:
220+
type: string
221+
type_:
222+
type: string
223+
value:
224+
type: string
225+
type: object
226+
validationDomain:
227+
type: string
228+
validationEmails:
229+
items:
230+
type: string
231+
type: array
232+
validationMethod:
233+
type: string
234+
validationStatus:
235+
type: string
236+
type: object
237+
type: array
203238
extendedKeyUsages:
204239
description: Contains a list of Extended Key Usage X.509 v3 extension
205240
objects. Each object specifies a purpose for which the certificate

generator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ resources:
3131
# now deleted from the aws-sdk-go private/model/api.Shape object,
3232
# setting `override_values` above does not work :(
3333
code: input.SetValidationMethod("DNS")
34+
sdk_read_one_pre_set_output:
35+
template_path: hooks/certificate/sdk_read_one_pre_set_output.go.tpl
3436
exceptions:
3537
terminal_codes:
3638
- InvalidParameter
@@ -59,6 +61,11 @@ resources:
5961
from:
6062
operation: DescribeCertificate
6163
path: Certificate.CreatedAt
64+
DomainValidations:
65+
is_read_only: true
66+
from:
67+
operation: DescribeCertificate
68+
path: Certificate.DomainValidationOptions
6269
ExtendedKeyUsages:
6370
is_read_only: true
6471
from:

helm/crds/acm.services.k8s.aws_certificates.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,41 @@ spec:
200200
description: The time at which the certificate was requested.
201201
format: date-time
202202
type: string
203+
domainValidations:
204+
description: |-
205+
Contains information about the initial validation of each domain name that
206+
occurs as a result of the RequestCertificate request. This field exists only
207+
when the certificate type is AMAZON_ISSUED.
208+
items:
209+
description: Contains information about the validation of each domain
210+
name in the certificate.
211+
properties:
212+
domainName:
213+
type: string
214+
resourceRecord:
215+
description: |-
216+
Contains a DNS record value that you can use to validate ownership or control
217+
of a domain. This is used by the DescribeCertificate action.
218+
properties:
219+
name:
220+
type: string
221+
type_:
222+
type: string
223+
value:
224+
type: string
225+
type: object
226+
validationDomain:
227+
type: string
228+
validationEmails:
229+
items:
230+
type: string
231+
type: array
232+
validationMethod:
233+
type: string
234+
validationStatus:
235+
type: string
236+
type: object
237+
type: array
203238
extendedKeyUsages:
204239
description: Contains a list of Extended Key Usage X.509 v3 extension
205240
objects. Each object specifies a purpose for which the certificate

pkg/resource/certificate/sdk.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
if resp.Certificate.DomainValidationOptions != nil {
2+
dvs := []*svcapitypes.DomainValidation{}
3+
for _, dvsiter := range resp.Certificate.DomainValidationOptions {
4+
dvselem := &svcapitypes.DomainValidation{}
5+
if dvsiter.DomainName != nil {
6+
dvselem.DomainName = dvsiter.DomainName
7+
}
8+
if dvsiter.ResourceRecord != nil {
9+
dvselem.ResourceRecord = &svcapitypes.ResourceRecord{}
10+
if dvsiter.ResourceRecord.Name != nil {
11+
dvselem.ResourceRecord.Name = dvsiter.ResourceRecord.Name
12+
}
13+
if dvsiter.ResourceRecord.Type != nil {
14+
dvselem.ResourceRecord.Type = dvsiter.ResourceRecord.Type
15+
}
16+
if dvsiter.ResourceRecord.Value != nil {
17+
dvselem.ResourceRecord.Value = dvsiter.ResourceRecord.Value
18+
}
19+
}
20+
if dvsiter.ValidationDomain != nil {
21+
dvselem.ValidationDomain = dvsiter.ValidationDomain
22+
}
23+
if dvsiter.ValidationEmails != nil {
24+
dvselem.ValidationEmails = dvsiter.ValidationEmails
25+
}
26+
if dvsiter.ValidationMethod != nil {
27+
dvselem.ValidationMethod = dvsiter.ValidationMethod
28+
}
29+
if dvsiter.ValidationStatus != nil {
30+
dvselem.ValidationStatus = dvsiter.ValidationStatus
31+
}
32+
dvs = append(dvs, dvselem)
33+
}
34+
ko.Status.DomainValidations = dvs
35+
} else {
36+
ko.Status.DomainValidations = nil
37+
}

0 commit comments

Comments
 (0)