Questions tagged [jsonnet]

Jsonnet is a data templating language which compiles to JSON.

Jsonnet is a domain specific configuration language that helps you define JSON data. Jsonnet lets you compute fragments of JSON within the structure, bringing the same benefit to structured data that templating languages bring to plain text.

Project info

116 questions
0
votes
1 answer

pass json config variable to a function in jsonnet

I had a jsonnet file where there is a file config.json which is hard coded in the variable. What I want to do is to have the ability to pass config_v1.json or config.v*.json as an argument to the config. How do I do that in the jsonnet ? local…
vkaul11
  • 4,098
  • 12
  • 47
  • 79
0
votes
0 answers

Unpacking a nested object in Jsonnet to flatten the structure

I have the following Jsonnet structure { _config: { v: 3, }, obj: { [std.char(97 + x)]: x for x in std.range(0, $._config.v - 1) } } which results in the following json { "_config": { "v": 3 }, "obj": { "a": 0, …
Kavfixnel
  • 151
  • 3
  • 10
0
votes
1 answer

Jsonnet err: object comprehension can only have one field

Below code was returning err : object comprehension can only have one field. What is the right syntax / code in jsonet for below function ? local generateSteps(branchName) = { [branchName + "_test_123"]: test_123(region,…
gthy
  • 301
  • 1
  • 3
  • 10
0
votes
1 answer

How to add and multiply strings representing signed integers in a functional way?

I'd like to do "basic math" on large (64-bits) signed integers in a "DSL" (jsonnet) that only has support for "numbers" (64-bit double). My "strategy" is converting strings, representing "integer" user-input, that can be correctly represented as a…
Sebastien Diot
  • 7,183
  • 6
  • 43
  • 85
0
votes
0 answers

jsonnet: howto template ini-file with duplicate sections?

I am trying to template an ini-file with jsonnet/tanka. Problem is that the file has to contain multiple duplicate sections. (Yes, I know this is probably not the best design, but out of my hands). Specifically i am trying to dynamically generate…
strowi
  • 27
  • 3
0
votes
1 answer

Jsonnet: How to do String Formatting + String Joining together?

I want to make this expression more readable so that it's easier to add new variables if needed, so I tried writing something like this: std.format('{%s}', std.join(', ', [ std.format('"account": "%s"', dev_account_id), …
Riley Hun
  • 2,541
  • 5
  • 31
  • 77
0
votes
1 answer

jsonnet top level function and data in the same file not possible?

I'm trying to automatically generate nested templated json structures with jsonnet. Think about a warehouse structure, in which you'd have a physical site, on this site there are n1 warehouses, these warehouses have n2 ailes which in turn have n3…
The F
  • 15
  • 4
0
votes
1 answer

jsonnet - Removing all items from an array so they can be used without brackets

I have this long script that requires a specific format, but I am having problems with getting some conditions work. I have tried this multiple ways but I always get an array, in other scenarios I have called each index... While that works its slow…
Aladine
  • 185
  • 3
  • 16
0
votes
1 answer

Should I remove comments in the .ini files in Grafana?

I am trying to work on Grafana as code. And I have installed Grafana on my windows 10 machine. Now I wnat to configure Grafana in the Configuration files. This page ( Grafana Configuration) says that I have to uncomment all the ini. files. But…
M65
  • 27
  • 3
0
votes
1 answer

How do I convert my libsonnet files into jsonnet files and then plot them in Grafana?

How do I convert my libsonnet files into jsonnet files and then plot them in Grafana? I am using the repo: grafonnet-lib. Here I want to execute the libsonnet files in grafonnet, but when I execute a file, for example: dashboard.libsonnet, in…
M65
  • 27
  • 3
0
votes
1 answer

error installing jsonnet in python using pip install jsonnet

I want to run libsonnet files for my Grafana dashboard. For that I want to install jsonnet as a python package to run my libsonnet files then. FYI, I am using VScode on my windows 10 machine pip install jsonnet gives me the following error: PS…
M65
  • 27
  • 3
0
votes
0 answers

How to call jsonnet files on a windows mchine

I want to run jsonnet files (For Grafana) on my windows machine, but i dont know exactly what I need for it. I have installed vscode and git bash, but i dont know which command to use to run a file and then get it on my localhost for Grafana. Could…
M65
  • 27
  • 3
0
votes
0 answers

Tanka - VS Code - "Unexpected type string" while getting namespace from spec file

I'm trying out Tanka for k8s configs generation. Also, I'm using VS Code extension by Grafana Labs. I've problems in VS Code with referencing Tanka configuration as described here. I'm using configuration to retrieve namespace, like so: local k =…
Vsevolod
  • 87
  • 6
0
votes
0 answers

GitLab CID: Same job body with different names (passed as parameters)

We are creating a CICD to compile different FPGA IP Cores (imagine different software libraries). All the compilations are based on Makefile and are invoked with a simple make. The main problem is that our collection is increasing more and more, and…
ferdepe
  • 510
  • 1
  • 6
  • 21
0
votes
1 answer

Jsonnet mixin variables and functions

i am trying to write some wrapper logic for deployments with Tanka/Jsonnet, but seem to be running into some issue, that is probably very simple to solve. I am trying to create some wrapper-function for a statefulSet that adds e.g. some stdLabels at…
strowi
  • 27
  • 3