When a secret entry is provided, print only value
This commit is contained in:
parent
011ee485aa
commit
2914c5f444
14
kubers
14
kubers
@ -11,13 +11,21 @@ KUBERS_VERSION=0.1.0
|
||||
function append_to_secret() {
|
||||
SECRET=$1
|
||||
KEY=$2
|
||||
QUIET=$3
|
||||
VALUE=$(kubectl -n $NAMESPACE get secret $SECRET -o yaml| yq ".data.\"$KEY\"" | base64 -d)
|
||||
SECRET_DATA="test"
|
||||
if (( $(grep -c . <<<"$VALUE") > 1 )); then
|
||||
SECRET="$KEY: |-\n$(echo $VALUE| sed -e 's/^/ /')"
|
||||
SECRET_DATA="|-\n$(echo $VALUE| sed -e 's/^/ /')"
|
||||
SECRET="$KEY: $SECRET_DATA"
|
||||
else
|
||||
SECRET="$KEY: $VALUE"
|
||||
SECRET_DATA="$VALUE"
|
||||
SECRET="$KEY: $SECRET_DATA"
|
||||
fi
|
||||
if [[ $QUIET != "" ]]; then
|
||||
printf "$SECRET_DATA"
|
||||
else
|
||||
printf "$SECRET"
|
||||
fi
|
||||
}
|
||||
|
||||
function show_help() {
|
||||
@ -104,7 +112,7 @@ fi
|
||||
|
||||
SECRET=()
|
||||
if [[ $SECRET_ENTRY != "" ]]; then
|
||||
SECRET+=$(append_to_secret $SECRET_NAME $SECRET_ENTRY)
|
||||
SECRET+=$(append_to_secret $SECRET_NAME $SECRET_ENTRY 1)
|
||||
else
|
||||
for SECRET_ENTRY in $(kubectl -n $NAMESPACE get secret $SECRET_NAME -o yaml | yq '.data | keys' | sed -e "s/- //"); do
|
||||
SECRET+=("$(append_to_secret $SECRET_NAME $SECRET_ENTRY)");
|
||||
|
Loading…
Reference in New Issue
Block a user