-
Notifications
You must be signed in to change notification settings - Fork 26
Feat: Set Task Definitions to Inactive #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,3 +53,33 @@ function prefix_read_list_into_result() { | |
| function plugin_read_list_into_result() { | ||
| prefix_read_list_into_result "BUILDKITE_PLUGIN_${PLUGIN_PREFIX}_${1}" | ||
| } | ||
|
|
||
| # Deregisters task definitions that are not the current one | ||
| deregister_old_task_definitions() { | ||
| local task_family=$1 | ||
| local task_revision=$2 | ||
|
|
||
| echo "--- :ecs: Fetching old task definitions to de-register" | ||
| echo "$task_family" | ||
| # Fetch all `ACTIVE` task definitions for the family | ||
| all_active_task_defs=$(aws ecs list-task-definitions \ | ||
| --family-prefix "${task_family}" \ | ||
| --query 'taskDefinitionArns[]' \ | ||
| --output text) | ||
|
Comment on lines
+65
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure to re-use the default options to aws commands like it is done on the hook file because it may include regions without which the commands will probably fail |
||
|
|
||
| # Array | ||
| readarray -t active_task_defs <<<"$all_active_task_defs" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
|
|
||
| # Remove the current task definition from the list | ||
| for i in "${!active_task_defs[@]}"; do | ||
| if [[ "${active_task_defs[$i]}" == *":${task_revision}"* ]]; then | ||
| unset 'active_task_defs[$i]' | ||
| fi | ||
| done | ||
|
Comment on lines
+73
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looping through all active definitions to remove a single element may be a bad idea... I'd suggest doing this check in the next loop while removing them |
||
|
|
||
| # De-register the old task definitions | ||
| for task_def in "${active_task_defs[@]}"; do | ||
| echo "Deregistering $task_def" | ||
| aws ecs deregister-task-definition --task-definition "$task_def" | ||
| done | ||
|
Comment on lines
+81
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure to re-use the default options to aws commands like it is done on the hook file because it may include regions without which the commands will probably fail |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is for plugin-specific functionality, I'd suggest creating the function in the main file or creating a new library file for these kind of things