ansible-collection-prometheus/.github/scripts/lint_arguments_spec.sh
Ben Kochie 100b6e2070
fix: Add test for argument_specs matching (#177)
* fix: Add test for argument_specs matching

Compare contents of `meta/arguments_spec.yml` against `defaults/main.yml` on
each role to make sure keys match.

Signed-off-by: SuperQ <superq@gmail.com>

* Fixup arguments_spec linting issues.

Signed-off-by: SuperQ <superq@gmail.com>

---------

Signed-off-by: SuperQ <superq@gmail.com>
2023-08-16 17:49:02 +02:00

22 lines
510 B
Bash
Executable file

#!/usr/bin/env bash
#
# Description: Lint the defaults/main.yml against the meta/arguments_spec.yml
lint_diff() {
diff -u \
<(yq 'keys | .[]' "${role}/defaults/main.yml" | sort -u) \
<(yq '.argument_specs.main.options | keys | .[] ' "${role}/meta/argument_specs.yml" | sort -u)
return $?
}
error=0
for role in roles/* ; do
echo "Checking ${role}"
if ! lint_diff ; then
echo "ERROR: ${role}: meta/argument_specs.yml doesn't match defaults/main.yml"
error=1
fi
done
exit "${error}"