Skip to content

Commit 8ea040c

Browse files
authored
Use --filter to target instance (#79)
Fixing a bug that was re-introduced with 5.0.0
1 parent 271daf0 commit 8ea040c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

gcloud-snapshot.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,27 @@ getInstanceName()
167167

168168
getDeviceList()
169169
{
170-
echo -e "$(gcloud $OPT_ACCOUNT compute disks list $1 --filter "$FILTER_CLAUSE" --format='value(name,zone,id)' $OPT_PROJECT)"
170+
# echo -e "$(gcloud $OPT_INSTANCE_SERVICE_ACCOUNT compute disks list --filter "users~instances/$1\$ $FILTER_CLAUSE" --format='value(name)')"
171+
172+
local filter=""
173+
174+
# if using remote instances (-r), then no name filter is required
175+
if [ "$REMOTE_CLAUSE" = true ]; then
176+
177+
# check if $FILTER_CLAUSE exists
178+
if [[ ! -z $FILTER_CLAUSE ]]; then
179+
filter="${FILTER_CLAUSE}"
180+
fi
181+
else
182+
# check if $FILTER_CLAUSE exists
183+
if [[ ! -z $FILTER_CLAUSE ]]; then
184+
filter="name:$1 AND ${FILTER_CLAUSE}"
185+
else
186+
filter="name:$1"
187+
fi
188+
fi
189+
190+
echo -e "$(gcloud $OPT_ACCOUNT compute disks list --filter "${filter}" --format='value(name,zone,id)' $OPT_PROJECT)"
171191
}
172192

173193

0 commit comments

Comments
 (0)