How to use variable on left side ?
This is basic syntax of datadog annotation I am trying to convert in jsonnet. ad.datadoghq.com/<CONTAINER_IDENTIFIER>.logs : '[<LOG_CONFIG>]'
CONTAINER_IDENTIFIER will be different for each container.
Do you mean using a variable in the field name?
You can do it as follows:
local var = "foo";
{
["bar" + var + "baz"]: 42
}
which results in:
{
"barfoobaz": 42
}
There's a section in the tutorial about this: https://jsonnet.org/learning/tutorial.html#computed_field_names.
Please note that Github issues are not meant for basic language usage questions. Please consider posting such questions on Stackoverflow with a tag jsonnet, asking in the mailing list https://groups.google.com/forum/#!forum/jsonnet or on #jsonnet slack channel on https://kubernetes.slack.com/. Feel free to open an issue if you don't get a satisfying answer in one of these, if you suspect that there might be a bug, you have a feature request, a question about best practices or any other issue that the language developers should get involved in.
Thanks @sbarzowski It was really helpful