fix: empty field if secret exists without field
This commit is contained in:
parent
d645f3f7ff
commit
bf464fb09c
@ -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"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user