fix: patch additions honor source key style

When a patch appends a new node, it should honor the key style from the
patch. Prior to this commit, no style was applied, leading to problems
when the key value could be interpreted as a different type based on its
content. For example, "9110" needs quoting to ensure it is seen as a
string in yaml.
This commit is contained in:
Ed Overton
2023-06-08 17:21:46 -04:00
parent 336bc14e1a
commit 691b7d1df3
5 changed files with 216 additions and 5 deletions

View File

@@ -306,4 +306,61 @@ metadata:
name: foo
annotations: {}
`},
//
// Test Case
//
{
description: `Verify key style behavior`,
origin: `
apiVersion: v1
kind: ConfigMap
metadata:
name: foo
data:
unchanged: origin
unchanged-varying-key-style: origin
deleted-in-update: origin
deleted-in-local: origin
`,
update: `
apiVersion: v1
kind: ConfigMap
metadata:
name: foo
data:
unchanged: origin
'unchanged-varying-key-style': origin
deleted-in-local: origin
'added-in-update': 'update'
'added-in-update-and-local-same-value': 'update-and-local'
'added-in-update-and-local-diff-value': 'update'
`,
local: `
apiVersion: v1
kind: ConfigMap
metadata:
name: foo
data:
unchanged: origin
"unchanged-varying-key-style": origin
deleted-in-update: origin
"added-in-local": "local"
"added-in-update-and-local-same-value": "update-and-local"
"added-in-update-and-local-diff-value": "local"
`,
expected: `
apiVersion: v1
kind: ConfigMap
metadata:
name: foo
data:
unchanged: origin
"unchanged-varying-key-style": origin
"added-in-local": "local"
"added-in-update-and-local-same-value": "update-and-local"
"added-in-update-and-local-diff-value": "update"
'added-in-update': 'update'
`,
},
}