Skip to content

Commit 0ee4c19

Browse files
committed
reorganize delta pre compare
1 parent d9fef91 commit 0ee4c19

File tree

8 files changed

+62
-40
lines changed

8 files changed

+62
-40
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: "2025-11-29T03:44:25Z"
3-
build_hash: 23c7074fa310ad1ccb38946775397c203b49f024
2+
build_date: "2025-12-10T19:01:54Z"
3+
build_hash: 5c8b9050006ef6c7d3a97c279e7b1bc163f20a0a
44
go_version: go1.25.4
5-
version: v0.56.0
5+
version: v0.56.0-3-g5c8b905
66
api_directory_checksum: 90b0d1adcc91f4a1b1f1b436e3ac0c30d9271678
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6
99
generator_config_info:
10-
file_checksum: 23c3c400e5913ebaa0047af70fda453b065ce321
10+
file_checksum: c41ea4048464974d8ea8548e1933551a483f72c9
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ resources:
293293
DBInstance:
294294
hooks:
295295
delta_pre_compare:
296-
template_path: hooks/db_instance/delta_pre_compare.go.tpl
296+
code: customPreCompare(delta, a, b)
297297
sdk_create_pre_build_request:
298298
template_path: hooks/db_instance/sdk_create_pre_build_request.go.tpl
299299
sdk_create_post_set_output:

generator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ resources:
293293
DBInstance:
294294
hooks:
295295
delta_pre_compare:
296-
template_path: hooks/db_instance/delta_pre_compare.go.tpl
296+
code: customPreCompare(delta, a, b)
297297
sdk_create_pre_build_request:
298298
template_path: hooks/db_instance/sdk_create_pre_build_request.go.tpl
299299
sdk_create_post_set_output:

helm/templates/deployment.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ spec:
5151
- "$(AWS_REGION)"
5252
- --aws-endpoint-url
5353
- "$(AWS_ENDPOINT_URL)"
54+
{{- if .Values.aws.identity_endpoint_url }}
55+
- --aws-identity-endpoint-url
56+
- "$(AWS_IDENTITY_ENDPOINT_URL)"
57+
{{- end }}
58+
{{- if .Values.aws.allow_unsafe_aws_endpoint_urls }}
59+
- --allow-unsafe-aws-endpoint-urls
60+
{{- end }}
5461
{{- if .Values.log.enable_development_logging }}
5562
- --enable-development-logging
5663
{{- end }}
@@ -109,6 +116,8 @@ spec:
109116
value: {{ .Values.aws.region }}
110117
- name: AWS_ENDPOINT_URL
111118
value: {{ .Values.aws.endpoint_url | quote }}
119+
- name: AWS_IDENTITY_ENDPOINT_URL
120+
value: {{ .Values.aws.identity_endpoint_url | quote }}
112121
- name: ACK_WATCH_NAMESPACE
113122
value: {{ include "ack-rds-controller.watch-namespace" . }}
114123
- name: ACK_WATCH_SELECTORS

helm/values.schema.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,16 @@
171171
"region": {
172172
"type": "string"
173173
},
174-
"endpoint": {
174+
"endpoint_url": {
175175
"type": "string"
176176
},
177+
"identity_endpoint_url": {
178+
"type": "string"
179+
},
180+
"allow_unsafe_aws_endpoint_urls": {
181+
"type": "boolean",
182+
"default": false
183+
},
177184
"credentials": {
178185
"description": "AWS credentials information",
179186
"properties": {

helm/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ aws:
9090
# If specified, use the AWS region for AWS API calls
9191
region: ""
9292
endpoint_url: ""
93+
identity_endpoint_url: ""
94+
allow_unsafe_aws_endpoint_urls: false
9395
credentials:
9496
# If specified, Secret with shared credentials file to use.
9597
secretName: ""

pkg/resource/db_instance/delta.go

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

pkg/resource/db_instance/hooks.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,42 @@ var (
111111
)
112112
)
113113

114+
func customPreCompare(delta *ackcompare.Delta, a *resource, b *resource) {
115+
// Do not consider any of the following fields for delta if they are missing in
116+
// desired(a) but are present in latest(b) because each of these fields is
117+
// late-initialized
118+
// This special handling is only needed for DBInstance because late
119+
// initialized values are not returned after successful ModifyDBInstance
120+
// call. They are only populated once the DBInstance returns back to
121+
// available.
122+
if a.ko.Spec.AvailabilityZone == nil &&
123+
b.ko.Spec.AvailabilityZone != nil {
124+
a.ko.Spec.AvailabilityZone = b.ko.Spec.AvailabilityZone
125+
}
126+
if a.ko.Spec.BackupTarget == nil &&
127+
b.ko.Spec.BackupTarget != nil &&
128+
*b.ko.Spec.BackupTarget == ServiceDefaultBackupTarget {
129+
a.ko.Spec.BackupTarget = b.ko.Spec.BackupTarget
130+
}
131+
if a.ko.Spec.NetworkType == nil &&
132+
b.ko.Spec.NetworkType != nil &&
133+
*b.ko.Spec.NetworkType == ServiceDefaultNetworkType {
134+
a.ko.Spec.NetworkType = b.ko.Spec.NetworkType
135+
}
136+
if a.ko.Spec.PerformanceInsightsEnabled == nil &&
137+
b.ko.Spec.PerformanceInsightsEnabled != nil {
138+
a.ko.Spec.PerformanceInsightsEnabled = func() *bool { a := false; return &a }()
139+
}
140+
141+
// RDS will choose preferred engine minor version if only
142+
// engine major version is provided and controler should not
143+
// treat them as different, such as spec has 14, status has 14.1
144+
// controller should treat them as same
145+
reconcileEngineVersion(a, b)
146+
compareTags(delta, a, b)
147+
compareSecretReferenceChanges(delta, a, b)
148+
}
149+
114150
// requeueWaitUntilCanModify returns a `ackrequeue.RequeueNeededAfter` struct
115151
// explaining the DB instance cannot be modified until it reaches an available
116152
// status.

0 commit comments

Comments
 (0)