Skip to content

Commit 66c0f84

Browse files
authored
Merge pull request #569 from michaelhtm/rt-v0.43.0
Pin ACK runtime to v0.43.0
2 parents c2d3b95 + 47feec7 commit 66c0f84

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.22.4
66

77
require (
88
github.com/aws-controllers-k8s/pkg v0.0.15
9-
github.com/aws-controllers-k8s/runtime v0.42.0
9+
github.com/aws-controllers-k8s/runtime v0.43.0
1010
github.com/aws/aws-sdk-go v1.49.0
1111
github.com/aws/aws-sdk-go-v2 v1.32.7
1212
github.com/dlclark/regexp2 v1.10.0 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:l
7373
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
7474
github.com/aws-controllers-k8s/pkg v0.0.15 h1:C1pnD/aDqJsU9oYf5upHkpSc+Hv4JQVtkdCpfZQIPig=
7575
github.com/aws-controllers-k8s/pkg v0.0.15/go.mod h1:VvdjLWmR6IJ3KU8KByKiq/lJE8M+ur2piXysXKTGUS0=
76-
github.com/aws-controllers-k8s/runtime v0.42.0 h1:fVb3cOwUtn0ZwTSedapES+Rspb97S8BTxMqXJt6R5uM=
77-
github.com/aws-controllers-k8s/runtime v0.42.0/go.mod h1:Oy0JKvDxZMZ+SVupm4NZVqP00KLIIAMfk93KnOwlt5c=
76+
github.com/aws-controllers-k8s/runtime v0.43.0 h1:mCtMHO0rew84VbqotquvBirnKysbao+y2G3QI8bKZxM=
77+
github.com/aws-controllers-k8s/runtime v0.43.0/go.mod h1:Oy0JKvDxZMZ+SVupm4NZVqP00KLIIAMfk93KnOwlt5c=
7878
github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY=
7979
github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
8080
github.com/aws/aws-sdk-go-v2 v1.32.7 h1:ky5o35oENWi0JYWUZkB7WYvVPP+bcRF5/Iq7JWSb5Rw=

pkg/generate/ack/runtime_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ func (frm *fakeRM) EnsureTags(
147147
return nil
148148
}
149149

150+
func (frm *fakeRM) FilterSystemTags(acktypes.AWSResource) {}
151+
150152
// This test is mostly just a hack to introduce a Go module dependency between
151153
// the ACK runtime library and the code generator. The code generator doesn't
152154
// actually depend on Go code in the ACK runtime, but it *produces* templated

templates/pkg/resource/manager.go.tpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ func (rm *resourceManager) FilterSystemTags(res acktypes.AWSResource) {
342342
{{ end -}}
343343
existingTags = r.ko.Spec.{{ $tagField.Path }}
344344
resourceTags := ToACKTags(existingTags)
345-
IgnoreAWSTags(resourceTags)
345+
ignoreSystemTags(resourceTags)
346346
{{ GoCodeInitializeNestedStructField .CRD "r.ko" $tagField "svcapitypes" 1 -}}
347347
r.ko.Spec.{{ $tagField.Path }} = FromACKTags(resourceTags)
348348
{{- end }}
349349
{{- end }}
350350
}
351351
352-
// MirrorAWSTags ensures that AWS tags are included in the desired resource
352+
// mirrorAWSTags ensures that AWS tags are included in the desired resource
353353
// if they are present in the latest resource. This will ensure that the
354354
// aws tags are not present in a diff. The logic of the controller will
355355
// ensure these tags aren't patched to the resource in the cluster, and
@@ -395,7 +395,7 @@ func mirrorAWSTags(a *resource, b *resource) {
395395
existingLatestTags = b.ko.Spec.{{ $tagField.Path }}
396396
desiredTags := ToACKTags(existingDesiredTags)
397397
latestTags := ToACKTags(existingLatestTags)
398-
SyncAWSTags(desiredTags, latestTags)
398+
syncAWSTags(desiredTags, latestTags)
399399
{{ GoCodeInitializeNestedStructField .CRD "a.ko" $tagField "svcapitypes" 1 -}}
400400
a.ko.Spec.{{ $tagField.Path }} = FromACKTags(desiredTags)
401401
{{- end }}

templates/pkg/resource/tags.go.tpl

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import(
1111
var (
1212
_ = svcapitypes.{{ .CRD.Kind }}{}
1313
_ = acktags.NewTags()
14+
ACKSystemTags = []string{"services.k8s.aws/namespace", "services.k8s.aws/controller-version"}
1415
)
1516

1617
{{- if $hookCode := Hook .CRD "convert_tags" }}
@@ -87,21 +88,20 @@ func FromACKTags(tags acktags.Tags) {{ $tagFieldGoType }} {
8788
}
8889
{{ end }}
8990

90-
// IgnoreAWSTags ignores tags that have keys that start with "aws:"
91-
// is needed to ensure the controller does not attempt to remove
92-
// tags set by AWS
91+
// ignoreSystemTags ignores tags that have keys that start with "aws:"
92+
// and ACKSystemTags, to avoid patching them to the resourceSpec.
9393
// Eg. resources created with cloudformation have tags that cannot be
9494
// removed by an ACK controller
95-
func IgnoreAWSTags(tags acktags.Tags) {
95+
func ignoreSystemTags(tags acktags.Tags) {
9696
for k := range tags {
9797
if strings.HasPrefix(k, "aws:") ||
98-
strings.HasPrefix(k, "services.k8s.aws/") {
98+
slices.Contains(ACKSystemTags, k) {
9999
delete(tags, k)
100100
}
101101
}
102102
}
103103

104-
// SyncAWSTags ensures AWS-managed tags (prefixed with "aws:") from the latest resource state
104+
// syncAWSTags ensures AWS-managed tags (prefixed with "aws:") from the latest resource state
105105
// are preserved in the desired state. This prevents the controller from attempting to
106106
// modify AWS-managed tags, which would result in an error.
107107
//
@@ -120,7 +120,7 @@ func IgnoreAWSTags(tags acktags.Tags) {
120120
// desired := Tags{"environment": "dev"}
121121
// SyncAWSTags(desired, latest)
122122
// desired now contains {"aws:cloudformation:stack-name": "my-stack", "environment": "dev"}
123-
func SyncAWSTags(a acktags.Tags, b acktags.Tags) {
123+
func syncAWSTags(a acktags.Tags, b acktags.Tags) {
124124
for k := range b {
125125
if strings.HasPrefix(k, "aws:") {
126126
a[k] = b[k]

0 commit comments

Comments
 (0)