mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-09-15 12:18:57 +00:00
Iteratively convert PatchesJson6902 to Patches.
This commit is contained in:
@@ -144,6 +144,12 @@ type Kustomization struct {
|
|||||||
// moving content of deprecated fields to newer
|
// moving content of deprecated fields to newer
|
||||||
// fields.
|
// fields.
|
||||||
func (k *Kustomization) FixKustomizationPostUnmarshalling() {
|
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 == "" {
|
if k.Kind == "" {
|
||||||
k.Kind = KustomizationKind
|
k.Kind = KustomizationKind
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,3 +19,9 @@ type PatchJson6902 struct {
|
|||||||
// inline patch string
|
// inline patch string
|
||||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
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}
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,3 +13,8 @@ type PatchTarget struct {
|
|||||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||||
Name string `json:"name" yaml:"name"`
|
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}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user