Don't allow creating setter with same name as substitution

This commit is contained in:
Morten Torkildsen
2020-07-12 11:28:09 -07:00
parent 556eb48651
commit f9631e4bb2
2 changed files with 39 additions and 3 deletions

View File

@@ -408,6 +408,39 @@ spec:
`,
err: "cyclic substitution detected with name my-nested-subst",
},
{
name: "substitution with non-existing setter with same name",
args: []string{
"foo", "--field-value", "prefix-1234", "--pattern", "prefix-${foo}"},
input: `
apiVersion: test/v1
kind: Foo
metadata:
name: foo
spec:
setterVal: 1234
substVal: prefix-1234
`,
inputOpenAPI: `
apiVersion: v1alpha1
kind: Example
`,
expectedOpenAPI: `
apiVersion: v1alpha1
kind: Example
`,
expectedResources: `
apiVersion: test/v1
kind: Foo
metadata:
name: foo
spec:
setterVal: 1234
substVal: prefix-1234
`,
err: "setters must have different name than the substitution: foo",
},
}
for i := range tests {
test := tests[i]