From bf464fb09c74dafa2f03b1c69592d627fda6816c Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 5 Jun 2024 11:43:54 +0200 Subject: [PATCH] fix: empty field if secret exists without field --- manifests/bin/deploy.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/manifests/bin/deploy.sh b/manifests/bin/deploy.sh index 7264461..7b0a5bc 100755 --- a/manifests/bin/deploy.sh +++ b/manifests/bin/deploy.sh @@ -19,15 +19,25 @@ function kcreatecm() { function kgseckey() { local sec="$1"; shift local key="$1"; shift + local ret - kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d + ret="$(kubectl get secret "$sec" -o jsonpath="{.data.$key}" | base64 -d)" + if [ "$?" -eq 0 ] || [ -z "$ret" ]; then + return 1 + fi + echo "$ret" } function kgcmkey() { local cm="$1"; shift local key="$1"; shift + local ret; - kubectl get configmap "$cm" -o jsonpath="{.data.$key}" + ret="$(kubectl get configmap "$cm" -o jsonpath="{.data.$key}")" + if [ "$?" -eq 0 ] || [ -z "$ret" ]; then + return 1 + fi + echo "$ret" }