Skip to content

Top-level arguments #24

Open
Open
@moleike

Description

@moleike

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions