Skip to content

Commit

Permalink
ci: add storage account cleanup to VHD pipeline (Azure#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon authored and Justin Hackett committed Mar 14, 2019
1 parent 3088ecc commit b537a6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .pipelines/vhd-builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ phases:
-e VHD_NAME=${VHD_NAME} \
${DEIS_GO_DEV_IMAGE} make az-copy
displayName: Copying resource to Classic Storage Account
condition: not(variables.DRY_RUN)
- script: |
SA_NAME="$(cat packer-output | grep "storage name:" | cut -d " " -f 3)" && \
docker run --rm \
-v ${PWD}:/go/src/github.com/Azure/aks-engine \
-w /go/src/github.com/Azure/aks-engine \
-e CLIENT_ID=${CLIENT_ID} \
-e CLIENT_SECRET="$(CLIENT_SECRET)" \
-e TENANT_ID=${TENANT_ID} \
-e SA_NAME=${SA_NAME} \
-e AZURE_RESOURCE_GROUP_NAME=${AZURE_RESOURCE_GROUP_NAME} \
${DEIS_GO_DEV_IMAGE} make delete-sa
displayName: Clean-up Storage Account
- script: |
docker run --rm \
-v ${PWD}:/go/src/github.com/Azure/aks-engine \
Expand Down
5 changes: 4 additions & 1 deletion packer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ az-login:
az login --service-principal -u ${CLIENT_ID} -p ${CLIENT_SECRET} --tenant ${TENANT_ID}

run-packer: az-login
@packer version && $(MAKE) init-packer && ($(MAKE) build-packer | tee packer-output)
@packer version && $(MAKE) init-packer | tee packer-output && ($(MAKE) build-packer | tee -a packer-output)

az-copy: az-login
azcopy --source "${OS_DISK_SAS}" --destination "${CLASSIC_BLOB}/${VHD_NAME}" --dest-sas "${CLASSIC_SAS_TOKEN}"

delete-sa: az-login
az storage account delete -n ${SA_NAME} -g ${AZURE_RESOURCE_GROUP_NAME} --yes

generate-sas: az-login
az storage container generate-sas --name vhds --permissions lr --connection-string "${CLASSIC_SA_CONNECTION_STRING}" --start ${START_DATE} --expiry ${EXPIRY_DATE} | tr -d '"' | tee -a vhd-sas && cat vhd-sas

0 comments on commit b537a6a

Please sign in to comment.