Skip to content

Commit

Permalink
Support use aliases so network aliases can be used with the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
snmaynard committed Dec 13, 2018
1 parent ec3cc22 commit 215d1fc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands/run.sh
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions plugin.yml
Expand Up @@ -47,6 +47,8 @@ configuration:
type: boolean
no-cache:
type: boolean
use-aliases:
type: boolean
tty:
type: boolean
dependencies:
Expand Down Expand Up @@ -77,6 +79,7 @@ configuration:
volumes: [ run ]
leave-volumes: [ run ]
no-cache: [ build ]
use-aliases: [ run ]
dependencies: [ run ]
ansi: [ run ]
tty: [ run ]
Expand Down
25 changes: 25 additions & 0 deletions tests/run.bats
Expand Up @@ -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
Expand Down

0 comments on commit 215d1fc

Please sign in to comment.