Fix multiple compose file secret generation?
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
143b8974d6
commit
992d1dbae2
22
plugin.sh
22
plugin.sh
|
@ -32,16 +32,18 @@ generate_secrets() {
|
|||
chmod +x /usr/bin/yq
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
for SECRET in $(yq r ${PLUGIN_COMPOSE//:/ } 'secrets.*.name'); do
|
||||
echo "$SECRET"
|
||||
SECRET=$(eval echo "$SECRET")
|
||||
if docker -H "$REMOTE_DOCKER_HOST" secret ls | grep -q "$SECRET"; then
|
||||
echo "Skipping existing secret $SECRET"
|
||||
else
|
||||
eval "echo \"generating $SECRET\""
|
||||
PW=$(</dev/urandom tr -dc 'A-Za-z0-9' | head -c 40; echo)
|
||||
eval "echo \"$PW\" | docker -H \"$REMOTE_DOCKER_HOST\" secret create \"$SECRET\" -";
|
||||
fi
|
||||
for COMPOSE_FILE in ${PLUGIN_COMPOSE//:/ }; do
|
||||
for SECRET in $(yq r "$COMPOSE_FILE" 'secrets.*.name'); do
|
||||
echo "$SECRET"
|
||||
SECRET=$(eval echo "$SECRET")
|
||||
if docker -H "$REMOTE_DOCKER_HOST" secret ls | grep -q "$SECRET"; then
|
||||
echo "Skipping existing secret $SECRET"
|
||||
else
|
||||
eval "echo \"generating $SECRET\""
|
||||
PW=$(</dev/urandom tr -dc 'A-Za-z0-9' | head -c 40; echo)
|
||||
eval "echo \"$PW\" | docker -H \"$REMOTE_DOCKER_HOST\" secret create \"$SECRET\" -";
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo "--- end secrets ---"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue