Skip to content

Normalize resource key before grouping manifests to convert default namespace to empty #5774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions pkg/app/pipedv1/plugin/kubernetes/provider/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,26 @@ func DiffList(liveManifests, desiredManifests []Manifest, logger *zap.Logger, op
func groupManifests(olds, news []Manifest) (adds, deletes, newChanges, oldChanges []Manifest) {
// Sort the manifests before comparing.
sort.Slice(news, func(i, j int) bool {
return news[i].Key().String() < news[j].Key().String()
return news[i].Key().normalize().String() < news[j].Key().normalize().String()
})
sort.Slice(olds, func(i, j int) bool {
return olds[i].Key().String() < olds[j].Key().String()
return olds[i].Key().normalize().String() < olds[j].Key().normalize().String()
})

var n, o int
for {
if n >= len(news) || o >= len(olds) {
break
}
if news[n].Key().String() == olds[o].Key().String() {
if news[n].Key().normalize().String() == olds[o].Key().normalize().String() {
newChanges = append(newChanges, news[n])
oldChanges = append(oldChanges, olds[o])
n++
o++
continue
}
// Has in news but not in olds so this should be a added one.
if news[n].Key().String() < olds[o].Key().String() {
if news[n].Key().normalize().String() < olds[o].Key().normalize().String() {
adds = append(adds, news[n])
n++
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,26 @@ func DiffList(liveManifests, desiredManifests []Manifest, logger *zap.Logger, op
func groupManifests(olds, news []Manifest) (adds, deletes, newChanges, oldChanges []Manifest) {
// Sort the manifests before comparing.
sort.Slice(news, func(i, j int) bool {
return news[i].Key().String() < news[j].Key().String()
return news[i].Key().normalize().String() < news[j].Key().normalize().String()
})
sort.Slice(olds, func(i, j int) bool {
return olds[i].Key().String() < olds[j].Key().String()
return olds[i].Key().normalize().String() < olds[j].Key().normalize().String()
})

var n, o int
for {
if n >= len(news) || o >= len(olds) {
break
}
if news[n].Key().String() == olds[o].Key().String() {
if news[n].Key().normalize().String() == olds[o].Key().normalize().String() {
newChanges = append(newChanges, news[n])
oldChanges = append(oldChanges, olds[o])
n++
o++
continue
}
// Has in news but not in olds so this should be a added one.
if news[n].Key().String() < olds[o].Key().String() {
if news[n].Key().normalize().String() < olds[o].Key().normalize().String() {
adds = append(adds, news[n])
n++
continue
Expand Down