Skip to content

Commit

Permalink
Merge pull request #3 from buildkite-plugins/support-comma-delimited-…
Browse files Browse the repository at this point in the history
…account-ids

Support comma delimited account id's
  • Loading branch information
lox authored Jul 12, 2017
2 parents 9b74a3f + ffd815e commit 945ad8f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .buildkite/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ steps:
- wait
- label: check login happens correctly
command: grep 005820773040 ~/.docker/config.json
command: grep 032379705303 ~/.docker/config.json
plugins:
${BUILDKITE_REPO}#${commit}:
login: "true"
account-ids: "005820773040"
account-ids: "032379705303"
YAML
2 changes: 1 addition & 1 deletion hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi

# For logging into the current AWS account’s registry
if [[ "${BUILDKITE_PLUGIN_ECR_LOGIN:-}" =~ ^(true|1)$ ]] ; then
registry_ids=( $(plugin_read_list ACCOUNT_IDS) )
registry_ids=( $(plugin_read_list ACCOUNT_IDS | tr "," "\n") )
login_args=()

if [[ ${#registry_ids[@]} -gt 0 ]] ; then
Expand Down
15 changes: 15 additions & 0 deletions tests/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,20 @@ load '/usr/local/lib/bats/load.bash'
assert_success
assert_output --partial "logging in to docker"

unstub aws
}

@test "Login to ECR with Comma-delimited Account IDS" {
export BUILDKITE_PLUGIN_ECR_LOGIN=true
export BUILDKITE_PLUGIN_ECR_ACCOUNT_IDS="1111,2222,3333"

stub aws \
"ecr get-login --registry-ids 1111 2222 3333 : echo echo logging in to docker"

run $PWD/hooks/pre-command

assert_success
assert_output --partial "logging in to docker"

unstub aws
}

0 comments on commit 945ad8f

Please sign in to comment.