mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
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:
@@ -15,24 +15,27 @@ var testCases = [][]testCase{scalarTestCases, listTestCases, mapTestCases, eleme
|
||||
|
||||
func TestMerge(t *testing.T) {
|
||||
for i := range testCases {
|
||||
for _, tc := range testCases[i] {
|
||||
actual, err := MergeStrings(tc.local, tc.origin, tc.update)
|
||||
if tc.err == nil {
|
||||
if !assert.NoError(t, err, tc.description) {
|
||||
t.FailNow()
|
||||
for j := range testCases[i] {
|
||||
tc := testCases[i][j]
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
actual, err := MergeStrings(tc.local, tc.origin, tc.update, !tc.noInfer)
|
||||
if tc.err == nil {
|
||||
if !assert.NoError(t, err, tc.description) {
|
||||
t.FailNow()
|
||||
}
|
||||
if !assert.Equal(t,
|
||||
strings.TrimSpace(tc.expected), strings.TrimSpace(actual), tc.description) {
|
||||
t.FailNow()
|
||||
}
|
||||
} else {
|
||||
if !assert.Errorf(t, err, tc.description) {
|
||||
t.FailNow()
|
||||
}
|
||||
if !assert.Contains(t, tc.err.Error(), err.Error()) {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
if !assert.Equal(t,
|
||||
strings.TrimSpace(tc.expected), strings.TrimSpace(actual), tc.description) {
|
||||
t.FailNow()
|
||||
}
|
||||
} else {
|
||||
if !assert.Errorf(t, err, tc.description) {
|
||||
t.FailNow()
|
||||
}
|
||||
if !assert.Contains(t, tc.err.Error(), err.Error()) {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,4 +47,5 @@ type testCase struct {
|
||||
local string
|
||||
expected string
|
||||
err error
|
||||
noInfer bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user