Confine calls to ApplyToJSON.

This commit is contained in:
monopole
2021-01-07 18:34:05 -08:00
parent 8c6a9f6495
commit 614e853db3
31 changed files with 59 additions and 81 deletions

View File

@@ -13,6 +13,7 @@ import (
"sigs.k8s.io/kustomize/api/resid"
"sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kyaml/filtersutil"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/yaml"
)
@@ -422,9 +423,9 @@ func (r *Resource) ApplySmPatch(patch *Resource) error {
return err
}
n, ns := r.GetName(), r.GetNamespace()
err = filtersutil.ApplyToJSON(patchstrategicmerge.Filter{
r.ApplyFilter(patchstrategicmerge.Filter{
Patch: node,
}, r)
})
if !r.IsEmpty() {
r.SetName(n)
r.SetNamespace(ns)
@@ -432,6 +433,10 @@ func (r *Resource) ApplySmPatch(patch *Resource) error {
return err
}
func (r *Resource) ApplyFilter(f kio.Filter) error {
return filtersutil.ApplyToJSON(f, r)
}
func mergeStringMaps(maps ...map[string]string) map[string]string {
result := map[string]string{}
for _, m := range maps {