mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 10:00:56 +00:00
Deal with field deprecation immediately after load.
This commit is contained in:
@@ -32,7 +32,6 @@ import (
|
|||||||
"sigs.k8s.io/kustomize/pkg/fs"
|
"sigs.k8s.io/kustomize/pkg/fs"
|
||||||
interror "sigs.k8s.io/kustomize/pkg/internal/error"
|
interror "sigs.k8s.io/kustomize/pkg/internal/error"
|
||||||
"sigs.k8s.io/kustomize/pkg/loader"
|
"sigs.k8s.io/kustomize/pkg/loader"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
patchtransformer "sigs.k8s.io/kustomize/pkg/patch/transformer"
|
patchtransformer "sigs.k8s.io/kustomize/pkg/patch/transformer"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
"sigs.k8s.io/kustomize/pkg/resource"
|
"sigs.k8s.io/kustomize/pkg/resource"
|
||||||
@@ -60,13 +59,14 @@ func NewKustTarget(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var m types.Kustomization
|
var k types.Kustomization
|
||||||
err = unmarshal(content, &m)
|
err = unmarshal(content, &k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
k.DealWithDeprecatedFields()
|
||||||
return &KustTarget{
|
return &KustTarget{
|
||||||
kustomization: &m,
|
kustomization: &k,
|
||||||
ldr: ldr,
|
ldr: ldr,
|
||||||
fSys: fSys,
|
fSys: fSys,
|
||||||
tcfg: tcfg,
|
tcfg: tcfg,
|
||||||
@@ -157,9 +157,6 @@ func (kt *KustTarget) loadCustomizedResMap() (resmap.ResMap, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
kt.kustomization.PatchesStrategicMerge = patch.Append(
|
|
||||||
kt.kustomization.PatchesStrategicMerge,
|
|
||||||
kt.kustomization.Patches...)
|
|
||||||
patches, err := resource.NewResourceSliceFromPatches(
|
patches, err := resource.NewResourceSliceFromPatches(
|
||||||
kt.ldr, kt.kustomization.PatchesStrategicMerge, kt.decoder)
|
kt.ldr, kt.kustomization.PatchesStrategicMerge, kt.decoder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -91,6 +91,18 @@ type Kustomization struct {
|
|||||||
ImageTags []ImageTag `json:"imageTags,omitempty" yaml:"imageTags,omitempty"`
|
ImageTags []ImageTag `json:"imageTags,omitempty" yaml:"imageTags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DealWithDeprecatedFields should be called immediately after
|
||||||
|
// loading from storage.
|
||||||
|
func (k *Kustomization) DealWithDeprecatedFields() {
|
||||||
|
// The Patches field, meant to hold StrategicMerge patches,
|
||||||
|
// is deprecated. Append anything found there to the
|
||||||
|
// PatchesStrategicMerge field.
|
||||||
|
// This happened when the PatchesJson6902 field was introduced.
|
||||||
|
k.PatchesStrategicMerge = patch.Append(
|
||||||
|
k.PatchesStrategicMerge, k.Patches...)
|
||||||
|
k.Patches = []string{}
|
||||||
|
}
|
||||||
|
|
||||||
// ConfigMapArgs contains the metadata of how to generate a configmap.
|
// ConfigMapArgs contains the metadata of how to generate a configmap.
|
||||||
type ConfigMapArgs struct {
|
type ConfigMapArgs struct {
|
||||||
// Name of the configmap.
|
// Name of the configmap.
|
||||||
|
|||||||
Reference in New Issue
Block a user