From 215d1fc369e8e6f7ce2668f5cd628547a49779c5 Mon Sep 17 00:00:00 2001 From: Simon Maynard Date: Thu, 13 Dec 2018 20:40:46 +0000 Subject: [PATCH] Support use aliases so network aliases can be used with the plugin --- commands/run.sh | 5 +++++ plugin.yml | 3 +++ tests/run.bats | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/commands/run.sh b/commands/run.sh index f1ef2c80..545d5bea 100755 --- a/commands/run.sh +++ b/commands/run.sh @@ -112,6 +112,11 @@ if [[ "$(plugin_read_config ANSI "true")" == "false" ]] ; then run_params+=(--no-ansi) fi +# Enable alias support for networks +if [[ "$(plugin_read_config USE_ALIASES "false")" == "true" ]] ; then + run_params+=(--use-aliases) +fi + run_params+=("$run_service") if [[ ! -f "$override_file" ]]; then diff --git a/plugin.yml b/plugin.yml index 500681f6..66af9578 100644 --- a/plugin.yml +++ b/plugin.yml @@ -47,6 +47,8 @@ configuration: type: boolean no-cache: type: boolean + use-aliases: + type: boolean tty: type: boolean dependencies: @@ -77,6 +79,7 @@ configuration: volumes: [ run ] leave-volumes: [ run ] no-cache: [ build ] + use-aliases: [ run ] dependencies: [ run ] ansi: [ run ] tty: [ run ] diff --git a/tests/run.bats b/tests/run.bats index 21a9a40d..5f8877a3 100644 --- a/tests/run.bats +++ b/tests/run.bats @@ -338,6 +338,31 @@ export BUILDKITE_JOB_ID=1111 unstub buildkite-agent } +@test "Run with use aliases" { + export BUILDKITE_JOB_ID=1111 + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice + export BUILDKITE_PIPELINE_SLUG=test + export BUILDKITE_BUILD_NUMBER=1 + export BUILDKITE_COMMAND=pwd + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CHECK_LINKED_CONTAINERS=false + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_CLEANUP=false + export BUILDKITE_PLUGIN_DOCKER_COMPOSE_USE_ALIASES=true + + stub docker-compose \ + "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml pull myservice : echo pulled myservice" \ + "-f docker-compose.yml -p buildkite1111 -f docker-compose.buildkite-1-override.yml run --name buildkite1111_myservice_build_1 --use-aliases myservice pwd : echo ran myservice with use aliases output" + + stub buildkite-agent \ + "meta-data get docker-compose-plugin-built-image-tag-myservice : echo myimage" + + run $PWD/hooks/command + + assert_success + assert_output --partial "ran myservice with use aliases output" + unstub docker-compose + unstub buildkite-agent +} + @test "Run with a volumes option" { export BUILDKITE_JOB_ID=1111 export BUILDKITE_PLUGIN_DOCKER_COMPOSE_RUN=myservice