mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
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:
@@ -417,6 +417,47 @@ spec:
|
||||
protocol: TCP
|
||||
- port: 30901
|
||||
targetPort: 30901
|
||||
`,
|
||||
mergeOptions: yaml.MergeOptions{
|
||||
ListIncreaseDirection: yaml.MergeOptionsListAppend,
|
||||
},
|
||||
},
|
||||
|
||||
//
|
||||
// Test Case
|
||||
//
|
||||
{description: `Verify key style behavior`,
|
||||
source: `
|
||||
kind: Deployment
|
||||
spec:
|
||||
source-and-dest: source-and-dest
|
||||
source-only: source-only
|
||||
"source-only-key-double-quoted": source-only
|
||||
source-and-dest-key-style-diff-1: source-and-dest
|
||||
'source-and-dest-key-style-diff-2': source-and-dest
|
||||
"source-and-dest-key-style-diff-3": source-and-dest
|
||||
`,
|
||||
dest: `
|
||||
kind: Deployment
|
||||
spec:
|
||||
source-and-dest: source-and-dest
|
||||
'source-and-dest-key-style-diff-1': source-and-dest
|
||||
"source-and-dest-key-style-diff-2": source-and-dest
|
||||
source-and-dest-key-style-diff-3: source-and-dest
|
||||
dest-only: dest-only
|
||||
'dest-only-key-single-quoted': dest-only
|
||||
`,
|
||||
expected: `
|
||||
kind: Deployment
|
||||
spec:
|
||||
source-and-dest: source-and-dest
|
||||
'source-and-dest-key-style-diff-1': source-and-dest
|
||||
"source-and-dest-key-style-diff-2": source-and-dest
|
||||
source-and-dest-key-style-diff-3: source-and-dest
|
||||
dest-only: dest-only
|
||||
'dest-only-key-single-quoted': dest-only
|
||||
source-only: source-only
|
||||
"source-only-key-double-quoted": source-only
|
||||
`,
|
||||
mergeOptions: yaml.MergeOptions{
|
||||
ListIncreaseDirection: yaml.MergeOptionsListAppend,
|
||||
|
||||
Reference in New Issue
Block a user