Crossplane CRD composition import generates errors in k file
markphillips100 opened this issue · 5 comments
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
- Install VSCode, KCL, KCL language server and KCL VSCode extension.
- Download crossplane composition crd from here, or clone repo whichever is preferred to obtain this file.
- Create a new KCL module:
kcl mod init mymod
andcd mymod
. - Type
kcl import -m crd -s -o . <location of yaml from step 1>
- Open module folder in VSCode and open the file models\apiextensions_crossplane_io_v1_composition.k at line 1171.
- Observe errors in the generated code.
- Replace
main.k
contents with the following code:
import models as models
comp: models.Composition {}
- Type
kcl run
from module folder. - Observe errors related to generated code from line 1171.
- Comment generated code at line 1171 and execute step 8 again. Observe no error.
2. What did you expect to see? (Required)
No errors.
3. What did you see instead (Required)
1171 | readinessChecks?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0] = [{matchCondition
: map[status:True type:Ready], type: MatchCondition}]
|
^ name 'Ready' is not defined
|
error[E2L23]: CompileError
--> D:\Dev\EziEvent\ezievent-identityservice\devops\dev-cluster\crossplane-kcl\tuckerbox-core-composition\models\apiextensio
ns_crossplane_io_v1_composition.k:1171:159
|
1171 | readinessChecks?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0] = [{matchCondition
: map[status:True type:Ready], type: MatchCondition}]
|
^ name 'MatchCondition' is not defined, did you mean '["matchCondition"]'?
|
4. What is your KCL components version? (Required)
KCL: 0.8.0-windows-amd64
KCL vscode extension: v0.1.5
OS: Windows11
Hello @markphillips100
Thank you for your feedback. This may be a bug in the kcl-openapi tool https://github.com/kcl-lang/kcl-openapi, which changes the default value to go map string instead of KCL dict string. The correct code at line 1171 may be
readinessChecks?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0] =[{matchCondition: {status: True, type: "Ready"}, type: "MatchCondition"}]
Yes that gives no errors. I'm assuming then that kcl import is just a wrapper over kcl-openapi?
I'll raise the issue there then. Feel free to close.
May I ask what version of kcl-openapi the kcl 0.8.0 version uses? If there is a later version I may try that direct just to see if the issue remains in latest code from that repo.
I think this issue still exists in the latest version.