From bc5859d44bb432eaec3c15953224b3b1413af74f Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Sat, 1 Aug 2020 08:55:00 +0000 Subject: [PATCH 01/10] Replace patchesJson6902 field with patches. --- api/types/fix.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/types/fix.go b/api/types/fix.go index 71548bea56..ed386a1338 100644 --- a/api/types/fix.go +++ b/api/types/fix.go @@ -9,14 +9,15 @@ import ( "sigs.k8s.io/yaml" ) -// FixKustomizationPreUnmarshalling modies the raw data +// FixKustomizationPreUnmarshalling modifies the raw data // before marshalling - e.g. changes old field names to // new field names. func FixKustomizationPreUnmarshalling(data []byte) ([]byte, error) { - deprecateFieldsMap := map[string]string{ - "imageTags:": "images:", + deprecatedFieldsMap := map[string]string{ + "imageTags:": "images:", + "patchesJson6902": "patches", } - for oldname, newname := range deprecateFieldsMap { + for oldname, newname := range deprecatedFieldsMap { pattern := regexp.MustCompile(oldname) data = pattern.ReplaceAll(data, []byte(newname)) } From 9b8232533f656ccf92b561adae75c9d022ecc6c2 Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Sat, 1 Aug 2020 08:55:18 +0000 Subject: [PATCH 02/10] Add test. --- .../kustfile/kustomizationfile_test.go | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/kustomize/internal/commands/kustfile/kustomizationfile_test.go b/kustomize/internal/commands/kustfile/kustomizationfile_test.go index 2f9e9e69b2..5fc29770d8 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile_test.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile_test.go @@ -342,6 +342,51 @@ kind: Kustomization } } +func TestFixOutdatedPatchesFieldTitle(t *testing.T) { + kustomizationContentWithOutdatedPatchesFieldTitle := []byte(` +patchesJson6902: +- path: patch1.yaml + target: + kind: Deployment +- path: patch2.yaml + target: + kind: Service +`) + + expected := []byte(` +patches: +- path: patch1.yaml + target: + kind: Deployment +- path: patch2.yaml + target: + kind: Service +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +`) + fSys := filesys.MakeFsInMemory() + testutils_test.WriteTestKustomizationWith(fSys, kustomizationContentWithOutdatedPatchesFieldTitle) + mf, err := NewKustomizationFile(fSys) + if err != nil { + t.Fatalf("Unexpected Error: %v", err) + } + + kustomization, err := mf.Read() + if err != nil { + t.Fatalf("Unexpected Error: %v", err) + } + if err = mf.Write(kustomization); err != nil { + t.Fatalf("Unexpected Error: %v", err) + } + bytes, _ := fSys.ReadFile(mf.path) + + if string(expected) != string(bytes) { + t.Fatalf( + "expected =\n%s\n\nactual =\n%s\n", + string(expected), string(bytes)) + } +} + func TestUnknownFieldInKustomization(t *testing.T) { kContent := []byte(` foo: From efd5f414a8c43dc42234a462af63eb3cf5506a56 Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Sat, 1 Aug 2020 18:44:30 +0000 Subject: [PATCH 03/10] Remove unused field from field order list. --- kustomize/internal/commands/kustfile/kustomizationfile.go | 1 - kustomize/internal/commands/kustfile/kustomizationfile_test.go | 1 - 2 files changed, 2 deletions(-) diff --git a/kustomize/internal/commands/kustfile/kustomizationfile.go b/kustomize/internal/commands/kustfile/kustomizationfile.go index f347e368a0..b7b34f99e7 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile.go @@ -47,7 +47,6 @@ func determineFieldOrder() []string { "CommonLabels", "CommonAnnotations", "PatchesStrategicMerge", - "PatchesJson6902", "Patches", "ConfigMapGenerator", "SecretGenerator", diff --git a/kustomize/internal/commands/kustfile/kustomizationfile_test.go b/kustomize/internal/commands/kustfile/kustomizationfile_test.go index 5fc29770d8..c5135b8076 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile_test.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile_test.go @@ -27,7 +27,6 @@ func TestFieldOrder(t *testing.T) { "CommonLabels", "CommonAnnotations", "PatchesStrategicMerge", - "PatchesJson6902", "Patches", "ConfigMapGenerator", "SecretGenerator", From 43b0f2d925cff9c195a29b269bd8899ea47e94bd Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Sat, 1 Aug 2020 18:45:44 +0000 Subject: [PATCH 04/10] Remove unused utility function StringInSplice. --- .../internal/commands/kustfile/kustomizationfile.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/kustomize/internal/commands/kustfile/kustomizationfile.go b/kustomize/internal/commands/kustfile/kustomizationfile.go index b7b34f99e7..2e98f126c6 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile.go @@ -176,16 +176,6 @@ func (mf *kustomizationFile) Write(kustomization *types.Kustomization) error { return mf.fSys.WriteFile(mf.path, data) } -// StringInSlice returns true if the string is in the slice. -func StringInSlice(str string, list []string) bool { - for _, v := range list { - if v == str { - return true - } - } - return false -} - func (mf *kustomizationFile) parseCommentedFields(content []byte) error { buffer := bytes.NewBuffer(content) var comments [][]byte From b3f147d0123d6c05fa8daaa0032e5d5e2ac3af7c Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Wed, 5 Aug 2020 22:03:12 +0000 Subject: [PATCH 05/10] Add group and verison to fix test. --- .../commands/kustfile/kustomizationfile_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kustomize/internal/commands/kustfile/kustomizationfile_test.go b/kustomize/internal/commands/kustfile/kustomizationfile_test.go index c5135b8076..1a996df833 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile_test.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile_test.go @@ -346,20 +346,24 @@ func TestFixOutdatedPatchesFieldTitle(t *testing.T) { patchesJson6902: - path: patch1.yaml target: - kind: Deployment + kind: Service - path: patch2.yaml target: - kind: Service + group: apps + kind: Deployment + version: v1 `) expected := []byte(` patches: - path: patch1.yaml target: - kind: Deployment + kind: Service - path: patch2.yaml target: - kind: Service + group: apps + kind: Deployment + version: v1 apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization `) From bd7d0f864bf0983f7878332e7c354e7a946359bc Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Sun, 9 Aug 2020 07:30:40 +0000 Subject: [PATCH 06/10] Revert "Remove unused utility function StringInSplice." This reverts commit 43b0f2d925cff9c195a29b269bd8899ea47e94bd. --- .../internal/commands/kustfile/kustomizationfile.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kustomize/internal/commands/kustfile/kustomizationfile.go b/kustomize/internal/commands/kustfile/kustomizationfile.go index 2e98f126c6..b7b34f99e7 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile.go @@ -176,6 +176,16 @@ func (mf *kustomizationFile) Write(kustomization *types.Kustomization) error { return mf.fSys.WriteFile(mf.path, data) } +// StringInSlice returns true if the string is in the slice. +func StringInSlice(str string, list []string) bool { + for _, v := range list { + if v == str { + return true + } + } + return false +} + func (mf *kustomizationFile) parseCommentedFields(content []byte) error { buffer := bytes.NewBuffer(content) var comments [][]byte From eee581462ce6b3f6666d38976a09d2aa18736eb8 Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Mon, 10 Aug 2020 17:53:30 +0000 Subject: [PATCH 07/10] Undo wholesale replacement of PatchesJson6902. --- api/types/fix.go | 3 +-- kustomize/internal/commands/kustfile/kustomizationfile.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/types/fix.go b/api/types/fix.go index ed386a1338..de70467ed9 100644 --- a/api/types/fix.go +++ b/api/types/fix.go @@ -14,8 +14,7 @@ import ( // new field names. func FixKustomizationPreUnmarshalling(data []byte) ([]byte, error) { deprecatedFieldsMap := map[string]string{ - "imageTags:": "images:", - "patchesJson6902": "patches", + "imageTags:": "images:", } for oldname, newname := range deprecatedFieldsMap { pattern := regexp.MustCompile(oldname) diff --git a/kustomize/internal/commands/kustfile/kustomizationfile.go b/kustomize/internal/commands/kustfile/kustomizationfile.go index b7b34f99e7..f347e368a0 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile.go @@ -47,6 +47,7 @@ func determineFieldOrder() []string { "CommonLabels", "CommonAnnotations", "PatchesStrategicMerge", + "PatchesJson6902", "Patches", "ConfigMapGenerator", "SecretGenerator", From 2f3c89e73fa436b0acb9e067d494c50f0371b83f Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Mon, 10 Aug 2020 17:57:03 +0000 Subject: [PATCH 08/10] Add diffing to tests. --- kustomize/go.mod | 1 + kustomize/go.sum | 2 + .../kustfile/kustomizationfile_test.go | 85 ++++++++++++++----- 3 files changed, 68 insertions(+), 20 deletions(-) diff --git a/kustomize/go.mod b/kustomize/go.mod index b1e2d19a2e..9b13ebbe8a 100644 --- a/kustomize/go.mod +++ b/kustomize/go.mod @@ -3,6 +3,7 @@ module sigs.k8s.io/kustomize/kustomize/v3 go 1.14 require ( + github.com/google/go-cmp v0.3.0 github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.0.0 github.com/spf13/pflag v1.0.5 diff --git a/kustomize/go.sum b/kustomize/go.sum index 474c958053..5f83ee0de8 100644 --- a/kustomize/go.sum +++ b/kustomize/go.sum @@ -239,6 +239,7 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -756,6 +757,7 @@ sigs.k8s.io/kustomize/kyaml v0.1.4/go.mod h1:461i94nj0h0ylJ6w83jLkR4SqqVhn1iY6fj sigs.k8s.io/kustomize/kyaml v0.2.0/go.mod h1:72/rLkSi+L/pHM1oCjwrf3ClU+tH5kZQvvdLSqIHwWU= sigs.k8s.io/kustomize/kyaml v0.4.1 h1:NEqA/35upoAjb+I5vh1ODUqxoX4DOrezeQa9BhhG5Co= sigs.k8s.io/kustomize/kyaml v0.4.1/go.mod h1:XJL84E6sOFeNrQ7CADiemc1B0EjIxHo3OhW4o1aJYNw= +sigs.k8s.io/kustomize/kyaml v0.4.2/go.mod h1:XJL84E6sOFeNrQ7CADiemc1B0EjIxHo3OhW4o1aJYNw= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18= diff --git a/kustomize/internal/commands/kustfile/kustomizationfile_test.go b/kustomize/internal/commands/kustfile/kustomizationfile_test.go index 1a996df833..97bcc76550 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile_test.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile_test.go @@ -8,6 +8,8 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" + "sigs.k8s.io/kustomize/api/filesys" "sigs.k8s.io/kustomize/api/konfig" "sigs.k8s.io/kustomize/api/types" @@ -27,6 +29,7 @@ func TestFieldOrder(t *testing.T) { "CommonLabels", "CommonAnnotations", "PatchesStrategicMerge", + "PatchesJson6902", "Patches", "ConfigMapGenerator", "SecretGenerator", @@ -157,8 +160,8 @@ patchesStrategicMerge: } bytes, _ := fSys.ReadFile(mf.path) - if !reflect.DeepEqual(kustomizationContentWithComments, bytes) { - t.Fatal("written kustomization with comments is not the same as original one") + if diff := cmp.Diff(kustomizationContentWithComments, bytes); diff != "" { + t.Errorf("Mismatch (-expected, +actual):\n%s", diff) } } @@ -251,10 +254,8 @@ generatorOptions: } bytes, _ := fSys.ReadFile(mf.path) - if string(expected) != string(bytes) { - t.Fatalf( - "expected =\n%s\n\nactual =\n%s\n", - string(expected), string(bytes)) + if diff := cmp.Diff(expected, bytes); diff != "" { + t.Errorf("Mismatch (-expected, +actual):\n%s", diff) } } @@ -289,10 +290,8 @@ kind: Kustomization } bytes, _ := fSys.ReadFile(mf.path) - if string(expected) != string(bytes) { - t.Fatalf( - "expected =\n%s\n\nactual =\n%s\n", - string(expected), string(bytes)) + if diff := cmp.Diff(expected, bytes); diff != "" { + t.Errorf("Mismatch (-expected, +actual):\n%s", diff) } } @@ -334,10 +333,58 @@ kind: Kustomization } bytes, _ := fSys.ReadFile(mf.path) - if string(expected) != string(bytes) { - t.Fatalf( - "expected =\n%s\n\nactual =\n%s\n", - string(expected), string(bytes)) + if diff := cmp.Diff(expected, bytes); diff != "" { + t.Errorf("Mismatch (-expected, +actual):\n%s", diff) + } +} + +func TestRenameAndKeepOutdatedPatchesField(t *testing.T) { + kustomizationContentWithOutdatedPatchesFieldTitle := []byte(` +patchesJson6902: +- path: patch1.yaml + target: + kind: Deployment +patches: +- path: patch2.yaml + target: + kind: Deployment +- path: patch3.yaml + target: + kind: Service +`) + + expected := []byte(` +patches: +- path: patch2.yaml + target: + kind: Deployment +- path: patch3.yaml + target: + kind: Service +- path: patch1.yaml + target: + kind: Deployment +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +`) + fSys := filesys.MakeFsInMemory() + testutils_test.WriteTestKustomizationWith(fSys, kustomizationContentWithOutdatedPatchesFieldTitle) + mf, err := NewKustomizationFile(fSys) + if err != nil { + t.Fatalf("Unexpected Error: %v", err) + } + + kustomization, err := mf.Read() + if err != nil { + t.Fatalf("Unexpected Error: %v", err) + } + if err = mf.Write(kustomization); err != nil { + t.Fatalf("Unexpected Error: %v", err) + } + bytes, _ := fSys.ReadFile(mf.path) + + if diff := cmp.Diff(expected, bytes); diff != "" { + t.Errorf("Mismatch (-expected, +actual):\n%s", diff) } } @@ -355,6 +402,8 @@ patchesJson6902: `) expected := []byte(` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization patches: - path: patch1.yaml target: @@ -364,8 +413,6 @@ patches: group: apps kind: Deployment version: v1 -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization `) fSys := filesys.MakeFsInMemory() testutils_test.WriteTestKustomizationWith(fSys, kustomizationContentWithOutdatedPatchesFieldTitle) @@ -383,10 +430,8 @@ kind: Kustomization } bytes, _ := fSys.ReadFile(mf.path) - if string(expected) != string(bytes) { - t.Fatalf( - "expected =\n%s\n\nactual =\n%s\n", - string(expected), string(bytes)) + if diff := cmp.Diff(expected, bytes); diff != "" { + t.Errorf("Mismatch (-expected, +actual):\n%s", diff) } } From 45893b258899b5adaada80a29e59770afcdf3143 Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Mon, 10 Aug 2020 17:57:39 +0000 Subject: [PATCH 09/10] Iteratively convert PatchesJson6902 to Patches. --- api/types/kustomization.go | 6 ++++++ api/types/patchjson6902.go | 6 ++++++ api/types/patchtarget.go | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/api/types/kustomization.go b/api/types/kustomization.go index 8cc7299b71..464efe878b 100644 --- a/api/types/kustomization.go +++ b/api/types/kustomization.go @@ -144,6 +144,12 @@ type Kustomization struct { // moving content of deprecated fields to newer // fields. func (k *Kustomization) FixKustomizationPostUnmarshalling() { + // PatchesJson6902 should be under the Patches field. + for _, patch := range k.PatchesJson6902 { + k.Patches = append(k.Patches, patch.ToPatch()) + } + k.PatchesJson6902 = nil + if k.Kind == "" { k.Kind = KustomizationKind } diff --git a/api/types/patchjson6902.go b/api/types/patchjson6902.go index 1a189aa6d9..4c90ce2017 100644 --- a/api/types/patchjson6902.go +++ b/api/types/patchjson6902.go @@ -19,3 +19,9 @@ type PatchJson6902 struct { // inline patch string Patch string `json:"patch,omitempty" yaml:"patch,omitempty"` } + +// ToPatch converts a PatchJson6902 to its superset Patch. +func (patch *PatchJson6902) ToPatch() Patch { + selector := patch.Target.ToSelector() + return Patch{Path: patch.Path, Patch: patch.Patch, Target: &selector} +} diff --git a/api/types/patchtarget.go b/api/types/patchtarget.go index ee8c6a691a..85f8045747 100644 --- a/api/types/patchtarget.go +++ b/api/types/patchtarget.go @@ -13,3 +13,8 @@ type PatchTarget struct { Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` Name string `json:"name" yaml:"name"` } + +// ToSelector converts a PatchTarget to a Selector. +func (target *PatchTarget) ToSelector() Selector { + return Selector{Name: target.Name, Namespace: target.Namespace, Gvk: target.Gvk} +} From 1bc9225302e7b2042b3eadd91ac35f19918e20c4 Mon Sep 17 00:00:00 2001 From: Eyob Tefera Date: Wed, 12 Aug 2020 18:14:03 +0000 Subject: [PATCH 10/10] Move patches fix to before Write step. --- api/types/kustomization.go | 16 +++++++++++----- kustomize/go.sum | 7 ------- .../commands/kustfile/kustomizationfile.go | 1 + 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api/types/kustomization.go b/api/types/kustomization.go index 464efe878b..c32832b2c5 100644 --- a/api/types/kustomization.go +++ b/api/types/kustomization.go @@ -144,11 +144,6 @@ type Kustomization struct { // moving content of deprecated fields to newer // fields. func (k *Kustomization) FixKustomizationPostUnmarshalling() { - // PatchesJson6902 should be under the Patches field. - for _, patch := range k.PatchesJson6902 { - k.Patches = append(k.Patches, patch.ToPatch()) - } - k.PatchesJson6902 = nil if k.Kind == "" { k.Kind = KustomizationKind @@ -164,6 +159,17 @@ func (k *Kustomization) FixKustomizationPostUnmarshalling() { k.Bases = nil } +// FixKustomizationPreMarshalling fixes things +// that should occur after the kustomization file +// has been processed. +func (k *Kustomization) FixKustomizationPreMarshalling() { + // PatchesJson6902 should be under the Patches field. + for _, patch := range k.PatchesJson6902 { + k.Patches = append(k.Patches, patch.ToPatch()) + } + k.PatchesJson6902 = nil +} + func (k *Kustomization) EnforceFields() []string { var errs []string if k.Kind != "" && k.Kind != KustomizationKind && k.Kind != ComponentKind { diff --git a/kustomize/go.sum b/kustomize/go.sum index 9588ccf7b2..ededde4dd0 100644 --- a/kustomize/go.sum +++ b/kustomize/go.sum @@ -750,14 +750,7 @@ sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9 sigs.k8s.io/controller-runtime v0.4.0/go.mod h1:ApC79lpY3PHW9xj/w9pj+lYkLgwAAUZwfXkME1Lajns= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= -sigs.k8s.io/kustomize/cmd/config v0.2.0 h1:VNAWKb1JLl7dFjMAD5MwdZpGjreN3qL63C8DKtsUYck= -sigs.k8s.io/kustomize/cmd/config v0.2.0/go.mod h1:oXzY7QJS6JlmWgusEjra2O3cW7GSIICXa59/3DvjBfE= -sigs.k8s.io/kustomize/kyaml v0.1.4/go.mod h1:461i94nj0h0ylJ6w83jLkR4SqqVhn1iY6fjD0JSTQeE= -sigs.k8s.io/kustomize/kyaml v0.2.0/go.mod h1:72/rLkSi+L/pHM1oCjwrf3ClU+tH5kZQvvdLSqIHwWU= sigs.k8s.io/kustomize/kyaml v0.4.0/go.mod h1:XJL84E6sOFeNrQ7CADiemc1B0EjIxHo3OhW4o1aJYNw= -sigs.k8s.io/kustomize/kyaml v0.4.1 h1:NEqA/35upoAjb+I5vh1ODUqxoX4DOrezeQa9BhhG5Co= -sigs.k8s.io/kustomize/kyaml v0.4.1/go.mod h1:XJL84E6sOFeNrQ7CADiemc1B0EjIxHo3OhW4o1aJYNw= -sigs.k8s.io/kustomize/kyaml v0.4.2/go.mod h1:XJL84E6sOFeNrQ7CADiemc1B0EjIxHo3OhW4o1aJYNw= sigs.k8s.io/kustomize/kyaml v0.5.0 h1:xufpSxgpugQxtd0aN1ZsWnr3Kj0fpAi7GN4dnEs4oPg= sigs.k8s.io/kustomize/kyaml v0.5.0/go.mod h1:bEzbO5pN9OvlEeCLvFHo8Pu7SA26Herc2m60UeWZBdI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= diff --git a/kustomize/internal/commands/kustfile/kustomizationfile.go b/kustomize/internal/commands/kustfile/kustomizationfile.go index f347e368a0..900d748e28 100644 --- a/kustomize/internal/commands/kustfile/kustomizationfile.go +++ b/kustomize/internal/commands/kustfile/kustomizationfile.go @@ -170,6 +170,7 @@ func (mf *kustomizationFile) Write(kustomization *types.Kustomization) error { if kustomization == nil { return errors.New("util: kustomization file arg is nil") } + kustomization.FixKustomizationPreMarshalling() data, err := mf.marshal(kustomization) if err != nil { return err