From 686e4f0f2d498ee39a69e43f7535171f16f5fcbc Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Thu, 15 Apr 2021 15:01:38 +0200 Subject: [PATCH] [type/__postgres_conf] Reverse state logic (decide based on source first) --- .../conf/type/__postgres_conf/explorer/state | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/cdist/conf/type/__postgres_conf/explorer/state b/cdist/conf/type/__postgres_conf/explorer/state index e76540c5..4b7b0a43 100644 --- a/cdist/conf/type/__postgres_conf/explorer/state +++ b/cdist/conf/type/__postgres_conf/explorer/state @@ -200,23 +200,24 @@ psql_exec 'SELECT 1' >/dev/null || { exit 1 } -if psql_conf_cmp "${conf_name}" "$(cat "${__object:?}/parameter/value")" -then - echo present -else - case $(psql_conf_source "${conf_name}") - in - ('') - # invalid configuration parameter - # (error message was already printed by SHOW command above. - # Yes, it's a hack) - exit 1 - ;; - (default) - echo absent - ;; - (*) +case $(psql_conf_source "${conf_name}") +in + ('') + printf 'Invalid configuration parameter: %s\n' "${conf_name}" >&2 + exit 1 + ;; + (default) + echo absent + ;; + (*) + if ! test -f "${__object:?}/parameter/value" + then + echo present + elif psql_conf_cmp "${conf_name}" "$(cat "${__object:?}/parameter/value")" + then + echo present + else echo different - ;; - esac -fi + fi + ;; +esac