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

[Bug] Import of modules containing "-" fails #1261

Closed
dennybaa opened this issue Apr 30, 2024 · 7 comments
Closed

[Bug] Import of modules containing "-" fails #1261

dennybaa opened this issue Apr 30, 2024 · 7 comments
Assignees
Labels
bug Something isn't working module

Comments

@dennybaa
Copy link

dennybaa commented Apr 30, 2024

Hi there, I've bumped into inability to use hosted modules from artifactshub in case if they contain dash "-" character.

1. Minimal reproduce step (Required)

Let's suppose the following directory structure:

├── appsops
│   └── rules
│       ├── dev
│       │   ├── kcl.yaml
│       │   ├── main.k
│       └── iaas-prod
├── kcl.mod
├── kcl.mod.lock
├── pkg
│   ├── rules.k

Namely the import statement is located in the rule.k file which is in turn imported from main.k triggered by kcl.yaml.

Sample rules.k contents:

# import victoria_metrics_operator.v1beta1.operator_victoriametrics_com_v1beta1_vm_rule as vmrule
import k8s.apimachinery.pkg.apis.meta.v1

# k = vmrule.OperatorVictoriametricsComV1beta1VMRuleSpecGroupsItems0RulesItems0 {alert = "hello"}
v = v1.ObjectMeta {name = "hello"}

In case a module doesn't have any dashes such as k8s everything works smooth whereas importing victoria_metrics_operator doesn't work. Error message:

8 | k = vmrule.OperatorVictoriametricsComV1beta1VMRuleSpecGroupsItems0RulesItems0 {alert = "hello"}
  |     ^ Invalid schema type 'any'

It's odd, but if we place the same dashed import on the level with kcl.mod into say it a.k file, and simply invoke kcl a.k this scenario is operable.

4. What is your KCL components version? (Required)

"0.8.6"

@dennybaa dennybaa changed the title Import of modules containing "-" fails [Bug] Import of modules containing "-" fails Apr 30, 2024
@Peefy
Copy link
Contributor

Peefy commented Apr 30, 2024

Hello. Thanks for the feedback. Could you please show me the content of kcl.mod? I will double check it.

@dennybaa
Copy link
Author

dennybaa commented Apr 30, 2024

Yep, sure @Peefy

[package]
name = "some-test"
edition = "v0.8.0"
version = "0.0.1"

[dependencies]
k8s = { oci = "oci://ghcr.io/kcl-lang/k8s", tag = "1.28" }
victoria-metrics-operator = { oci = "oci://ghcr.io/kcl-lang/victoria-metrics-operator", tag = "0.0.1" }

And for the whole picture kcl.yaml which is:

kcl_cli_configs:
  files:
    - main.k

@Peefy Peefy added bug Something isn't working module labels Apr 30, 2024
@Peefy Peefy added this to the v0.9.0 Release milestone Apr 30, 2024
@Peefy
Copy link
Contributor

Peefy commented Apr 30, 2024

Thank you! I will fix it and release a new version today.

@dennybaa
Copy link
Author

dennybaa commented Apr 30, 2024

Also just an idea which seems pretty much as another issue... To brush up modules import behavior. By this I mean, even if there's no dependency in kcl.mod, the module if available in cache (~/.kcl/kpm) is silently imported which seems not unambiguous.

@dennybaa
Copy link
Author

Thank you too! It's a pleasure to work with KCL language.

@Peefy
Copy link
Contributor

Peefy commented Apr 30, 2024

Also just an idea which seems pretty much as another issue... To brush up modules import behavior. By this I mean, even if there's no dependency in kcl.mod, the module if available in cache (~/.kcl/kpm) is silently imported which seems not unambiguous.

Thank you, I will fix it together.

@Peefy Peefy self-assigned this Apr 30, 2024
@Peefy
Copy link
Contributor

Peefy commented Apr 30, 2024

Closed by kcl-lang/cli#73 and kcl-lang/kpm#309

@Peefy Peefy closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module
Projects
None yet
Development

No branches or pull requests

2 participants