Skip to content

Commit

Permalink
Merge pull request #140 from envato/fix-bug-with-hyphens-in-services
Browse files Browse the repository at this point in the history
Fix bug with hyphens in service names
  • Loading branch information
toolmantim authored May 17, 2018
2 parents 7960b83 + a0c29e1 commit 9dbf37b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/push.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ compose_image_for_service() {
local image=""

image=$(run_docker_compose config \
| grep -E "^( \\w+:| image:)" \
| grep -E "^( [_[:alnum:]-]+:| image:)" \
| grep -E "( ${service}:)" -A 1 \
| grep -oE ' image: (.+)' \
| awk '{print $2}')
Expand Down
8 changes: 8 additions & 0 deletions tests/composefiles/docker-compose.config.with.hyphens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3.2'
services:
app:
build: ../..
depends_on:
- foo-db
foo-db:
image: postgres:9.4
14 changes: 13 additions & 1 deletion tests/docker-compose-images.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ load '../lib/push'
unstub docker-compose
}

@test "Image for compose service with a service with hyphens in the name" {
export HIDE_PROMPT=1
stub docker-compose \
"-f docker-compose.yml -p buildkite config : cat $PWD/tests/composefiles/docker-compose.config.with.hyphens.yml"

run compose_image_for_service "app"

assert_success
assert_output "buildkite_app"
unstub docker-compose
}

@test "Image for compose service without an image in config" {
export HIDE_PROMPT=1
stub docker-compose \
Expand All @@ -28,4 +40,4 @@ load '../lib/push'
assert_success
assert_output "buildkite_helper"
unstub docker-compose
}
}

0 comments on commit 9dbf37b

Please sign in to comment.