Skip to content

Commit 5d677d5

Browse files
committed
more formatting and fix test errors
Signed-off-by: Atif Ali <[email protected]>
1 parent a7511ee commit 5d677d5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pkg/sync/sync_context.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,10 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
10811081
currentVal, exists := currentSpec[k]
10821082
// Only add to changes if values are actually different
10831083
if !exists || !reflect.DeepEqual(currentVal, desiredVal) {
1084+
// Skip if the values are deeply equal (for complex types like volumeClaimTemplates)
1085+
if exists && reflect.DeepEqual(currentVal, desiredVal) {
1086+
continue
1087+
}
10841088
currentStr := formatValue(currentVal)
10851089
desiredStr := formatValue(desiredVal)
10861090
changes = append(changes, fmt.Sprintf(" - %s:\n from: %s\n to: %s",
@@ -1090,11 +1094,13 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
10901094
}
10911095
if len(changes) > 0 {
10921096
sort.Strings(changes)
1093-
return common.ResultCodeSyncFailed, fmt.Sprintf("attempting to change immutable fields:\n%s\n\nForbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden",
1097+
message := fmt.Sprintf("attempting to change immutable fields:\n%s\n\nForbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden",
10941098
strings.Join(changes, "\n"))
1099+
return common.ResultCodeSyncFailed, message
10951100
}
10961101
}
10971102
}
1103+
// For all other errors, return the original error message
10981104
return common.ResultCodeSyncFailed, err.Error()
10991105
}
11001106
if kube.IsCRD(t.targetObj) && !dryRun {

pkg/sync/sync_context_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,8 +2246,6 @@ Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordina
22462246
sc.resourceOps = mockResourceOps
22472247

22482248
_, message := sc.applyObject(task, false, false)
2249-
t.Logf("+++Actual error message:\n%s", message)
2250-
t.Logf("+++Expected error message:\n%s", tt.expectedMessage)
22512249
assert.Equal(t, tt.expectedMessage, message)
22522250
})
22532251
}

0 commit comments

Comments
 (0)