Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CertificateAuthority customSetDefaults method #54

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ack_generate_info:
build_date: "2024-05-02T20:44:28Z"
build_date: "2024-06-26T15:57:25Z"
build_hash: 14cef51778d471698018b6c38b604181a6948248
go_version: go1.22.0
version: v0.34.0
Expand Down
33 changes: 13 additions & 20 deletions pkg/resource/certificate_authority/custom_delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,30 @@ package certificate_authority
import (
svcapitypes "github.com/aws-controllers-k8s/acmpca-controller/apis/v1alpha1"
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
"github.com/aws/aws-sdk-go/aws"
)

func customSetDefaults(
a *resource,
b *resource,
desired *resource,
latest *resource,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know in the generator.yaml there is a definition given with the parameters being a,b. Not sure how the generator works but wanted to call that out in case we need to fix generator.yaml

) {
// Default value of UsageMode is GENERAL_PURPOSE
defaultUsageMode := aws.String("GENERAL_PURPOSE")

if ackcompare.IsNil(a.ko.Spec.UsageMode) && ackcompare.IsNotNil(b.ko.Spec.UsageMode) {
a.ko.Spec.UsageMode = defaultUsageMode
if ackcompare.IsNil(desired.ko.Spec.UsageMode) && ackcompare.IsNotNil(latest.ko.Spec.UsageMode) {
desired.ko.Spec.UsageMode = latest.ko.Spec.UsageMode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the naming is flipped.

You want to set latest/current to the desired state.

}

// Default value of KeyStorageSecurityStandard is FIPS_140_2_LEVEL_3_OR_HIGHER
defaultKeyStorageSecurityStandard := aws.String("FIPS_140_2_LEVEL_3_OR_HIGHER")

if ackcompare.IsNil(a.ko.Spec.KeyStorageSecurityStandard) && ackcompare.IsNotNil(b.ko.Spec.KeyStorageSecurityStandard) {
a.ko.Spec.KeyStorageSecurityStandard = defaultKeyStorageSecurityStandard
if ackcompare.IsNil(desired.ko.Spec.KeyStorageSecurityStandard) && ackcompare.IsNotNil(latest.ko.Spec.KeyStorageSecurityStandard) {
desired.ko.Spec.KeyStorageSecurityStandard = latest.ko.Spec.KeyStorageSecurityStandard
}

if ackcompare.IsNil(a.ko.Spec.RevocationConfiguration) && ackcompare.IsNotNil(b.ko.Spec.RevocationConfiguration) {
a.ko.Spec.RevocationConfiguration = &svcapitypes.RevocationConfiguration{}
if ackcompare.IsNil(desired.ko.Spec.RevocationConfiguration) && ackcompare.IsNotNil(latest.ko.Spec.RevocationConfiguration) {
desired.ko.Spec.RevocationConfiguration = &svcapitypes.RevocationConfiguration{}
}

if ackcompare.IsNotNil(a.ko.Spec.RevocationConfiguration) && ackcompare.IsNotNil(b.ko.Spec.RevocationConfiguration) {
if ackcompare.IsNil(a.ko.Spec.RevocationConfiguration.CRLConfiguration) && ackcompare.IsNotNil(b.ko.Spec.RevocationConfiguration.CRLConfiguration) {
a.ko.Spec.RevocationConfiguration.CRLConfiguration = b.ko.Spec.RevocationConfiguration.CRLConfiguration
if ackcompare.IsNotNil(desired.ko.Spec.RevocationConfiguration) && ackcompare.IsNotNil(latest.ko.Spec.RevocationConfiguration) {
if ackcompare.IsNil(desired.ko.Spec.RevocationConfiguration.CRLConfiguration) && ackcompare.IsNotNil(latest.ko.Spec.RevocationConfiguration.CRLConfiguration) {
desired.ko.Spec.RevocationConfiguration.CRLConfiguration = latest.ko.Spec.RevocationConfiguration.CRLConfiguration
}
if ackcompare.IsNil(a.ko.Spec.RevocationConfiguration.OCSPConfiguration) && ackcompare.IsNotNil(b.ko.Spec.RevocationConfiguration.OCSPConfiguration) {
a.ko.Spec.RevocationConfiguration.OCSPConfiguration = b.ko.Spec.RevocationConfiguration.OCSPConfiguration
if ackcompare.IsNil(desired.ko.Spec.RevocationConfiguration.OCSPConfiguration) && ackcompare.IsNotNil(latest.ko.Spec.RevocationConfiguration.OCSPConfiguration) {
desired.ko.Spec.RevocationConfiguration.OCSPConfiguration = latest.ko.Spec.RevocationConfiguration.OCSPConfiguration
}
}
}