...
1
2
3
4 package krusty_test
5
6 import (
7 "testing"
8
9 kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
10 )
11
12 func writeIssueBase(th kusttest_test.Harness) {
13 th.WriteK("base", `
14 nameSuffix: -test-api
15
16 resources:
17 - deploy.yaml
18 `)
19 th.WriteF("base/deploy.yaml", `
20 apiVersion: apps/v1
21 kind: Deployment
22 metadata:
23 name: example
24 spec:
25 template:
26 spec:
27 containers:
28 - name: example
29 image: example:1.0
30 volumeMounts:
31 - name: conf
32 mountPath: /etc/config
33 volumes:
34 - name: conf
35 configMap:
36 name: conf
37 `)
38 }
39
40 func TestIssue2896Base(t *testing.T) {
41 th := kusttest_test.MakeHarness(t)
42 writeIssueBase(th)
43 m := th.Run("base", th.MakeDefaultOptions())
44 th.AssertActualEqualsExpected(m, `
45 apiVersion: apps/v1
46 kind: Deployment
47 metadata:
48 name: example-test-api
49 spec:
50 template:
51 spec:
52 containers:
53 - image: example:1.0
54 name: example
55 volumeMounts:
56 - mountPath: /etc/config
57 name: conf
58 volumes:
59 - configMap:
60 name: conf
61 name: conf
62 `)
63 }
64
65 func TestIssue2896Overlay(t *testing.T) {
66 th := kusttest_test.MakeHarness(t)
67 writeIssueBase(th)
68 th.WriteK("overlay", `
69 resources:
70 - ../base
71
72 patches:
73 - patch: |-
74 apiVersion: apps/v1
75 kind: Deployment
76 metadata:
77 name: example
78 spec:
79 template:
80 spec:
81 containers:
82 - name: example
83 image: example:2.0
84 `)
85
86 m := th.Run("overlay", th.MakeDefaultOptions())
87 th.AssertActualEqualsExpected(m, `
88 apiVersion: apps/v1
89 kind: Deployment
90 metadata:
91 name: example-test-api
92 spec:
93 template:
94 spec:
95 containers:
96 - image: example:2.0
97 name: example
98 volumeMounts:
99 - mountPath: /etc/config
100 name: conf
101 volumes:
102 - configMap:
103 name: conf
104 name: conf
105 `)
106 }
107
View as plain text