Skip to content

Commit 488b379

Browse files
committed
fix test failures
Signed-off-by: Atif Ali <[email protected]>
1 parent 21eddb3 commit 488b379

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

pkg/sync/sync_context.go

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,9 +1324,50 @@ func getImmutableFieldChanges(currentSpec, desiredSpec map[string]any) []string
13241324

13251325
// formatVolumeClaimChanges handles the special case of formatting changes to volumeClaimTemplates
13261326
func formatVolumeClaimChanges(currentVal, desiredVal any) []string {
1327-
// Special formatting for volumeClaimTemplates changes
1328-
// Shows storage size changes for each template
1329-
return []string{}
1327+
currentTemplates, ok := currentVal.([]any)
1328+
if !ok {
1329+
return []string{formatFieldChange("volumeClaimTemplates", currentVal, desiredVal)}
1330+
}
1331+
1332+
desiredTemplates, ok := desiredVal.([]any)
1333+
if !ok {
1334+
return []string{formatFieldChange("volumeClaimTemplates", currentVal, desiredVal)}
1335+
}
1336+
1337+
if len(currentTemplates) != len(desiredTemplates) {
1338+
return []string{formatFieldChange("volumeClaimTemplates", currentVal, desiredVal)}
1339+
}
1340+
1341+
var changes []string
1342+
for i := range desiredTemplates {
1343+
desiredTemplate, ok := desiredTemplates[i].(map[string]any)
1344+
if !ok {
1345+
continue
1346+
}
1347+
currentTemplate, ok := currentTemplates[i].(map[string]any)
1348+
if !ok {
1349+
continue
1350+
}
1351+
1352+
// Extract just the template name without storage size
1353+
metadata, ok := desiredTemplate["metadata"].(map[string]any)
1354+
if !ok {
1355+
continue
1356+
}
1357+
name, ok := metadata["name"].(string)
1358+
if !ok || name == "" {
1359+
continue
1360+
}
1361+
1362+
desiredStorage := getTemplateStorage(desiredTemplate)
1363+
currentStorage := getTemplateStorage(currentTemplate)
1364+
1365+
if currentStorage != desiredStorage {
1366+
changes = append(changes, fmt.Sprintf(" - volumeClaimTemplates.%s:\n from: %q\n to: %q",
1367+
name, currentStorage, desiredStorage))
1368+
}
1369+
}
1370+
return changes
13301371
}
13311372

13321373
func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.ResultCode, string) {

0 commit comments

Comments
 (0)