From e0416403c4862cb8bc0f41a7c6f8a33d1a8656a5 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Thu, 15 Apr 2021 09:04:07 +0200 Subject: [PATCH] [type/__postgres_conf] Add psql_conf_source function to state explorer --- cdist/conf/type/__postgres_conf/explorer/state | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__postgres_conf/explorer/state b/cdist/conf/type/__postgres_conf/explorer/state index be881be6..9f54724a 100644 --- a/cdist/conf/type/__postgres_conf/explorer/state +++ b/cdist/conf/type/__postgres_conf/explorer/state @@ -27,6 +27,10 @@ psql_exec() { su - "${postgres_user}" -c "psql postgres -twAc $(quote "$*")" } +psql_conf_source() { + # NOTE: SHOW/SET are case-insentitive, so this command should also be. + psql_exec "SELECT CASE WHEN source = 'default' OR setting = boot_val THEN 'default' ELSE source END FROM pg_settings WHERE lower(name) = lower('$1')" +} psql_conf_cmp() { test "$(psql_exec "SHOW $1")" = "$2" } @@ -40,8 +44,7 @@ if psql_conf_cmp "${conf_name}" "$(cat "${__object:?}/parameter/value")" then echo present else - # NOTE: SHOW/SET are case-insentitive, so this command should also be. - case $(psql_exec "SELECT CASE WHEN source = 'default' OR setting = boot_val THEN 'default' ELSE source END FROM pg_settings WHERE lower(name) = lower('${conf_name}')") + case $(psql_conf_source "${conf_name}") in ('') # invalid configuration parameter