Skip to content

Commit

Permalink
Use --filter to target instance (#79)
Browse files Browse the repository at this point in the history
Fixing a bug that was re-introduced with 5.0.0
  • Loading branch information
jacksegal authored Nov 23, 2018
1 parent 271daf0 commit 8ea040c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion gcloud-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,27 @@ getInstanceName()

getDeviceList()
{
echo -e "$(gcloud $OPT_ACCOUNT compute disks list $1 --filter "$FILTER_CLAUSE" --format='value(name,zone,id)' $OPT_PROJECT)"
# echo -e "$(gcloud $OPT_INSTANCE_SERVICE_ACCOUNT compute disks list --filter "users~instances/$1\$ $FILTER_CLAUSE" --format='value(name)')"

local filter=""

# if using remote instances (-r), then no name filter is required
if [ "$REMOTE_CLAUSE" = true ]; then

# check if $FILTER_CLAUSE exists
if [[ ! -z $FILTER_CLAUSE ]]; then
filter="${FILTER_CLAUSE}"
fi
else
# check if $FILTER_CLAUSE exists
if [[ ! -z $FILTER_CLAUSE ]]; then
filter="name:$1 AND ${FILTER_CLAUSE}"
else
filter="name:$1"
fi
fi

echo -e "$(gcloud $OPT_ACCOUNT compute disks list --filter "${filter}" --format='value(name,zone,id)' $OPT_PROJECT)"
}


Expand Down

0 comments on commit 8ea040c

Please sign in to comment.