ceph-mixin: fix ceph-mixin setup

Made following changes to files,

Makefile:
    Add needed 'tox' target to generate alert files
    Now we can do 'make generate' OR 'make test'
    to generate all the yaml files (and run tests)

alerts.jsonnet:
    Added an 'import' line to include 'config.libsonnet' file.
    This fix the errors in generating 'prometheus_alerts.yml' file

tox.ini:
    Added all the existing 'alerts-' targets to 'envlist'
    Added the missing 'alerts-test' target to 'testenv'
    Added 'jsonnet' to 'allowlist_externals', which prevents a
    deprecation waring
    A minor spell correction

lint-jsonnet.sh:
    Made errors more verbose.

Signed-off-by: Arun Kumar Mohan <amohan@redhat.com>
This commit is contained in:
Arun Kumar Mohan 2023-04-02 07:58:16 +05:30
parent 985173419b
commit 86d040e2fc
4 changed files with 19 additions and 7 deletions

View File

@ -4,6 +4,7 @@ fmt:
./lint-jsonnet.sh -i
generate: dashboards_out
tox -ealerts-fix
vendor: jsonnetfile.lock.json
tox -ejsonnet-bundler-install
@ -18,7 +19,7 @@ lint:
test: generate
tox -ejsonnet-check
tox -epromql-query-test
tox -ealerts-check
tox -ealerts-test
check: test
.PHONY: all fmt generate lint test check

View File

@ -1 +1 @@
std.manifestYamlDoc((import 'alerts.libsonnet').prometheusAlerts, indent_array_in_object=true, quote_keys=false)
std.manifestYamlDoc(((import 'config.libsonnet') + (import 'alerts.libsonnet')).prometheusAlerts, indent_array_in_object=true, quote_keys=false)

View File

@ -1,5 +1,14 @@
#!/bin/sh -e
JSONNETS_FILES=$(find . -name 'vendor' -prune -o \
-name '*.jsonnet' -print -o -name '*.libsonnet' -print)
jsonnetfmt "$@" ${JSONNETS_FILES}
-name '*.jsonnet' -print -o -name '*.libsonnet' -print)
for each_jsonnet_file in ${JSONNETS_FILES}; do
jsonnetfmt "$@" ${each_jsonnet_file} || jfmt_failed_files="$jfmt_failed_files ${each_jsonnet_file}"
done
exit_status=0
# if variable 'jfmt_failed_files' is not empty/null
if [ -n "${jfmt_failed_files}" ]; then
echo "'jsonnetfmt' check failed on:${jfmt_failed_files}"
exit_status=1
fi
exit $exit_status

View File

@ -4,7 +4,8 @@ envlist =
jsonnet-{check,lint,fix},
jsonnet-bundler-{install,update},
promql-query-{test,lint},
alerts-check
alerts-{fix,check,lint,test}
skipsdist = true
[testenv:jsonnet-bundler-{install,update}]
@ -23,7 +24,7 @@ allowlist_externals =
find
jb
jsonnet
jsonnetfm
jsonnetfmt
sh
description =
check: Ensure that auto-generated files matches the current version
@ -61,13 +62,14 @@ allowlist_externals =
commands =
behave tests_dashboards/features
[testenv:alerts-{fix,check,lint}]
[testenv:alerts-{fix,check,lint,test}]
deps =
-rrequirements-alerts.txt
pytest
depends = grafonnet-check
allowlist_externals =
promtool
jsonnet
commands =
fix: jsonnet -J vendor -S alerts.jsonnet -o prometheus_alerts.yml
lint: promtool check rules prometheus_alerts.yml