Skip to content

Commit

Permalink
support multiple container names
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Trappitt committed Feb 20, 2016
1 parent 3d4a0fc commit 899bccb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ deploy:
cluster: Production-DashboardCluster //base cluster name / wildcard
family: Production-DashboardTaskDefinition //base family name / wildcard
service: Production-DashboardService //base service name / wildcard
constainer_name: dashboard //the name of the container in the definition that uses this image
container_names:
- dashboard //array of conatiner names for each definition
allow_multiple_clusters: false //update services on multiple clusters if matched
allow_multiple_services: false //update multiple services on a clusters if matched
log_level: 'debug' //logging level to output
Expand Down Expand Up @@ -61,10 +62,10 @@ Again a good example is if you have a environment where instead of using differe
####family
The family parameter operates as a wildcard as well, but it is used to match to task definitions. When the plugin matches a cluster and service, it retrieves all the current tasks within that service. From these tasks it derives the currently active task definitions. These are matched / filtered by this setting to determine which task definitions to update.

####constainer_name
The container name is required in order to determine which conatiner within the task definition to update the image name for this build. This setting is intended to accomodate definitions with multiple containers.
####container_names
A list of container names is required in order to determine which containers within the task definition to update the with the new image name for this build. This setting is intended to accomodate definitions with multiple containers.

Note - It is a non-case sensitive exact match on the name. It does not support wildcards.
Note - It is a non-case sensitive exact match on each name in the array. It does not support wildcards.

####allow_multiple_clusters (optional)
This defaults to false as a safety precuation. If set to true it will allow matched definitions in multiple clusters to be updated at once.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ npm install
(these aren't real aws keys btw)

```
node app.js -- '{"repo":{"clone_url":"git://github.com/drone/drone","owner":"drone","name":"drone","full_name":"drone/drone"},"system":{"link_url":"https://beta.drone.io"},"build":{"number":22,"status":"success","started_at":1421029603,"finished_at":1421029813,"message":"UpdatetheReadme","author":"johnsmith","author_email":"[email protected]","event":"push","branch":"master","commit":"436b7a6e2abaddfd35740527353e78a227ddcb2c","ref":"refs/heads/master"},"workspace":{"root":"/drone/src","path":"/drone/src/github.com/drone/drone"},"vargs":{"build":"","repo":"","access_key":"AKIAGDHD65JEJZU6NA","secret_key":"JHGDjhgsd78678hjgdjgTYRT6467582kjhDkhmF","region":"ap-southeast-2","family":"CoreProduction-DashboardTaskDefinition","cluster":"CoreProduction-ServicesCluster","service":"CoreProduction-DashboardService","constainer_name":"dashboard","allow_multiple_clusters":false,"allow_multiple_services":false,"image_name":"registry.mydomain.com.au/dashboard-development","image_tag":"1.0.1","log_level":"debug","task_definition":null, "desired_count": 2, "deployment_configuration":{"maximum_percent": 200, "minimum_healthy_percent": 0}, "disable_dry_run":false}}'
node app.js -- '{"repo":{"clone_url":"git://github.com/drone/drone","owner":"drone","name":"drone","full_name":"drone/drone"},"system":{"link_url":"https://beta.drone.io"},"build":{"number":22,"status":"success","started_at":1421029603,"finished_at":1421029813,"message":"UpdatetheReadme","author":"johnsmith","author_email":"[email protected]","event":"push","branch":"master","commit":"436b7a6e2abaddfd35740527353e78a227ddcb2c","ref":"refs/heads/master"},"workspace":{"root":"/drone/src","path":"/drone/src/github.com/drone/drone"},"vargs":{"build":"","repo":"","access_key":"AKIAGDHD65JEJZU6NA","secret_key":"JHGDjhgsd78678hjgdjgTYRT6467582kjhDkhmF","region":"ap-southeast-2","family":"CoreProduction-DashboardTaskDefinition","cluster":"CoreProduction-ServicesCluster","service":"CoreProduction-DashboardService","constainer_names":["dashboard"],"allow_multiple_clusters":false,"allow_multiple_services":false,"image_name":"registry.mydomain.com.au/dashboard-development","image_tag":"1.0.1","log_level":"debug","task_definition":null, "desired_count": 2, "deployment_configuration":{"maximum_percent": 200, "minimum_healthy_percent": 0}, "disable_dry_run":false}}'
Friendly version
```
Expand Down Expand Up @@ -68,7 +68,7 @@ Friendly version
"family": "Development-DashboardTaskDefinition",
"cluster": "Development-ServicesCluster",
"service": "Development-DashboardService",
"constainer_name": "dashboard",
"constainer_names": ["dashboard"],
"allow_multiple_clusters": false,
"allow_multiple_services": false,
"image_name": "registry.mydomain.com.au/dashboard-development",
Expand Down
5 changes: 3 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,10 @@ ecsService.prototype = Object.create({
//need to handle multiple containers
//which ones updated.
//need to have the container passed in the vargs
for (var x=0; x<taskDef.containerDefinitions; x++) {
for (var x=0; x<taskDef.containerDefinitions.length; x++) {
var name = taskDef.containerDefinitions[x].name;
if (this.vargs.containerName.indexOf(name.toLowerCase()) != -1) {
if (this.vargs.containerNames.indexOf(name.toLowerCase()) != -1) {
this.logger.info('Updating image for container: ' + name + ' in task definition: ' + taskDef.taskDefinitionArn);
taskDef.containerDefinitions[x].image = this.vargs.imageName + ":" + this.vargs.imageTag
}
}
Expand Down

0 comments on commit 899bccb

Please sign in to comment.