@@ -11,6 +11,7 @@ import(
1111var (
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