Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crossplane CRD composition import generates errors in k file #1127

Closed
markphillips100 opened this issue Mar 12, 2024 · 5 comments · Fixed by kcl-lang/kcl-openapi#83
Closed
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.

Comments

@markphillips100
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Install VSCode, KCL, KCL language server and KCL VSCode extension.
  2. Download crossplane composition crd from here, or clone repo whichever is preferred to obtain this file.
  3. Create a new KCL module: kcl mod init mymod and cd mymod.
  4. Type kcl import -m crd -s -o . <location of yaml from step 1>
  5. Open module folder in VSCode and open the file models\apiextensions_crossplane_io_v1_composition.k at line 1171.
  6. Observe errors in the generated code.
  7. Replace main.k contents with the following code:
import models as models
comp: models.Composition {}
  1. Type kcl run from module folder.
  2. Observe errors related to generated code from line 1171.
  3. 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

@Peefy
Copy link
Contributor

Peefy commented Mar 12, 2024

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"}]

@markphillips100
Copy link
Author

Yes that gives no errors. I'm assuming then that kcl import is just a wrapper over kcl-openapi?

@markphillips100
Copy link
Author

I'll raise the issue there then. Feel free to close.

@Peefy Peefy added this to the v0.9.0 Release milestone Mar 12, 2024
@Peefy Peefy added tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc. bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Mar 12, 2024
@markphillips100
Copy link
Author

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.

@Peefy
Copy link
Contributor

Peefy commented Mar 12, 2024

I think this issue still exists in the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed tool Issues or PRs related to kcl tools inlucding format, lint, validation, document tools, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants