From 1ffd6dfb30cc6210703d010b980b498f90bdae16 Mon Sep 17 00:00:00 2001 From: Blizter <blizter47@gmail.com> Date: Sun, 24 Oct 2021 09:31:28 -0400 Subject: [PATCH] let example generate --- ...rtmanager-config-template-external.jsonnet | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/examples/alertmanager-config-template-external.jsonnet b/examples/alertmanager-config-template-external.jsonnet index 420c34d5..73b3ee4f 100644 --- a/examples/alertmanager-config-template-external.jsonnet +++ b/examples/alertmanager-config-template-external.jsonnet @@ -1,28 +1,35 @@ local configmap(name, namespace, data) = { - apiVersion: "v1", - kind: "ConfigMap", - metadata : { - name: name, - namespace: namespace, - }, - data: data, - }; + apiVersion: 'v1', + kind: 'ConfigMap', + metadata: { + name: name, + namespace: namespace, + }, + data: data, +}; local kp = - // different libsonnet imported + // different libsonnet imported { - configmap+:: { - 'alert-templates': configmap( - 'alertmanager-alert-template.tmpl', - $._config.namespace, - {"data": importstr 'alertmanager-alert-template.tmpl'}, - ) + values+:: { + common+: { + namespace: 'monitoring', }, - alertmanager+:{ - spec+:{ - # the important field configmaps: - configMaps: ['alert-templates',], # goes to etc/alermanager/configmaps - }, + }, + alertmanager+:: { + alertmanager+: { + spec+: { + // the important field configmaps: + configMaps: ['alert-templates'], // goes to etc/alermanager/configmaps + }, }, -}; + }, + configmap+:: { + 'alert-templates': configmap( + 'alertmanager-alert-template.tmpl', + $.values.common.namespace, // could be $._config.namespace to assign namespace once + { data: importstr 'alertmanager-alert-template.tmpl' }, + ), + }, + }; { [name + '-configmap']: kp.configmap[name] for name in std.objectFields(kp.configmap) } -- GitLab