mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Remove delegation to RNode in Resource.
This commit is contained in:
@@ -303,16 +303,18 @@ func (kt *KustTarget) runValidators(ra *accumulator.ResAccumulator) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
new := ra.ResMap().DeepCopy()
|
||||
kt.removeValidatedByLabel(new)
|
||||
if err = orignal.ErrorIfNotEqualSets(new); err != nil {
|
||||
newMap := ra.ResMap().DeepCopy()
|
||||
if err = kt.removeValidatedByLabel(newMap); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = orignal.ErrorIfNotEqualSets(newMap); err != nil {
|
||||
return fmt.Errorf("validator shouldn't modify the resource map: %v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (kt *KustTarget) removeValidatedByLabel(rm resmap.ResMap) {
|
||||
func (kt *KustTarget) removeValidatedByLabel(rm resmap.ResMap) error {
|
||||
resources := rm.Resources()
|
||||
for _, r := range resources {
|
||||
labels := r.GetLabels()
|
||||
@@ -320,12 +322,11 @@ func (kt *KustTarget) removeValidatedByLabel(rm resmap.ResMap) {
|
||||
continue
|
||||
}
|
||||
delete(labels, konfig.ValidatedByLabelKey)
|
||||
if len(labels) == 0 {
|
||||
r.SetLabels(nil)
|
||||
} else {
|
||||
r.SetLabels(labels)
|
||||
if err := r.SetLabels(labels); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// accumulateResources fills the given resourceAccumulator
|
||||
|
||||
Reference in New Issue
Block a user