From 09e83fc5a9ab83d0ebe10c96b5fb1104b581402d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 21 Jul 2022 16:15:21 +0200 Subject: [PATCH] TT#177550 check: Refactor config YAML file validation into a function This way we can reuse to validate other YAML files. Change-Id: I2e6587e16a3176cba349f6260df1769d4312c619 --- scripts/check | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/check b/scripts/check index 56a842b4..f498bdf9 100755 --- a/scripts/check +++ b/scripts/check @@ -90,6 +90,19 @@ check_origin() { fi } +check_yaml() { + local schema="$1" + local config="$2" + + if ! pkwalify -s -m 'YAML::XS' -f "${schema}" "${config}" >/dev/null 2>&1 ; then + log_error "Invalid schema detected for ${config}" + pkwalify -m 'YAML::XS' -f "${schema}" "${config}" >&2 || true + return 1 + fi + + return 0 +} + check_multi_site() { log_debug "Checking multi-site support" if ! command -v ngcp-site >/dev/null; then @@ -178,9 +191,7 @@ validate_config() { ;; esac - if ! pkwalify -s -m 'YAML::XS' -f "${schema}" "$c" >/dev/null 2>&1 ; then - log_error "Invalid schema detected for $c" - pkwalify -m 'YAML::XS' -f "${schema}" "$c" >&2 || true + if ! check_yaml "${schema}" "$c"; then rc=1 fi if ${c_cleanup}; then