mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Merge pull request #3644 from natasha41575/AllowGeneralNameChanges
allow general name and kind changes via an options field in patches
This commit is contained in:
@@ -22,6 +22,7 @@ type plugin struct {
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
}
|
||||
|
||||
//noinspection GoUnusedGlobalVariable
|
||||
@@ -64,6 +65,12 @@ func (p *plugin) Config(
|
||||
}
|
||||
if errSM == nil {
|
||||
p.loadedPatch = patchSM
|
||||
if p.Options["allowNameChange"] {
|
||||
p.loadedPatch.SetAllowNameChange("true")
|
||||
}
|
||||
if p.Options["allowKindChange"] {
|
||||
p.loadedPatch.SetAllowKindChange("true")
|
||||
}
|
||||
} else {
|
||||
p.decodedPatch = patchJson
|
||||
}
|
||||
|
||||
@@ -296,7 +296,6 @@ spec:
|
||||
- proxy
|
||||
- sidecar
|
||||
`)
|
||||
|
||||
rm := th.LoadAndRunTransformer(`
|
||||
apiVersion: builtin
|
||||
kind: PatchTransformer
|
||||
@@ -364,6 +363,8 @@ spec:
|
||||
- sidecar
|
||||
image: docker.io/istio/proxyv2
|
||||
name: istio-proxy
|
||||
- image: nginx
|
||||
name: nginx
|
||||
`)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/prefixes: baked-
|
||||
config.kubernetes.io/previousKinds: Service
|
||||
config.kubernetes.io/previousNames: apple
|
||||
config.kubernetes.io/previousNamespaces: default
|
||||
config.kubernetes.io/suffixes: -pie
|
||||
@@ -87,6 +88,7 @@ kind: ConfigMap
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/prefixes: baked-
|
||||
config.kubernetes.io/previousKinds: ConfigMap
|
||||
config.kubernetes.io/previousNames: cm
|
||||
config.kubernetes.io/previousNamespaces: default
|
||||
config.kubernetes.io/suffixes: -pie
|
||||
@@ -138,6 +140,7 @@ kind: Deployment
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/prefixes: test-
|
||||
config.kubernetes.io/previousKinds: Deployment
|
||||
config.kubernetes.io/previousNames: deployment
|
||||
config.kubernetes.io/previousNamespaces: default
|
||||
name: test-deployment
|
||||
|
||||
Reference in New Issue
Block a user