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

Top-level arguments #24

Open
moleike opened this issue Apr 7, 2021 · 0 comments
Open

Top-level arguments #24

moleike opened this issue Apr 7, 2021 · 0 comments
Labels

Comments

@moleike
Copy link
Owner

moleike commented Apr 7, 2021

Jsonnet programs cannot always be self-contained, consider e.g. when the generated config needs to have secrets in it. In this case, you do not want to commit your secrets alongside code. More generally, you might want to parameterise your program with commit hashes, versions numbers, etc.

Top-level arguments (TLAs) allow you to call Jsonnet programs with parameters, as long as your program evaluates to a function.

>>> jsonnet -e 'std.map' --tla-code 'func=function(x) x * x' --tla-code arr='[1, 2, 3]'
>>> 
[
   1,
   4,
   9
]

If a program does not reduce to a top-level function, then the arguments are ignored.

See here for how it's done in go-jsonnet: https://github.com/google/go-jsonnet/blob/v0.17.0/interpreter.go#L1227

@moleike moleike added help wanted Extra attention is needed good first issue Good for newcomers labels Apr 7, 2021
@moleike moleike removed the help wanted Extra attention is needed label Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant