fix: empty field if secret exists without field

This commit is contained in:
ange 2024-06-05 11:43:54 +02:00
parent d645f3f7ff
commit bf464fb09c
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D

View File

@ -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"
}