Code Snippets Jsonnet

Short texts Jsonnet 🧑‍💻 Code snippets Jsonnet ✍️ Reading lists Jsonnet 👀

aws-s3-deny-non-corp.libsonnet

{ // s3DenyNonCorpPolicy encapsulates the policy to deny access to the bucket `bucketName` // to all IPs other than the ones supplied by the `ipAddresses` list s3DenyNonCorpPolicy(bucketName, ipAddresses=[],):: { Version: ‘2012-10-17’, Statement: [ { Sid: ‘SourceIP’, Action: ‘s3:*’, Effect: ‘Deny’, Resource: [ // use jsonnet string format from the standard lib std.format(‘arn:aws:s3:::%s’, bucketName), std.format(‘arn:aws:s3:::%s/*’, bucketName), […]

policy-v1.jsonnet

local lib = import ‘./lib/aws-s3-deny-non-corp.libsonnet’; lib.s3DenyNonCorpPolicy(‘the-bucket’, [ ‘11.11.11.11/32’, ‘22.22.22.22/32’, ])

qbec helm victoriametrics

local p = import ‘../../params.libsonnet’; local params = p.components.victoriametrics; local k = import ‘1.21/main.libsonnet’; local vm = importstr ‘data://victoriametrics/github.com/VictoriaMetrics/helm-charts/raw/347d4558d9c25cd341718bf5a2ee167da042c080/packages/victoria-metrics-cluster-0.9.6.tgz’; { local ns = k.core.v1.namespace, namespace:: ns.new(params.namespace) resources: [ $.namespace, std.native(‘parseYaml’)(vm), ], }.resources { components: { prometheus: { externalLabels: { cluster: std.extVar(‘qbec.io/env’), }, remoteWrite: [{ url: ‘http://vminsert.victoriametrics.svc.cluster.local:8480/insert/0/prometheus/api/v1/write’, }], }, grafana: { prometheusDatasource: { url: ‘vmselect.victoriametrics.svc.cluster.local:8481/select/0/prometheus’, }, […]

qbec helm victoriametrics

local p = import ‘../../params.libsonnet’; local params = p.components.victoriametrics; local k = import ‘1.21/main.libsonnet’; local vm = importstr ‘data://victoriametrics/github.com/VictoriaMetrics/helm-charts/raw/347d4558d9c25cd341718bf5a2ee167da042c080/packages/victoria-metrics-cluster-0.9.6.tgz’; { local ns = k.core.v1.namespace, namespace:: ns.new(params.namespace) resources: [ $.namespace, std.native(‘parseYaml’)(vm), ], }.resources

bench.jsonnet

std.join(‘ + ‘, [std.format(‘{ xs+: [%d] }’, i) for i in std.range(0, 10000)])