De Wiki Clusterlab.com.br
Ir para navegação
Ir para pesquisar
#!/bin/bash
function KEYVAULT_SECRET_FIND() { cat $1 | jq -r '.[]|.name' | grep -i $2 | while read KEY; do cat $1 | jq -r '.[]|select(.name=="'$KEY'")' ;done ; }
function HELP() { echo """
EXAMPLE:
$0 <SUBSCRIPTION> <VAULT> <SECRET FILE> <SECRET NAME>
"""; exit 1; }
if [ $# -ne 4 ]
then
HELP
else
export SUB=$1
export VAULT=$2
export DATA=$3
export SECRET=$4
echo KEYVAULT_SECRET_SET \
$SUB \
$VAULT \
$SECRET \
\"$(KEYVAULT_SECRET_FIND $DATA $SECRET | jq -r '.secret')\" \
\"$(KEYVAULT_SECRET_FIND $DATA $SECRET | jq -r '.tags|@text' | sed -e 's/{//g' -e 's/}//g' -e 's/\"//g' -e 's/,/;/g' -e 's/:/=/g')\"
fi