mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +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:
@@ -776,6 +776,103 @@ spec:
|
||||
autoscaling: true
|
||||
deepgram-api:
|
||||
some: value
|
||||
`,
|
||||
},
|
||||
|
||||
// Issue #4928
|
||||
"support numeric keys": {
|
||||
input: `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
"6443": "foobar"
|
||||
`,
|
||||
patch: yaml.MustParse(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
"6443": "barfoo"
|
||||
"9110": "foo-foo"
|
||||
`),
|
||||
expected: `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
"6443": "barfoo"
|
||||
"9110": "foo-foo"
|
||||
`,
|
||||
},
|
||||
|
||||
"honor different key style one": {
|
||||
input: `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
'6443': "foobar"
|
||||
`,
|
||||
patch: yaml.MustParse(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
"6443": "barfoo"
|
||||
9110: "foo-foo"
|
||||
`),
|
||||
expected: `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
'6443': "barfoo"
|
||||
9110: "foo-foo"
|
||||
`,
|
||||
},
|
||||
|
||||
"honor different key style two": {
|
||||
input: `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
"6443": "foobar"
|
||||
`,
|
||||
patch: yaml.MustParse(`
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
"6443": "barfoo"
|
||||
'9110': "foo-foo"
|
||||
`),
|
||||
expected: `
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: blabla
|
||||
namespace: blabla-ns
|
||||
data:
|
||||
"6443": "barfoo"
|
||||
'9110': "foo-foo"
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user