Move patches fix to before Write step.

This commit is contained in:
Eyob Tefera
2020-08-12 18:14:03 +00:00
parent 4da40461d3
commit 1bc9225302
3 changed files with 12 additions and 12 deletions

View File

@@ -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 {