From 2d55a3638fc268dc225e2edf869f2b23f5f6d936 Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Sat, 10 Aug 2019 23:41:51 -0400 Subject: [PATCH] Extract endpoint docker inspection to a function --- psu | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/psu b/psu index 0345d7a..b488fdd 100644 --- a/psu +++ b/psu @@ -825,12 +825,7 @@ deploy() { # Get Docker info echo_verbose "Getting Docker info..." local docker_info - docker_info=$(http \ - --check-status \ - --ignore-stdin \ - --verify=$HTTPIE_VERIFY_SSL \ - "$PORTAINER_URL/api/endpoints/$PORTAINER_ENDPOINT/docker/info" \ - "Authorization: Bearer $AUTH_TOKEN") + docker_info=$(docker_info) check_for_errors $? "$docker_info" echo_debug "Docker info -> $(echo $docker_info | jq -C .)" @@ -1002,6 +997,20 @@ env_file_to_json() { echo "$(env -i sh -c "(unset \$(env | sed 's/=.*//'); set -a; . $(readlink -f $ENVIRONMENT_VARIABLES_FILE); set +a; jq -njc 'env | to_entries | map({name: .key, value: .value})')")" } +# Get Docker info +docker_info() { + local docker_info + docker_info=$(http \ + --check-status \ + --ignore-stdin \ + --verify=$HTTPIE_VERIFY_SSL \ + "$PORTAINER_URL/api/endpoints/$PORTAINER_ENDPOINT/docker/info" \ + "Authorization: Bearer $AUTH_TOKEN") + check_for_errors $? "$docker_info" + + echo "$docker_info" +} + tasks() { local desired_state=$1 local state=$2