From f2891703a54ca0f4b518c77bfd4dbe0df056a6bb Mon Sep 17 00:00:00 2001 From: beorn7 Date: Sat, 6 Jul 2019 20:21:56 +0200 Subject: [PATCH] Add Makefile to easily make output files and lint sources Signed-off-by: beorn7 --- docs/node-mixin/.gitignore | 7 ++++--- docs/node-mixin/Makefile | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 docs/node-mixin/Makefile diff --git a/docs/node-mixin/.gitignore b/docs/node-mixin/.gitignore index 65d141bd..522b99f0 100644 --- a/docs/node-mixin/.gitignore +++ b/docs/node-mixin/.gitignore @@ -1,3 +1,4 @@ -/jsonnetfile.lock.json -/vendor/ - +jsonnetfile.lock.json +vendor +*.yaml +dashboards_out diff --git a/docs/node-mixin/Makefile b/docs/node-mixin/Makefile new file mode 100644 index 00000000..012a4b50 --- /dev/null +++ b/docs/node-mixin/Makefile @@ -0,0 +1,28 @@ +JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s + +all: fmt node_alerts.yaml node_rules.yaml dashboards_out lint + +fmt: + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + xargs -n 1 -- $(JSONNET_FMT) -i + +node_alerts.yaml: mixin.libsonnet config.libsonnet $(wildcard alerts/*) + jsonnet -S alerts.jsonnet > $@ + +node_rules.yaml: mixin.libsonnet config.libsonnet $(wildcard rules/*) + jsonnet -S rules.jsonnet > $@ + +dashboards_out: mixin.libsonnet config.libsonnet $(wildcard dashboards/*) + @mkdir -p dashboards_out + jsonnet -J vendor -m dashboards_out dashboards.jsonnet + +lint: node_alerts.yaml node_rules.yaml + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + while read f; do \ + $(JSONNET_FMT) "$$f" | diff -u "$$f" -; \ + done + + promtool check rules node_alerts.yaml node_rules.yaml + +clean: + rm -rf dashboards_out node_alerts.yaml node_rules.yaml