-
Notifications
You must be signed in to change notification settings - Fork 452
std.parseYaml #460
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
Comments
Fwiw, here's an example implementation: In particular, note that a YAML file is actually an array (aka stream) of YAML-encoded values, which implies a function signature slightly different to an otherwise-similar |
Nice
Perhaps we should have both |
Regarding the importing of json. Presumably this is just a recommendation, since valid json is valid jsonnet, there's nothing to stop people using import on json files? |
Yes it'd be a way to allow people to write scripts that can import "untrusted" JSON, i.e. JSON that worst case has bad values in it, not JSON that reads weird files. Although, to be honest, we should probably just sandbox the filesystem, e.g. not allow imports to escape the CWD. |
Any progress on this? |
The |
Feature request - please don't do this. I'd rather do |
Just to be clear, it would still be possible to explicitly add the directory that you are interested in (by adding them to Jsonnet library path, e.g. |
It would be pretty impactful for us, we use something like |
1 similar comment
It would be pretty impactful for us, we use something like |
@sbarzowski using the |
Thanks for the feedback. FYI there are no immediate plans to enforce FS sandboxing for importing and if we come back to this in the future, we'll try to do it in the least disruptive way. |
is there any sense of a timeline on when this issue might be more deeply considered? |
We already have parseJson. I would like to have parseYaml in the next release. We have go-jsonnet implementation ready. We need to add it here as well. There is more discussion about it in in google/go-jsonnet#339. |
Interestingly, the documentation says it is:
No official release contains commit da1490f yet. |
That cpp commit landed in https://github.com./google/jsonnet/releases/tag/v0.18.0. |
To be closed when we update the docs |
Can't this be closed now @sbarzowski ? The docs website does include |
@groodt thanks! |
Importing YAML files was requested by multiple people, it was proposed in #196 and popped up in various discussions. Also YAML files are very popular in the Kubernetes communities which are heavy users of jsonnet.
Implementing library function (probably builtin)
parseYaml
would allow processing yaml files with jsonnet. It would require importing it first throughimportstr
then invokingparseYaml
on the result. Later we can think about automatically applying it based on extension or something.Relatedly
imporstr
andparseJson
should be used rather thanimport
when dealing withjson
(not jsonnet) files, especially if they are not 100% trusted (considerimporstr "/etc/passwd"
).Challenges:
@benley, @nikolay
The text was updated successfully, but these errors were encountered: