Fix: adopted volume list parsing for docker CLI.
All checks were successful
Build Docker Image / build (push) Successful in 11s
All checks were successful
Build Docker Image / build (push) Successful in 11s
This commit is contained in:
16
azure-cli
16
azure-cli
@@ -80,13 +80,25 @@ fi
|
|||||||
|
|
||||||
if [ -n "$LIST" ]; then
|
if [ -n "$LIST" ]; then
|
||||||
echo "Available accounts:"
|
echo "Available accounts:"
|
||||||
$CMD volume ls --format json | jq -r '.[] | select(.labels | has("account")) | .labels.account'
|
# Unfortunately 'container' and 'docker' CLIs are not compatible
|
||||||
|
if [ "container" = "$CMD" ]; then
|
||||||
|
$CMD volume ls --format json | jq -r '.[] | select(.labels | has("account")) | .labels.account'
|
||||||
|
else
|
||||||
|
# Docker has settled to provide labels as one string, that's inconvinient
|
||||||
|
$CMD volume ls --format=json | jq -sr '.[] | .Account = (.Labels | match("account=([a-zA-Z0-9._%@+-]+)"; "x") | .captures[0].string) | .Account'
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "container" = "$CMD" ]; then
|
||||||
|
_FOUND="$($CMD volume ls --format json | jq -r --arg name "$VOLUME_NAME" --arg account "$ACCOUNT_NAME" '.[] | select(.name == $name or .labels.account == $account) | "FOUND"')"
|
||||||
|
else
|
||||||
|
_FOUND="$($CMD volume ls --format=json | jq -sr --arg name "$VOLUME_NAME" --arg account "$ACCOUNT_NAME" '.[] | .Account = (.Labels | match("account=([a-zA-Z0-9._%@+-]+)"; "x") // {} | .captures[0].string) | select(.Name == $name or .Account == $account) | "FOUND"')"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check, if the account volume exists, if not create it
|
# Check, if the account volume exists, if not create it
|
||||||
# This ensures persistent storage for the Azure CLI configuration
|
# This ensures persistent storage for the Azure CLI configuration
|
||||||
if [ ! "FOUND" = "$($CMD volume ls --format json | jq -r --arg name "$VOLUME_NAME" --arg account "$ACCOUNT_NAME" '.[] | select(.name == $name or .labels.account == $account) | "FOUND"')" ]; then
|
if [ ! "FOUND" = "$_FOUND" ]; then
|
||||||
echo "A volume for account '$ACCOUNT_NAME' does not exist."
|
echo "A volume for account '$ACCOUNT_NAME' does not exist."
|
||||||
read -p "Would you like to create one? (y/n) " -r RESPONSE
|
read -p "Would you like to create one? (y/n) " -r RESPONSE
|
||||||
if [[ ! "$RESPONSE" =~ ^[Yy]$ ]]; then
|
if [[ ! "$RESPONSE" =~ ^[Yy]$ ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user