Skip to content
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

Support comma delimited account id's #3

Merged
merged 2 commits into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}