Skip to content

Commit 4dd45e7

Browse files
Simon WakenhutSimon Wakenhut
authored andcommitted
fix(ecs): Fix LateInitialize & Slice diffs
Signed-off-by: Simon Wakenhut <[email protected]>
1 parent 45ad7a5 commit 4dd45e7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pkg/clients/ecs/taskdefinitionfamily/task_definition_family.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ func LateInitialize(in *ecs.TaskDefinitionFamilyParameters, resp *awsecs.Describ
4646
}
4747
}
4848
if in.Volumes != nil {
49-
for voli, vol := range in.Volumes {
50-
awsvol := resp.TaskDefinition.Volumes[voli]
51-
if vol.Host == nil && awsvol.Host != nil {
52-
vol.Host = &ecs.HostVolumeProperties{
53-
SourcePath: awsvol.Host.SourcePath,
49+
if len(in.Volumes) == len(resp.TaskDefinition.Volumes) {
50+
for voli, vol := range in.Volumes {
51+
awsvol := resp.TaskDefinition.Volumes[voli]
52+
if vol.Host == nil && awsvol.Host != nil {
53+
vol.Host = &ecs.HostVolumeProperties{
54+
SourcePath: awsvol.Host.SourcePath,
55+
}
5456
}
5557
}
5658
}
@@ -752,10 +754,16 @@ func IsUpToDate(target *ecs.TaskDefinitionFamily, out *awsecs.DescribeTaskDefini
752754
c := GenerateTaskDefinitionFamilyFromDescribe(out).Spec.ForProvider.DeepCopy()
753755

754756
tags := func(a, b *ecs.Tag) bool { return aws.StringValue(a.Key) < aws.StringValue(b.Key) }
757+
stringpointer := func(a, b *string) bool { return aws.StringValue(a) < aws.StringValue(b) }
758+
keyValuePair := func(a, b *ecs.KeyValuePair) bool { return aws.StringValue(a.Name) < aws.StringValue(b.Name) }
759+
secret := func(a, b *ecs.Secret) bool { return aws.StringValue(a.Name) < aws.StringValue(b.Name) }
755760

756761
diff := cmp.Diff(c, t,
757762
cmpopts.EquateEmpty(),
758763
cmpopts.SortSlices(tags),
764+
cmpopts.SortSlices(stringpointer),
765+
cmpopts.SortSlices(keyValuePair),
766+
cmpopts.SortSlices(secret),
759767
// Not present in DescribeTaskDefinitionOutput
760768
cmpopts.IgnoreFields(ecs.TaskDefinitionFamilyParameters{}, "Region"),
761769
cmpopts.IgnoreTypes(&xpv1.Reference{}, &xpv1.Selector{}, []xpv1.Reference{}))

pkg/controller/ecs/service/setup.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ func isUpToDate(context context.Context, service *svcapitypes.Service, output *s
7777

7878
tags := func(a, b *svcapitypes.Tag) bool { return aws.StringValue(a.Key) < aws.StringValue(b.Key) }
7979
stringpointer := func(a, b *string) bool { return aws.StringValue(a) < aws.StringValue(b) }
80+
keyValuePair := func(a, b *svcsdk.KeyValuePair) bool { return aws.StringValue(a.Name) < aws.StringValue(b.Name) }
8081

8182
diff := cmp.Diff(c, t,
8283
cmpopts.EquateEmpty(),
8384
cmpopts.SortSlices(tags),
8485
cmpopts.SortSlices(stringpointer),
86+
cmpopts.SortSlices(keyValuePair),
8587
// Not present in DescribeServicesOutput
8688
cmpopts.IgnoreFields(svcapitypes.ServiceParameters{}, "Region"),
8789
cmpopts.IgnoreFields(svcapitypes.CustomServiceParameters{}, "Cluster"),

0 commit comments

Comments
 (0)