diff --git a/kubers b/kubers index f2821a5..6d9eee0 100755 --- a/kubers +++ b/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 - printf "$SECRET" } 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)");