String type setter is not allowed to be numbers
Sometimes my string just happen to be "numbers", but kpt will compain about it.
Kptfile:
apiVersion: kpt.dev/v1alpha1
kind: Kptfile
metadata:
name: str-val
packageMetadata:
shortDescription: sample description
openAPI:
definitions:
io.k8s.cli.setters.stringValue:
type: string
x-k8s-cli:
setter:
name: stringValue
value: '1234'
io.k8s.cli.substitutions.subValue:
type: string
x-k8s-cli:
substitution:
name: subValue
pattern: "prefix-VALUE"
values:
- marker: VALUE
ref: '#/definitions/io.k8s.cli.setters.stringValue'
config.yaml
apiVersion: test/alpha
kind: strValue
metadata:
name: strValue
spec:
stringVal: 1234 # {"$ref":"#/definitions/io.k8s.cli.setters.stringValue"}
subVal: prefix-1234 # {"$ref":"#/definitions/io.k8s.cli.substitutions.subValue"}
Error:
> ~/bin/kpt cfg list-setters .
Error: The input value doesn't validate against provided OpenAPI schema: validation failure list:
stringValue in body must be of type string: "number"
> ~/bin/kpt version
v0.29.0
Expectation:
"1234" should be a valid string although it's also a number.
This used to work. Not sure exactly when it broke but on 0.27+ i run into this when setting a setter to the value true and on some earlier version it definitely worked because I have this scripted.
Are there any known workarounds for this? I can't come up with any way of quoting that works. If I use "'true'" it no longer fails but then the value in my KRM becomes "'true'" so that doesn't help.
Works in 0.26.0
I think this might be related to the validation functionality that was added? @phanimarupaka
This issue is caused by incorrect handling of values that are valid for both strings and other yaml types (like integers and booleans). This should be fixed by https://github.com/kubernetes-sigs/kustomize/pull/2599 and https://github.com/kubernetes-sigs/kustomize/pull/2608 and is included in kpt v0.30.0 that we released today.
We know there are still some rough edges around handling of types. If you run into this kind of issues, please let us know. There is a ongoing discussion around this on https://github.com/kubernetes-sigs/kustomize/pull/2594
I can confirm that setting a setter to true/false works as expected in 0.30.0
Thanks for reporting this. I'm closing this issue now, but if you find any other issues, feel free to reopen or just file a new issue.