Use OpenAPI when merging (3way) resources

- When merging (3way) resources use the patch strategy from the openAPI if the definition exists for the field
- Allow disabling of guessing patch strategy merge keys when no definition exists
- Support defining strategy and key directly on configuration fields through line and header coments
- Support attaching schema to parent fields of lists, and propagating -- e.g. that a field is a PodTemplate
This commit is contained in:
Phillip Wittrock
2020-02-27 10:08:40 -08:00
parent 8991b193c6
commit 5d1a0346b5
24 changed files with 991 additions and 507 deletions

View File

@@ -4,21 +4,21 @@
package merge2_test
var listTestCases = []testCase{
{`replace List -- different value in dest`,
`
{description: `replace List -- different value in dest`,
source: `
kind: Deployment
items:
- 1
- 2
- 3
`,
`
dest: `
kind: Deployment
items:
- 0
- 1
`,
`
expected: `
kind: Deployment
items:
- 1
@@ -27,18 +27,18 @@ items:
`,
},
{`replace List -- missing from dest`,
`
{description: `replace List -- missing from dest`,
source: `
kind: Deployment
items:
- 1
- 2
- 3
`,
`
dest: `
kind: Deployment
`,
`
expected: `
kind: Deployment
items:
- 1
@@ -50,22 +50,22 @@ items:
//
// Test Case
//
{`keep List -- same value in src and dest`,
`
{description: `keep List -- same value in src and dest`,
source: `
kind: Deployment
items:
- 1
- 2
- 3
`,
`
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
`
expected: `
kind: Deployment
items:
- 1
@@ -77,18 +77,18 @@ items:
//
// Test Case
//
{`keep List -- unspecified in src`,
`
{description: `keep List -- unspecified in src`,
source: `
kind: Deployment
`,
`
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
`
expected: `
kind: Deployment
items:
- 1
@@ -100,19 +100,19 @@ items:
//
// Test Case
//
{`remove List -- null in src`,
`
{description: `remove List -- null in src`,
source: `
kind: Deployment
items: null
`,
`
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
`
expected: `
kind: Deployment
`,
},
@@ -120,19 +120,19 @@ kind: Deployment
//
// Test Case
//
{`remove list -- empty in src`,
`
{description: `remove list -- empty in src`,
source: `
kind: Deployment
items: {}
`,
`
dest: `
kind: Deployment
items:
- 1
- 2
- 3
`,
`
expected: `
kind: Deployment
items: {}
`,