You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When pulling in the CompositeResourceDefinition schema and creating data using it, it seems that the KCL validations on the schema type and the Crossplane webhook validations from the cluster are incompatible.
If you try and leave this field undefined, you get the following error:
Error: failed to compile the kcl package
EvaluationError
--> /Users/sunspar/.kcl/kpm/crossplane_1.15.2/v1/apiextensions_crossplane_io_v1_composite_resource_definition.k:438:1
|
438 | len(deprecationWarning) <= 256
| object of type 'UndefinedType' has no len()
|
If instead you define it with any string message (including an empty string), then the YAML generates correctly (given the config you have) but applying it to the cluster causes the following error:
The CompositeResourceDefinition "helloworlds.crossplane.example.com" is invalid: <generated_CRD_"helloworlds.crossplane.example.com">.spec.versions[0].deprecationWarning: Invalid value: "": can only be set for deprecated versions`
2. What did you expect to see? (Required)deprecationWarning
I expected that since the field was optional, not providing it was allowed and would allow me to generate YAML output.
3. What did you see instead (Required)
The field is required and I cannot export this to YAML without it. providing this value however is problematic, because the K8S admission webhook blocks publishing XRDs with this field when deprecated = false.
4. What is your KCL components version? (Required)
0.8.6-darwin-arm64
The text was updated successfully, but these errors were encountered:
I've got this working with a local copy of the module when I change the check to the following, but I'm not sure if there is a better way to handle this issue since these files are auto-generated and likely to be overwritten (or worse, regresses when these schemas are generated for future versions of Crossplane):
check:
len(deprecationWarning) <= 256 if deprecationWarning != Undefined
Although it is created by kcl-openapi tool automatically https://github.com/kcl-lang/kcl-openapi , but the generated code is not correct. You can submit a PR to modify this code and upgrade the version in the kcl.mod . When the PR is merged, the package on the registry will be automatically updated. Thank you! ❤️
Bug Report
When pulling in the CompositeResourceDefinition schema and creating data using it, it seems that the KCL validations on the schema type and the Crossplane webhook validations from the cluster are incompatible.
1. Minimal reproduce step (Required)
Given the following file, hello_world.k:
You should find that you cannot export this definition to YAML via something like
kcl hello-world.k
unless you provide a string value forspec.versions[].deprecationWarning
. The schema claims this field is optional, but the check constraint here forces it to exist (len() fails if the value of the field is Undefined). https://github.com/kcl-lang/modules/blob/main/crossplane/v1/apiextensions_crossplane_io_v1_composite_resource_definition.k#L438If you try and leave this field undefined, you get the following error:
If instead you define it with any string message (including an empty string), then the YAML generates correctly (given the config you have) but applying it to the cluster causes the following error:
2. What did you expect to see? (Required)deprecationWarning
I expected that since the field was optional, not providing it was allowed and would allow me to generate YAML output.
3. What did you see instead (Required)
The field is required and I cannot export this to YAML without it. providing this value however is problematic, because the K8S admission webhook blocks publishing XRDs with this field when deprecated = false.
4. What is your KCL components version? (Required)
0.8.6-darwin-arm64
The text was updated successfully, but these errors were encountered: