Skip to content

Commit

Permalink
fix(publish): Delete existing VM images when rebaking (#1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander committed Apr 21, 2017
1 parent 422eacb commit d8d6556
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dev/build_google_image_functions.sh
Expand Up @@ -99,6 +99,8 @@ function image_from_prototype_disk() {
local target_image="$1"
local prototype_disk="$2"

delete_image_if_exists $target_image

echo "`date`: Creating image '$target_image' in project '$PROJECT'"
if [[ $prototype_disk = gs://*.tar.gz ]]; then
echo "Creating from URI $prototype_disk"
Expand All @@ -117,6 +119,25 @@ function image_from_prototype_disk() {
}


function delete_image_if_exists() {
local target_image="$1"

gcloud compute images describe $target_image \
--project $PROJECT \
--account $ACCOUNT &> /dev/null

if [[ $? ]]; then
echo "`date`: Image '$target_image' does not exist yet"
else
echo "`date`: Deleting preexisting '$target_image' in '$PROJECT'"
gcloud compute images delete $target_image \
--project $PROJECT \
--account $ACCOUNT \
--quiet
fi
}


function delete_build_instance() {
echo "`date`: Cleaning up prototype instance '$PROTOTYPE_INSTANCE'"
gcloud compute instances delete $PROTOTYPE_INSTANCE \
Expand Down

0 comments on commit d8d6556

Please sign in to comment.