kyaml: initial support for yaml and resource manipulation

This commit is contained in:
Phillip Wittrock
2019-11-04 11:27:47 -08:00
parent 588297f1f9
commit efd7c8e3f7
92 changed files with 13733 additions and 0 deletions

View File

@@ -0,0 +1,265 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package merge2_test
var elementTestCases = []testCase{
{`merge Element -- keep field in dest`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
`,
`
kind: Deployment
items:
- name: foo
image: foo:v0
command: ['run.sh']
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
command:
- run.sh
`,
},
{`merge Element -- add field to dest`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
command: ['run.sh']
`,
`
kind: Deployment
items:
- name: foo
image: foo:v0
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
command:
- run.sh
`,
},
{`merge Element -- add list, empty in dest`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
command: ['run.sh']
`,
`
kind: Deployment
items: {}
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
command:
- run.sh
`,
},
{`merge Element -- add list, missing from dest`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
command: ['run.sh']
`,
`
kind: Deployment
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
command:
- run.sh
`,
},
{`merge Element -- add Element first`,
`
kind: Deployment
items:
- name: bar
image: bar:v1
command: ['run2.sh']
- name: foo
image: foo:v1
`,
`
kind: Deployment
items:
- name: foo
image: foo:v0
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command:
- run2.sh
`,
},
{`merge Element -- add Element second`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command: ['run2.sh']
`,
`
kind: Deployment
items:
- name: foo
image: foo:v0
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command:
- run2.sh
`,
},
//
// Test Case
//
{`keep list -- list missing from src`,
`
kind: Deployment
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command: ['run2.sh']
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command:
- run2.sh
`,
},
//
// Test Case
//
{`keep Element -- element missing in src`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
`,
`
kind: Deployment
items:
- name: foo
image: foo:v0
- name: bar
image: bar:v1
command: ['run2.sh']
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command:
- run2.sh
`,
},
//
// Test Case
//
{`keep element -- empty list in src`,
`
kind: Deployment
items: {}
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command:
- run2.sh
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command:
- run2.sh
`,
},
//
// Test Case
//
{`remove Element -- null in src`,
`
kind: Deployment
items: null
`,
`
kind: Deployment
items:
- name: foo
image: foo:v1
- name: bar
image: bar:v1
command:
- run2.sh
`,
`
kind: Deployment
`,
},
}