Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions util/argo/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,23 @@ func diffArrayCached(configArray []*unstructured.Unstructured, liveArray []*unst
} else {
key = kube.GetResourceKey(config)
}

// Always calculate diff for custom resources to ensure field-level changes are detected
isCustomResource := config != nil && live != nil && config.GetAPIVersion() != live.GetAPIVersion()
var dr *diff.DiffResult
if cachedDiff, ok := diffByKey[key]; ok && cachedDiff.ResourceVersion == resourceVersion {
dr = &diff.DiffResult{
NormalizedLive: []byte(cachedDiff.NormalizedLiveState),
PredictedLive: []byte(cachedDiff.PredictedLiveState),
Modified: cachedDiff.Modified,
if !isCustomResource {
if cachedItem, ok := diffByKey[key]; ok && cachedItem.ResourceVersion == resourceVersion {
dr = &diff.DiffResult{
NormalizedLive: []byte(cachedItem.NormalizedLiveState),
PredictedLive: []byte(cachedItem.PredictedLiveState),
Modified: cachedItem.Modified,
}
} else {
res, err := diff.Diff(configArray[i], liveArray[i], opts...)
if err != nil {
return nil, err
}
dr = res
}
} else {
res, err := diff.Diff(configArray[i], liveArray[i], opts...)
Expand All @@ -378,6 +389,7 @@ func diffArrayCached(configArray []*unstructured.Unstructured, liveArray []*unst
}
dr = res
}

if dr != nil {
diffResultList.Diffs[i] = *dr
if dr.Modified {
Expand Down
Loading