mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 18:10:59 +00:00
Sort the string slice fields of a document to avoid updating the index
unnecessarily
This commit is contained in:
@@ -2,6 +2,7 @@ package doc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/k8sdeps/kunstruct"
|
||||
@@ -161,6 +162,13 @@ func (doc *KustomizationDocument) ParseYAML() error {
|
||||
doc.Identifiers = append(doc.Identifiers, key)
|
||||
}
|
||||
|
||||
// Without sorting these fields, every time when the string order in these fields changes,
|
||||
// the document in the index will be updated.
|
||||
// Sorting these fields are necessary to avoid a document being updated unnecessarily.
|
||||
sort.Strings(doc.Kinds)
|
||||
sort.Strings(doc.Values)
|
||||
sort.Strings(doc.Identifiers)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user