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

Built-in: importstr/yaml #995

Closed
steeling opened this issue Jan 20, 2024 · 7 comments
Closed

Built-in: importstr/yaml #995

steeling opened this issue Jan 20, 2024 · 7 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed runtime Issues or PRs related to kcl runtime including value and value opertions stdlib Issues or PRs related to kcl standard libraries

Comments

@steeling
Copy link

steeling commented Jan 20, 2024

Feature Request

Is your feature request related to a problem? Please describe:
I want to declaritively create text files and import them into kcl.

Describe the feature you'd like:
I'd like to create configmaps through kcl, ie:

kind: "ConfigMap"
apiVersion: "v1"
data: {
   "myfile": importstr(myfile.txt)
}

Describe alternatives you've considered:
Create generative rules outside of kcl

Other improvements might be:

importYaml, which would be able to import a yaml file, and convert to a KCL object.
glob to allow creating a list of filenames, that I can then iterate over to create a set of files, ie:

kind: "ConfigMap"
apiVersion: "v1"
data: {
   filename: importstr(filename) for filename in glob('mydata/*.yaml')
}

This feature does exist in jsonnet

@Peefy Peefy added this to the v0.8.0 Release milestone Jan 21, 2024
@Peefy Peefy added runtime Issues or PRs related to kcl runtime including value and value opertions good first issue Good for newcomers help wanted Extra attention is needed stdlib Issues or PRs related to kcl standard libraries labels Jan 21, 2024
@Peefy
Copy link
Contributor

Peefy commented Jan 23, 2024

Thank you for your feedback ❤️. Considering that corresponding IO functions or configmap generators are provided in many projects such as Kustomize, Helm, Terraform, Jsonnet, etc., this feature is considered suitable to be added as functions in the io system modules in version 0.8 of KCL just most of what is done in this issue #313

@shivam-Purohit
Copy link

hey @Peefy I wanted to start with the project, can i be any help in this?

@Peefy
Copy link
Contributor

Peefy commented Jan 23, 2024

hey @Peefy I wanted to start with the project, can i be any help in this?

Yes, you can open a PR to impl the io package for KCL.

@shivam-Purohit
Copy link

Yes, you can open a PR to impl the io package for KCL.

I will look into it and come up with a draft pr.

@Peefy
Copy link
Contributor

Peefy commented Feb 5, 2024

Whether this feature is Implemented in the form of a read_file function or importstr/importyaml, this feature must be additionally added with the sandbox feature to ensure security. The default sandbox workspace is workdir, and we need to discuss the relevant design here. cc @shivam-Purohit @zong-zhe

@shivam-Purohit
Copy link

@Peefy is this on high priority? sorry, but I am currently a bit busy. I am unassigning myself for now, if someone is interested they can try freely, it's up for grabs. I will try this in few weeks. Is that okay?

@Peefy
Copy link
Contributor

Peefy commented Feb 25, 2024

Related Issue: #1049
Closed by #1034, #1054, #1056, #1051 and #1052.

@Peefy Peefy closed this as completed Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed runtime Issues or PRs related to kcl runtime including value and value opertions stdlib Issues or PRs related to kcl standard libraries
Projects
None yet
Development

No branches or pull requests

4 participants