mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-27 12:38:11 +00:00
Merge pull request #501 from kencochrane/cloud-clean
Added ability to make ami-clean-mount to clean up AMI volume mount
This commit is contained in:
commit
2ca2b399be
@ -51,6 +51,9 @@ ami: common
|
|||||||
docker-compose run --rm -T ami clean
|
docker-compose run --rm -T ami clean
|
||||||
docker-compose run --rm -T ami bake
|
docker-compose run --rm -T ami bake
|
||||||
|
|
||||||
|
ami-clean-mount: common
|
||||||
|
docker-compose run --rm -T ami clean-mount
|
||||||
|
|
||||||
azure: common
|
azure: common
|
||||||
docker-compose build azure
|
docker-compose build azure
|
||||||
docker-compose run --rm -T azure makeraw
|
docker-compose run --rm -T azure makeraw
|
||||||
|
@ -76,13 +76,8 @@ bake_image()
|
|||||||
echo "${IMAGE_ID}" >"${MOBY_SRC_ROOT}/cloud/aws/ami_id.out"
|
echo "${IMAGE_ID}" >"${MOBY_SRC_ROOT}/cloud/aws/ami_id.out"
|
||||||
}
|
}
|
||||||
|
|
||||||
clean_tagged_resources()
|
clean_volume_mount()
|
||||||
{
|
{
|
||||||
if [ -d "${MOBY_SRC_ROOT}/moby" ]
|
|
||||||
then
|
|
||||||
rm -rf "${MOBY_SRC_ROOT}/moby"
|
|
||||||
fi
|
|
||||||
|
|
||||||
VOLUME_ID=$(aws ec2 describe-volumes --filters "Name=tag-key,Values=$1" | jq -r .Volumes[0].VolumeId)
|
VOLUME_ID=$(aws ec2 describe-volumes --filters "Name=tag-key,Values=$1" | jq -r .Volumes[0].VolumeId)
|
||||||
if [ ${VOLUME_ID} = "null" ]
|
if [ ${VOLUME_ID} = "null" ]
|
||||||
then
|
then
|
||||||
@ -94,6 +89,16 @@ clean_tagged_resources()
|
|||||||
arrowecho "Deleting volume"
|
arrowecho "Deleting volume"
|
||||||
aws ec2 delete-volume --volume-id ${VOLUME_ID} >/dev/null
|
aws ec2 delete-volume --volume-id ${VOLUME_ID} >/dev/null
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_tagged_resources()
|
||||||
|
{
|
||||||
|
if [ -d "${MOBY_SRC_ROOT}/moby" ]
|
||||||
|
then
|
||||||
|
rm -rf "${MOBY_SRC_ROOT}/moby"
|
||||||
|
fi
|
||||||
|
|
||||||
|
clean_volume_mount $1
|
||||||
|
|
||||||
IMAGE_ID=$(aws ec2 describe-images --filters "Name=tag-key,Values=$1" | jq -r .Images[0].ImageId)
|
IMAGE_ID=$(aws ec2 describe-images --filters "Name=tag-key,Values=$1" | jq -r .Images[0].ImageId)
|
||||||
if [ ${IMAGE_ID} = "null" ]
|
if [ ${IMAGE_ID} = "null" ]
|
||||||
@ -129,6 +134,9 @@ case "$1" in
|
|||||||
arrowecho "Cleaning resources from current build tag if applicable..."
|
arrowecho "Cleaning resources from current build tag if applicable..."
|
||||||
clean_tagged_resources "${TAG_KEY}"
|
clean_tagged_resources "${TAG_KEY}"
|
||||||
;;
|
;;
|
||||||
|
clean-mount)
|
||||||
|
clean_volume_mount "${TAG_KEY}"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Command $1 not found. Usage: ./bake-ami.sh [bake|clean]"
|
echo "Command $1 not found. Usage: ./bake-ami.sh [bake|clean|clean-mount]"
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user