mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
prevent all uses of YAML aliases from being overwritten by a transformer (#5096)
* return copied Node * add a test case about imageTagTransformer for anchor scenario * add TestPatchTransformerAnchor * TestReplacementTransformerAnchor
This commit is contained in:
@@ -828,3 +828,65 @@ spec:
|
||||
protocol: TCP
|
||||
`)
|
||||
}
|
||||
|
||||
func TestPatchTransformerAnchor(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t).
|
||||
PrepBuiltin("PatchTransformer")
|
||||
defer th.Reset()
|
||||
|
||||
th.RunTransformerAndCheckResult(`
|
||||
apiVersion: builtin
|
||||
kind: PatchTransformer
|
||||
metadata:
|
||||
name: test-transformer
|
||||
patch: |-
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: test-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: &name test-label
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: *name
|
||||
target:
|
||||
kind: Deployment
|
||||
name: test-deployment
|
||||
`, `apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: &name test-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: *name
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: *name
|
||||
spec:
|
||||
containers:
|
||||
- image: test-image
|
||||
name: *name
|
||||
`, `
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: test-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: test-label
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: test-label
|
||||
spec:
|
||||
containers:
|
||||
- image: test-image
|
||||
name: test-deployment
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user