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() {
|
function append_to_secret() {
|
||||||
SECRET=$1
|
SECRET=$1
|
||||||
KEY=$2
|
KEY=$2
|
||||||
|
QUIET=$3
|
||||||
VALUE=$(kubectl -n $NAMESPACE get secret $SECRET -o yaml| yq ".data.\"$KEY\"" | base64 -d)
|
VALUE=$(kubectl -n $NAMESPACE get secret $SECRET -o yaml| yq ".data.\"$KEY\"" | base64 -d)
|
||||||
|
SECRET_DATA="test"
|
||||||
if (( $(grep -c . <<<"$VALUE") > 1 )); then
|
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
|
else
|
||||||
SECRET="$KEY: $VALUE"
|
SECRET_DATA="$VALUE"
|
||||||
|
SECRET="$KEY: $SECRET_DATA"
|
||||||
fi
|
fi
|
||||||
|
if [[ $QUIET != "" ]]; then
|
||||||
|
printf "$SECRET_DATA"
|
||||||
|
else
|
||||||
printf "$SECRET"
|
printf "$SECRET"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_help() {
|
function show_help() {
|
||||||
@ -104,7 +112,7 @@ fi
|
|||||||
|
|
||||||
SECRET=()
|
SECRET=()
|
||||||
if [[ $SECRET_ENTRY != "" ]]; then
|
if [[ $SECRET_ENTRY != "" ]]; then
|
||||||
SECRET+=$(append_to_secret $SECRET_NAME $SECRET_ENTRY)
|
SECRET+=$(append_to_secret $SECRET_NAME $SECRET_ENTRY 1)
|
||||||
else
|
else
|
||||||
for SECRET_ENTRY in $(kubectl -n $NAMESPACE get secret $SECRET_NAME -o yaml | yq '.data | keys' | sed -e "s/- //"); do
|
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)");
|
SECRET+=("$(append_to_secret $SECRET_NAME $SECRET_ENTRY)");
|
||||||
|
Loading…
Reference in New Issue
Block a user