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
1
vote
1 answer

How to build using Bazel offline

I want to build my jsonnet with Bazel. For that I am using the jsonnet rules. Unfortunately in my build pipelines I can't pull from github. So, I have been reading into offline builds, but I can't seem to find a working solution. I have pulled the…
djamaile
  • 695
  • 3
  • 12
  • 30
1
vote
2 answers

jsonnet std.mapWithKey - not generating an array?

I have a local jsonnet object defined as so: local compactRules = { key1: "val1", key2: "val2", key3: "val3" }; And I'd like to generate this array: [ { rule: "key1", action: "val1", }, { rule: "keyk2", action: "val2" …
Doron Behar
  • 2,606
  • 2
  • 21
  • 24
1
vote
1 answer

Addressing parent elemens from nested (children)

I have following jsonnet. { local property = "global variable", property: "global property", bar: self.property, // global property baz: property, // global variable nested: { local…
Wakan Tanka
  • 7,542
  • 16
  • 69
  • 122
1
vote
1 answer

Remove kubernetes deployment based on jsonnet file

I am using jsonnet to describe deployment configuration for Kubernetes. { apiVersion: 'apps/v1', kind: 'Deployment', metadata: { name: 'dapi-test-pod', }, spec: { selector: { matchLabels: { app: 'dapi-test-pod', …
Uladzislau Kaminski
  • 2,113
  • 2
  • 14
  • 33
1
vote
1 answer

how to reference object properties and the object itself in Jsonnet

I am trying to build an object like following in Jsonnet, but I couldn't work out a way to present it in Jsonnet. "properties" :{ "a" : "value for a", "b" : "value for b", ... "nested" : { "a" : "value for a", "b" : "value for b", …
Ali
  • 1,759
  • 2
  • 32
  • 69
1
vote
1 answer

No such file or directory error while running jsonnet with grafonnet-lib

I have cloned grafonnet-lib from https://github.com/grafana/grafonnet-lib link and created a sample jsonnet file to convert it to json that grafana can read. But when I run the command "jsonnet -J /Data/Perf_Tool/grafonnet-lib/ sample.jsonnet" I get…
Vinod JV
  • 13
  • 3
1
vote
1 answer

Why does jsonnet python package use the name _jsonnet?

The Python Api for Jsonnet uses import _jsonnet Why is that? Why was it preferred over import jsonnet ?
Panda
  • 329
  • 3
  • 14
1
vote
1 answer

JSONNET Get the position of an element in an array

I'm using jsonnet to configure my panels in Grafana. I'm using itfor the first time and I like it a lot. However, I'm having a hard time understanding certain aspects. I have something similar to the following: .addTemplate( template.new( …
Hugo L.M
  • 1,053
  • 17
  • 31
1
vote
1 answer

Make changes to json string using jsonnet

I want to change namespace in alok-pod.json in the below json using jsonnet. { "apiVersion": "v1", "items": [ { "apiVersion": "v1", "data": { "alok-pod.json": "{\n \"namespace\": \"alok\",\n …
Alok Kumar Singh
  • 2,331
  • 3
  • 18
  • 37
1
vote
1 answer

How can I UNION two arrays in JSONNET?

If I have two arrays, for example, local array1 = [0,6,12]; local array2 = std.range(10,15); and I want an array [0,6,10,11,12,13,14,15] (not concerned specifically about ordering of the elements, just don't want duplicates) How can I perform this…
JustinJDavies
  • 2,663
  • 4
  • 30
  • 52
1
vote
2 answers

jsonnet - remove null values from array

I want to remove empty values and duplicates from an array, duplicate values are getting removed, empty isn't template: local sub = [ "", "one", "two", "two", ""]; { env: std.prune(std.uniq(std.sort(sub))) } output: { "env": [ "", …
Deepak Deore
  • 284
  • 3
  • 12
1
vote
2 answers

Remove duplicates from an array of objects in jsonnet

I have an array of objects, I would like to remove duplicates. My array has a common field name that I would like to use for deduplication. I am trying to convert the array to a map and then from map back to array but map conversions gives me an…
Aleš
  • 8,896
  • 8
  • 62
  • 107
1
vote
2 answers

Can jsonnet use shell?

I'd like to write code like below in jsonnet. Can jsonnet support this? local region = `curl http://100.100.100.200/latest/metadata/region_id` the region variable should be the output of executing curl…
che yang
  • 395
  • 3
  • 18
0
votes
0 answers

Exception when importing files from jsonnet

I have a case in jsonnet where i want to import a file if it exists, otherwise i want to provide a default value. My dream scenario would be to do something like this: local file = import "file"; { content: if file == null then "default" else…
0
votes
0 answers

Adding external variables to sjsonnet

I am new to using Jsonnet and I am trying to create a configuration file using sjsonnet by DataBricks in a Java codebase. The README on their Github Repo explains how to use Jsonnet without external variables, which is as follows: //…
Anuran Roy
  • 1
  • 1
  • 3