Skip to content

Commit

Permalink
Merge pull request #89 from sophiewigmore/delete-deployments
Browse files Browse the repository at this point in the history
Add task to delete all bosh deployments

[finishes #164839949](https://www.pivotaltracker.com/story/show/164839949)

Co-authored-by: Dave Walter <dwalter@pivotal.io>
  • Loading branch information
cdutra and davewalter authored Apr 25, 2019
2 parents 3e657d7 + af773d4 commit ff096f7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ running out of space.

### [bosh-delete-deployment][bosh-delete-deployment-task-yaml]
This deletes a BOSH deployment.
If you want to delete all of the available BOSH deployments you can set the `DELETE_ALL_DEPLOYMENTS` flag to `true`.

### [bosh-deploy][bosh-deploy-task-yaml]
This performs a BOSH upload-stemcell and BOSH deployment.
Expand Down
23 changes: 21 additions & 2 deletions bosh-delete-deployment/task
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ set -exu
# shellcheck disable=SC1091
source cf-deployment-concourse-tasks/shared-functions

function bosh_delete_all_deployments() {
local deployments
deployments=$(bosh deployments --json | jq -r '.Tables[].Rows[].name')

for deployment in ${deployments}; do
if [ -n "${deployment}" ]; then
echo "Deleting deployment: ${deployment}"
bosh \
-n \
delete-deployment -d "${deployment}" \
${force_flag}
fi
done
}

function check_delete_deployment_params() {
if [ -z "$DEPLOYMENT_NAME" ]; then
echo "DEPLOYMENT_NAME has not been set"
Expand All @@ -25,9 +40,13 @@ function bosh_delete_deployment() {
}

function main() {
check_delete_deployment_params
setup_bosh_env_vars
bosh_delete_deployment
if [ "$DELETE_ALL_DEPLOYMENTS" = true ]; then
bosh_delete_all_deployments
else
check_delete_deployment_params
bosh_delete_deployment
fi
}

main
4 changes: 4 additions & 0 deletions bosh-delete-deployment/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ params:
# - If blank or '.', uses `bbl-state` input as the location for bbl state
# - If the specified path does not exist, it will be created

DELETE_ALL_DEPLOYMENTS: false
# - Optional
# - When true, deletes ALL BOSH deployments

DEPLOYMENT_NAME: cf

IGNORE_ERRORS: false
Expand Down

0 comments on commit ff096f7

Please sign in to comment.