mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
convert tests to exercise openapi and inference
This commit is contained in:
@@ -6,22 +6,34 @@ package merge2_test
|
|||||||
var elementTestCases = []testCase{
|
var elementTestCases = []testCase{
|
||||||
{description: `merge Element -- keep field in dest`,
|
{description: `merge Element -- keep field in dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
@@ -29,22 +41,34 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add field to dest`,
|
{description: `merge Element -- add field to dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
@@ -52,20 +76,32 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add list, empty in dest`,
|
{description: `merge Element -- add list, empty in dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items: []
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: []
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
@@ -73,19 +109,28 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add list, missing from dest`,
|
{description: `merge Element -- add list, missing from dest`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
@@ -93,26 +138,38 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add Element first`,
|
{description: `merge Element -- add Element first`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: bar
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
@@ -120,26 +177,38 @@ items:
|
|||||||
|
|
||||||
{description: `merge Element -- add Element second`,
|
{description: `merge Element -- add Element second`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
@@ -150,23 +219,32 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `keep list -- list missing from src`,
|
{description: `keep list -- list missing from src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
@@ -177,26 +255,38 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `keep Element -- element missing in src`,
|
{description: `keep Element -- element missing in src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v0
|
image: foo:v0
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
@@ -207,24 +297,36 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `keep element -- empty list in src`,
|
{description: `keep element -- empty list in src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items: {}
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: {}
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
@@ -235,46 +337,62 @@ items:
|
|||||||
//
|
//
|
||||||
{description: `remove Element -- null in src`,
|
{description: `remove Element -- null in src`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items: null
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: null
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
items:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:v1
|
image: foo:v1
|
||||||
- name: bar
|
- name: bar
|
||||||
image: bar:v1
|
image: bar:v1
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test Case
|
// Test Case
|
||||||
//
|
//
|
||||||
{description: `no infer merge keys no merge'`,
|
{description: `infer merge keys merge'`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -282,8 +400,8 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using schema`,
|
{description: `no infer merge keys merge using schema`,
|
||||||
source: `
|
source: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -292,8 +410,8 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -302,8 +420,8 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -312,7 +430,7 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -320,24 +438,27 @@ spec:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
||||||
source: `
|
source: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
dest: `
|
dest: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
- name: foo # hell ow
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
- name: foo
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func TestMerge(t *testing.T) {
|
|||||||
for j := range testCases[i] {
|
for j := range testCases[i] {
|
||||||
tc := testCases[i][j]
|
tc := testCases[i][j]
|
||||||
t.Run(tc.description, func(t *testing.T) {
|
t.Run(tc.description, func(t *testing.T) {
|
||||||
actual, err := MergeStrings(tc.source, tc.dest, !tc.noInfer)
|
actual, err := MergeStrings(tc.source, tc.dest, tc.infer)
|
||||||
if !assert.NoError(t, err, tc.description) {
|
if !assert.NoError(t, err, tc.description) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
@@ -47,5 +47,5 @@ type testCase struct {
|
|||||||
source string
|
source string
|
||||||
dest string
|
dest string
|
||||||
expected string
|
expected string
|
||||||
noInfer bool
|
infer bool
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,39 +3,55 @@
|
|||||||
|
|
||||||
package merge3_test
|
package merge3_test
|
||||||
|
|
||||||
|
//nolint:lll
|
||||||
var elementTestCases = []testCase{
|
var elementTestCases = []testCase{
|
||||||
//
|
//
|
||||||
// Test Case
|
// Test Case
|
||||||
//
|
//
|
||||||
{description: `Add an element to an existing list`,
|
{description: `Add an element to an existing list`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
- name: baz
|
- name: baz
|
||||||
image: baz:2
|
image: baz:2
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:1
|
image: foo:1
|
||||||
- image: baz:2
|
- image: baz:2
|
||||||
name: baz
|
name: baz
|
||||||
|
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -43,44 +59,67 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Add an element to a non-existing list`,
|
{description: `Add an element to a non-existing list`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment`,
|
kind: Deployment`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- image: foo:bar
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: foo:bar
|
||||||
name: foo
|
name: foo
|
||||||
`},
|
`},
|
||||||
|
|
||||||
{description: `Add an element to a non-existing list, existing in dest`,
|
{description: `Add an element to a non-existing list, existing in dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment`,
|
kind: Deployment`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: baz
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: baz
|
||||||
image: baz:bar
|
image: baz:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: baz
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: baz
|
||||||
image: baz:bar
|
image: baz:bar
|
||||||
- image: foo:bar
|
- image: foo:bar
|
||||||
name: foo
|
name: foo
|
||||||
`},
|
`},
|
||||||
|
|
||||||
@@ -90,25 +129,38 @@ containers:
|
|||||||
// This element is missing from the destination -- only the new fields are added
|
// This element is missing from the destination -- only the new fields are added
|
||||||
{description: `Add a field to the element, element missing from dest`,
|
{description: `Add a field to the element, element missing from dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar`,
|
image: foo:bar`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command:
|
command:
|
||||||
- run.sh
|
- run.sh
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- command:
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
- run.sh
|
- run.sh
|
||||||
name: foo
|
name: foo
|
||||||
`},
|
`},
|
||||||
@@ -118,28 +170,41 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Update a field on the elem, element missing from the dest`,
|
{description: `Update a field on the elem, element missing from the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command:
|
command:
|
||||||
- run.sh
|
- run.sh
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command:
|
command:
|
||||||
- run2.sh
|
- run2.sh
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- command:
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
- run2.sh
|
- run2.sh
|
||||||
name: foo
|
name: foo
|
||||||
`},
|
`},
|
||||||
@@ -149,30 +214,46 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Update a field on the elem, element present in the dest`,
|
{description: `Update a field on the elem, element present in the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`},
|
`},
|
||||||
@@ -182,28 +263,44 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Add a field on the elem, element present in the dest`,
|
{description: `Add a field on the elem, element present in the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`},
|
`},
|
||||||
@@ -213,29 +310,45 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Add a field on the elem, element and field present in the dest`,
|
{description: `Add a field on the elem, element and field present in the dest`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`},
|
`},
|
||||||
@@ -245,23 +358,39 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Ignore an element`,
|
{description: `Ignore an element`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: {}
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: {}
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: {}
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`},
|
`},
|
||||||
|
|
||||||
@@ -270,18 +399,25 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Leave deleted`,
|
{description: `Leave deleted`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`},
|
`},
|
||||||
|
|
||||||
@@ -290,22 +426,38 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- matching`,
|
{description: `Remove an element -- matching`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -313,23 +465,39 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- field missing from update`,
|
{description: `Remove an element -- field missing from update`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -337,32 +505,48 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- element missing`,
|
{description: `Remove an element -- element missing`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
- name: baz
|
- name: baz
|
||||||
image: baz:bar
|
image: baz:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
- name: baz
|
- name: baz
|
||||||
image: baz:bar
|
image: baz:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`},
|
`},
|
||||||
@@ -372,24 +556,40 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- empty containers`,
|
{description: `Remove an element -- empty containers`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: {}
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -397,53 +597,82 @@ kind: Deployment
|
|||||||
//
|
//
|
||||||
{description: `Remove an element -- missing list field`,
|
{description: `Remove an element -- missing list field`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run.sh']
|
command: ['run.sh']
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec: {}
|
||||||
`},
|
`},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test Case
|
// Test Case
|
||||||
//
|
//
|
||||||
{description: `no infer merge keys no merge'`,
|
{description: `infer merge keys merge'`,
|
||||||
origin: `
|
origin: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -451,8 +680,8 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using schema`,
|
{description: `no infer merge keys merge using schema`,
|
||||||
origin: `
|
origin: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -460,8 +689,8 @@ spec:
|
|||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -470,8 +699,8 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -480,8 +709,8 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
kind: Deployment
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
@@ -490,7 +719,7 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -498,30 +727,46 @@ spec:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
{description: `no infer merge keys merge using explicit schema as line comment'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
spec:
|
||||||
- name: foo # hell ow
|
template:
|
||||||
|
spec:
|
||||||
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
spec:
|
||||||
- name: foo # hell ow
|
template:
|
||||||
|
spec:
|
||||||
|
containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -529,32 +774,48 @@ containers: # {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"t
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema as head comment'`,
|
{description: `no infer merge keys merge using explicit schema as head comment'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
containers:
|
spec:
|
||||||
- name: foo
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: foo
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
spec:
|
||||||
containers:
|
template:
|
||||||
- name: foo # hell ow
|
spec:
|
||||||
|
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
|
containers:
|
||||||
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
spec:
|
||||||
containers:
|
template:
|
||||||
- name: foo # hell ow
|
spec:
|
||||||
|
# {"items":{"$ref": "#/definitions/io.k8s.api.core.v1.Container"},"type":"array","x-kubernetes-patch-merge-key":"name","x-kubernetes-patch-strategy": "merge"}
|
||||||
|
containers:
|
||||||
|
- name: foo # hell ow
|
||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -562,12 +823,14 @@ containers:
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema to parent field'`,
|
{description: `no infer merge keys merge using explicit schema to parent field'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
@@ -575,6 +838,7 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
containers:
|
containers:
|
||||||
@@ -582,6 +846,7 @@ spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
containers:
|
containers:
|
||||||
@@ -589,7 +854,7 @@ spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -597,12 +862,14 @@ spec: # {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
|||||||
//
|
//
|
||||||
{description: `no infer merge keys merge using explicit schema to parent field header'`,
|
{description: `no infer merge keys merge using explicit schema to parent field header'`,
|
||||||
origin: `
|
origin: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: foo
|
- name: foo
|
||||||
`,
|
`,
|
||||||
update: `
|
update: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
@@ -610,6 +877,7 @@ spec:
|
|||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
local: `
|
local: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
spec:
|
spec:
|
||||||
@@ -618,6 +886,7 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
`,
|
`,
|
||||||
expected: `
|
expected: `
|
||||||
|
apiVersion: custom
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
# {"$ref":"#/definitions/io.k8s.api.core.v1.PodSpec"}
|
||||||
spec:
|
spec:
|
||||||
@@ -626,6 +895,6 @@ spec:
|
|||||||
image: foo:bar
|
image: foo:bar
|
||||||
command: ['run2.sh']
|
command: ['run2.sh']
|
||||||
`,
|
`,
|
||||||
noInfer: true,
|
infer: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func TestMerge(t *testing.T) {
|
|||||||
for j := range testCases[i] {
|
for j := range testCases[i] {
|
||||||
tc := testCases[i][j]
|
tc := testCases[i][j]
|
||||||
t.Run(tc.description, func(t *testing.T) {
|
t.Run(tc.description, func(t *testing.T) {
|
||||||
actual, err := MergeStrings(tc.local, tc.origin, tc.update, !tc.noInfer)
|
actual, err := MergeStrings(tc.local, tc.origin, tc.update, tc.infer)
|
||||||
if tc.err == nil {
|
if tc.err == nil {
|
||||||
if !assert.NoError(t, err, tc.description) {
|
if !assert.NoError(t, err, tc.description) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
@@ -47,5 +47,5 @@ type testCase struct {
|
|||||||
local string
|
local string
|
||||||
expected string
|
expected string
|
||||||
err error
|
err error
|
||||||
noInfer bool
|
infer bool
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user