mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 09:51:23 +00:00
update checker code in patchStrategicMerge
This commit is contained in:
@@ -7,8 +7,8 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/kyaml/filesys"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
@@ -218,7 +218,7 @@ func (k *Kustomization) FixKustomizationPostUnmarshalling() {
|
||||
// FixKustomizationPreMarshalling fixes things
|
||||
// that should occur after the kustomization file
|
||||
// has been processed.
|
||||
func (k *Kustomization) FixKustomizationPreMarshalling() error {
|
||||
func (k *Kustomization) FixKustomizationPreMarshalling(fSys filesys.FileSystem) error {
|
||||
// PatchesJson6902 should be under the Patches field.
|
||||
k.Patches = append(k.Patches, k.PatchesJson6902...)
|
||||
k.PatchesJson6902 = nil
|
||||
@@ -226,8 +226,7 @@ func (k *Kustomization) FixKustomizationPreMarshalling() error {
|
||||
if k.PatchesStrategicMerge != nil {
|
||||
for _, patchStrategicMerge := range k.PatchesStrategicMerge {
|
||||
// check this patch is file path select.
|
||||
if strings.Count(string(patchStrategicMerge), "\n") < 1 &&
|
||||
(patchStrategicMerge[len(patchStrategicMerge)-5:] == ".yaml" || patchStrategicMerge[len(patchStrategicMerge)-4:] == ".yml") {
|
||||
if _, err := fSys.ReadFile(string(patchStrategicMerge)); err == nil {
|
||||
// path patch
|
||||
k.Patches = append(k.Patches, Patch{Path: string(patchStrategicMerge)})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user