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

Ensure Ref is not overwritten in Spec #128

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ack_generate_info:
build_date: "2024-08-29T17:14:13Z"
build_date: "2024-09-19T16:42:31Z"
build_hash: f8f98563404066ac3340db0a049d2e530e5c51cc
go_version: go1.22.5
go_version: go1.23.0
version: v0.38.1
api_directory_checksum: 626700f8799840e0470b1ff7ef3dbb32665b9f9d
api_version: v1alpha1
Expand Down
17 changes: 16 additions & 1 deletion pkg/resource/cluster/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions templates/hooks/cluster/sdk_create_post_set_output.go.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
if desired.ko.Spec.ResourcesVPCConfig.SubnetRefs != nil {
ko.Spec.ResourcesVPCConfig.SubnetRefs = desired.ko.Spec.ResourcesVPCConfig.SubnetRefs
}

if desired.ko.Spec.ResourcesVPCConfig.SecurityGroupRefs != nil {
ko.Spec.ResourcesVPCConfig.SecurityGroupRefs = desired.ko.Spec.ResourcesVPCConfig.SecurityGroupRefs
}

// We expect the cluster to be in 'CREATING' status since we just issued
// the call to create it, but I suppose it doesn't hurt to check here.
if clusterCreating(&resource{ko}) {
Expand All @@ -6,3 +14,4 @@
ackcondition.SetSynced(&resource{ko}, corev1.ConditionFalse, nil, nil)
return &resource{ko}, nil
}

11 changes: 9 additions & 2 deletions templates/hooks/cluster/sdk_read_one_post_set_output.go.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
if r.ko.Spec.ResourcesVPCConfig.SubnetRefs != nil {
ko.Spec.ResourcesVPCConfig.SubnetRefs = r.ko.Spec.ResourcesVPCConfig.SubnetRefs
}

if r.ko.Spec.ResourcesVPCConfig.SecurityGroupRefs != nil {
ko.Spec.ResourcesVPCConfig.SecurityGroupRefs = r.ko.Spec.ResourcesVPCConfig.SecurityGroupRefs
}

if !clusterActive(&resource{ko}) {
// Setting resource synced condition to false will trigger a requeue of
// the resource. No need to return a requeue error here.
ackcondition.SetSynced(&resource{ko}, corev1.ConditionFalse, nil, nil)
} else {
ackcondition.SetSynced(&resource{ko}, corev1.ConditionTrue, nil, nil)
}

}