diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index ac0af02..02cb01b 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,8 +1,8 @@ ack_generate_info: - build_date: "2025-02-20T18:30:53Z" - build_hash: a326346bd3a6973254d247c9ab2dc76790c36241 + build_date: "2025-03-14T20:44:04Z" + build_hash: 0ab258c51775fd52af32e649da00d57373b20869 go_version: go1.24.0 - version: v0.43.2 + version: v0.43.2-6-g0ab258c api_directory_checksum: 2627dc306e3a83c86c04050c6c4336451459e728 api_version: v1alpha1 aws_sdk_go_version: v1.32.6 diff --git a/pkg/resource/queue/delta.go b/pkg/resource/queue/delta.go index fe3ee67..7504614 100644 --- a/pkg/resource/queue/delta.go +++ b/pkg/resource/queue/delta.go @@ -140,7 +140,9 @@ func newResourceDelta( delta.Add("Spec.SQSManagedSSEEnabled", a.ko.Spec.SQSManagedSSEEnabled, b.ko.Spec.SQSManagedSSEEnabled) } } - if !ackcompare.MapStringStringEqual(ToACKTags(a.ko.Spec.Tags), ToACKTags(b.ko.Spec.Tags)) { + desiredACKTags, _ := convertToOrderedACKTags(a.ko.Spec.Tags) + latestACKTags, _ := convertToOrderedACKTags(b.ko.Spec.Tags) + if !ackcompare.MapStringStringEqual(desiredACKTags, latestACKTags) { delta.Add("Spec.Tags", a.ko.Spec.Tags, b.ko.Spec.Tags) } if ackcompare.HasNilDifference(a.ko.Spec.VisibilityTimeout, b.ko.Spec.VisibilityTimeout) { diff --git a/pkg/resource/queue/manager.go b/pkg/resource/queue/manager.go index dff6544..4d32aa6 100644 --- a/pkg/resource/queue/manager.go +++ b/pkg/resource/queue/manager.go @@ -324,9 +324,9 @@ func (rm *resourceManager) EnsureTags( defaultTags := ackrt.GetDefaultTags(&rm.cfg, r.ko, md) var existingTags map[string]*string existingTags = r.ko.Spec.Tags - resourceTags := ToACKTags(existingTags) + resourceTags, keyOrder := convertToOrderedACKTags(existingTags) tags := acktags.Merge(resourceTags, defaultTags) - r.ko.Spec.Tags = FromACKTags(tags) + r.ko.Spec.Tags = fromACKTags(tags, keyOrder) return nil } @@ -343,9 +343,9 @@ func (rm *resourceManager) FilterSystemTags(res acktypes.AWSResource) { } var existingTags map[string]*string existingTags = r.ko.Spec.Tags - resourceTags := ToACKTags(existingTags) + resourceTags, tagKeyOrder := convertToOrderedACKTags(existingTags) ignoreSystemTags(resourceTags) - r.ko.Spec.Tags = FromACKTags(resourceTags) + r.ko.Spec.Tags = fromACKTags(resourceTags, tagKeyOrder) } // mirrorAWSTags ensures that AWS tags are included in the desired resource @@ -367,10 +367,10 @@ func mirrorAWSTags(a *resource, b *resource) { var existingDesiredTags map[string]*string existingDesiredTags = a.ko.Spec.Tags existingLatestTags = b.ko.Spec.Tags - desiredTags := ToACKTags(existingDesiredTags) - latestTags := ToACKTags(existingLatestTags) + desiredTags, desiredTagKeyOrder := convertToOrderedACKTags(existingDesiredTags) + latestTags, _ := convertToOrderedACKTags(existingLatestTags) syncAWSTags(desiredTags, latestTags) - a.ko.Spec.Tags = FromACKTags(desiredTags) + a.ko.Spec.Tags = fromACKTags(desiredTags, desiredTagKeyOrder) } // newResourceManager returns a new struct implementing diff --git a/pkg/resource/queue/sdk.go b/pkg/resource/queue/sdk.go index b89f95a..d4761c8 100644 --- a/pkg/resource/queue/sdk.go +++ b/pkg/resource/queue/sdk.go @@ -189,7 +189,7 @@ func (rm *resourceManager) sdkFind( if tags, err := rm.getTags(ctx, r); err != nil { return nil, err } else { - ko.Spec.Tags = FromACKTags(tags) + ko.Spec.Tags = fromACKTags(tags, nil) } return &resource{ko}, nil diff --git a/pkg/resource/queue/tags.go b/pkg/resource/queue/tags.go index a3990ba..c07139d 100644 --- a/pkg/resource/queue/tags.go +++ b/pkg/resource/queue/tags.go @@ -30,15 +30,17 @@ var ( ACKSystemTags = []string{"services.k8s.aws/namespace", "services.k8s.aws/controller-version"} ) -// ToACKTags converts the tags parameter into 'acktags.Tags' shape. +// convertToOrderedACKTags converts the tags parameter into 'acktags.Tags' shape. // This method helps in creating the hub(acktags.Tags) for merging -// default controller tags with existing resource tags. -func ToACKTags(tags map[string]*string) acktags.Tags { +// default controller tags with existing resource tags. It also returns a slice +// of keys maintaining the original key Order when the tags are a list +func convertToOrderedACKTags(tags map[string]*string) (acktags.Tags, []string) { result := acktags.NewTags() - if tags == nil || len(tags) == 0 { - return result - } + keyOrder := []string{} + if len(tags) == 0 { + return result, keyOrder + } for k, v := range tags { if v == nil { result[k] = "" @@ -47,18 +49,21 @@ func ToACKTags(tags map[string]*string) acktags.Tags { } } - return result + return result, keyOrder } -// FromACKTags converts the tags parameter into map[string]*string shape. +// fromACKTags converts the tags parameter into map[string]*string shape. // This method helps in setting the tags back inside AWSResource after merging -// default controller tags with existing resource tags. -func FromACKTags(tags acktags.Tags) map[string]*string { +// default controller tags with existing resource tags. When a list, +// it maintains the order from original +func fromACKTags(tags acktags.Tags, keyOrder []string) map[string]*string { result := map[string]*string{} + + _ = keyOrder for k, v := range tags { - vCopy := v - result[k] = &vCopy + result[k] = &v } + return result } diff --git a/templates/hooks/queue/sdk_get_attributes_post_set_output.go.tpl b/templates/hooks/queue/sdk_get_attributes_post_set_output.go.tpl index a97dc70..4d205d5 100644 --- a/templates/hooks/queue/sdk_get_attributes_post_set_output.go.tpl +++ b/templates/hooks/queue/sdk_get_attributes_post_set_output.go.tpl @@ -1,5 +1,5 @@ if tags, err := rm.getTags(ctx, r); err != nil { return nil, err } else { - ko.Spec.Tags = FromACKTags(tags) + ko.Spec.Tags = fromACKTags(tags, nil) }