bin: refactor out triton variables into new fn

This commit is contained in:
Tom Gallacher 2016-10-20 16:13:53 +01:00
parent 7f054437c8
commit b5ae1c6f2b
2 changed files with 9 additions and 3 deletions

View File

@ -11,6 +11,7 @@ INCLUDE=$(dirname $(readlink -f $0))
ensure_command triton ensure_command triton
ensure_triton_cns_is_enabled ensure_triton_cns_is_enabled
get_triton_details
write_env_file write_env_file
triton env triton env

View File

@ -39,12 +39,17 @@ ensure_command() {
} }
export -f ensure_command export -f ensure_command
ensure_docker_config_matches_triton_config_and_capture_triton_details() { get_triton_details() {
local docker_user=$(docker info 2>&1 | awk -F": " '/SDCAccount:/{print $2}')
local docker_dc=$(echo $DOCKER_HOST | awk -F"/" '{print $3}' | awk -F'.' '{print $1}')
TRITON_USER=$(triton profile get | awk -F": " '/account:/{print $2}') TRITON_USER=$(triton profile get | awk -F": " '/account:/{print $2}')
TRITON_DC=$(triton profile get | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}') TRITON_DC=$(triton profile get | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}')
TRITON_ACCOUNT=$(triton account get | awk -F": " '/id:/{print $2}') TRITON_ACCOUNT=$(triton account get | awk -F": " '/id:/{print $2}')
}
export -f get_triton_details
ensure_docker_config_matches_triton_config_and_capture_triton_details() {
local docker_user=$(docker info 2>&1 | awk -F": " '/SDCAccount:/{print $2}')
local docker_dc=$(echo $DOCKER_HOST | awk -F"/" '{print $3}' | awk -F'.' '{print $1}')
get_triton_details
if [[ ! "$docker_user" = "$TRITON_USER" ]] || [[ ! "$docker_dc" = "$TRITON_DC" ]]; then if [[ ! "$docker_user" = "$TRITON_USER" ]] || [[ ! "$docker_dc" = "$TRITON_DC" ]]; then
echo "Docker user: ${docker_user}" echo "Docker user: ${docker_user}"
echo "Triton user: ${TRITON_USER}" echo "Triton user: ${TRITON_USER}"