Merge pull request #3644 from natasha41575/AllowGeneralNameChanges

allow general name and kind changes via an options field in patches
This commit is contained in:
Jeff Regan
2021-03-15 15:49:04 -07:00
committed by GitHub
17 changed files with 285 additions and 146 deletions

View File

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

View File

@@ -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
`)
}

View File

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