From 28295e8835a0c8ffd5cea299c0e28cc19a81e3e7 Mon Sep 17 00:00:00 2001 From: Patrick Robinson Date: Thu, 17 May 2018 18:16:33 +1000 Subject: [PATCH 1/2] Create a failing test to show the issue of hyphens in service names --- .../docker-compose.config.with.hyphens.yml | 8 ++++++++ tests/docker-compose-images.bats | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/composefiles/docker-compose.config.with.hyphens.yml diff --git a/tests/composefiles/docker-compose.config.with.hyphens.yml b/tests/composefiles/docker-compose.config.with.hyphens.yml new file mode 100644 index 00000000..0031ef87 --- /dev/null +++ b/tests/composefiles/docker-compose.config.with.hyphens.yml @@ -0,0 +1,8 @@ +version: '3.2' +services: + app: + build: ../.. + depends_on: + - foo-db + foo-db: + image: postgres:9.4 diff --git a/tests/docker-compose-images.bats b/tests/docker-compose-images.bats index b5dbc20c..dca55923 100644 --- a/tests/docker-compose-images.bats +++ b/tests/docker-compose-images.bats @@ -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 \ @@ -28,4 +40,4 @@ load '../lib/push' assert_success assert_output "buildkite_helper" unstub docker-compose -} \ No newline at end of file +} From a0c29e19d82e7eb803b4c0300dc45a7fa8d5c031 Mon Sep 17 00:00:00 2001 From: Patrick Robinson Date: Thu, 17 May 2018 18:16:48 +1000 Subject: [PATCH 2/2] Look for words, underscores and hyphens in container names --- lib/push.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/push.bash b/lib/push.bash index 272d2bb5..c557b90f 100644 --- a/lib/push.bash +++ b/lib/push.bash @@ -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}')