mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-17 01:39:06 +00:00
Updates in image transformer (#911)
- Decouple `mutateImage` from `updateContainers` to be reused as `mutateFunc` - Ignore default image transform error for CRD which may contain non-array type `containers` field Related to #890, #904, fixes #890
This commit is contained in:
committed by
Jingfang Liu
parent
21a0cba43e
commit
2490e605c3
@@ -233,11 +233,11 @@ spec3:
|
||||
th.writeF("/app/base/config/custom.yaml", `
|
||||
images:
|
||||
- kind: Custom
|
||||
path: spec/template/spec/myContainers
|
||||
path: spec/template/spec/myContainers/image
|
||||
- kind: Custom
|
||||
path: spec2/template/spec/myContainers
|
||||
path: spec2/template/spec/myContainers/image
|
||||
- kind: Custom
|
||||
path: spec3/template/spec/myInitContainers
|
||||
path: spec3/template/spec/myInitContainers/image
|
||||
`)
|
||||
}
|
||||
func TestTransfomersImageCustomConfig(t *testing.T) {
|
||||
@@ -283,3 +283,56 @@ spec3:
|
||||
name: my-cool-app
|
||||
`)
|
||||
}
|
||||
|
||||
func makeTransfomersImageKnativeBase(th *KustTestHarness) {
|
||||
th.writeK("/app/base", `
|
||||
resources:
|
||||
- knative.yaml
|
||||
configurations:
|
||||
- config/knative.yaml
|
||||
images:
|
||||
- name: solsa-echo
|
||||
newTag: foo
|
||||
`)
|
||||
th.writeF("/app/base/knative.yaml", `
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: echo
|
||||
spec:
|
||||
runLatest:
|
||||
configuration:
|
||||
revisionTemplate:
|
||||
spec:
|
||||
container:
|
||||
image: solsa-echo
|
||||
`)
|
||||
th.writeF("/app/base/config/knative.yaml", `
|
||||
images:
|
||||
- path: spec/runLatest/configuration/revisionTemplate/spec/container/image
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
`)
|
||||
}
|
||||
|
||||
func TestTransfomersImageKnativeConfig(t *testing.T) {
|
||||
th := NewKustTestHarness(t, "/app/base")
|
||||
makeTransfomersImageKnativeBase(th)
|
||||
m, err := th.makeKustTarget().MakeCustomizedResMap()
|
||||
if err != nil {
|
||||
t.Fatalf("Err: %v", err)
|
||||
}
|
||||
th.assertActualEqualsExpected(m, `
|
||||
apiVersion: serving.knative.dev/v1alpha1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: echo
|
||||
spec:
|
||||
runLatest:
|
||||
configuration:
|
||||
revisionTemplate:
|
||||
spec:
|
||||
container:
|
||||
image: solsa-echo:foo
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user