From e9618101e5b2642e91fc5f6e20ff4539e418a624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guitaut?= Date: Tue, 15 Sep 2015 23:49:51 +0200 Subject: [PATCH] Display image & version in `list` --- functions | 8 +++++++- tests/bin/docker | 5 +++++ tests/service_list.bats | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 94c0d53..b82ea00 100755 --- a/functions +++ b/functions @@ -56,7 +56,7 @@ service_list() { else dokku_log_info1_quiet "$PLUGIN_SERVICE services:" for SERVICE in $SERVICES; do - dokku_log_verbose "$SERVICE $(service_status "$SERVICE")$(service_exposed_ports "$SERVICE")" + dokku_log_verbose "$SERVICE, $(service_version "$SERVICE") $(service_status "$SERVICE")$(service_exposed_ports "$SERVICE")" done fi } @@ -277,3 +277,9 @@ get_database_name() { # so we need to normalize them out echo "$1" | tr .- _ } + +service_version() { + local SERVICE="$1" + local SERVICE_NAME="$(get_service_name "$SERVICE")" + docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME" +} diff --git a/tests/bin/docker b/tests/bin/docker index a5dc911..5556f66 100755 --- a/tests/bin/docker +++ b/tests/bin/docker @@ -51,6 +51,11 @@ case "$1" in exit 0 fi + if [[ $@ =~ \{\{.Config.Image\}\} ]]; then + echo "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" + exit 0 + fi + if [[ $@ =~ \{\{\.State\..*\}\} ]]; then if [[ $@ =~ \{\{\.State\.Running\}\} ]]; then echo "true" diff --git a/tests/service_list.bats b/tests/service_list.bats index 6b8eeb9..1ff3c6d 100755 --- a/tests/service_list.bats +++ b/tests/service_list.bats @@ -11,13 +11,13 @@ teardown() { @test "($PLUGIN_COMMAND_PREFIX:list) with no exposed ports" { run dokku "$PLUGIN_COMMAND_PREFIX:list" - assert_contains "${lines[*]}" "l (running)" + assert_contains "${lines[*]}" "l, postgres:9.4.4 (running)" } @test "($PLUGIN_COMMAND_PREFIX:list) with exposed ports" { dokku "$PLUGIN_COMMAND_PREFIX:expose" l 4242 run dokku "$PLUGIN_COMMAND_PREFIX:list" - assert_contains "${lines[*]}" "l (running), exposed port(s): 5432->4242" + assert_contains "${lines[*]}" "l, postgres:9.4.4 (running), exposed port(s): 5432->4242" } @test "($PLUGIN_COMMAND_PREFIX:list) when there are no services" {