From dd886215e7d65f8c60a0f5a11dd60b751bdda55b Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 2 Jun 2017 14:20:37 -0700 Subject: [PATCH 1/3] fix nits --- triton-docker | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/triton-docker b/triton-docker index cf58c4e..5123e75 100755 --- a/triton-docker +++ b/triton-docker @@ -72,7 +72,7 @@ function currentProfile () { } # Set env vars to make using CNS easier -function CnsEnvVars () { +function cnsEnvVars () { # If the CNS env vars are already set, don't bother continuing if [ -n "$TRITON_CNS_SEARCH_DOMAIN_PUBLIC" ] && [ -n "$TRITON_CNS_SEARCH_DOMAIN_PRIVATE" ] @@ -85,7 +85,7 @@ function CnsEnvVars () { local triton_url="$(triton profile get | awk -F"/" '/url:/{print $3}')" # Do not continue if the target is not a Triton Public Cloud data center - if [ ! "api.joyent.com" == "$(echo "${triton_url}" | awk -F'.' '{print $2 "." $3 "." $4}')" ] + if [ ! ".api.joyent.com" == "${triton_url: -15}" ] then return fi @@ -137,14 +137,14 @@ case "$(basename $0)" in triton-docker) checkAll && eval "$(triton env)" && - CnsEnvVars && + cnsEnvVars && exec /usr/local/bin/triton-docker-helper $@ ;; triton-compose) checkAll && eval "$(triton env)" && export COMPOSE_HTTP_TIMEOUT=750 && - CnsEnvVars && + cnsEnvVars && exec /usr/local/bin/triton-compose-helper $@ ;; triton-docker-install) From f320fb47998f5ac79b11fcfe9b400d2f9b020220 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Fri, 2 Jun 2017 14:42:16 -0700 Subject: [PATCH 2/3] don't exit if CNS is disabled --- triton-docker | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/triton-docker b/triton-docker index 5123e75..d5df59e 100755 --- a/triton-docker +++ b/triton-docker @@ -68,7 +68,24 @@ function currentProfile () { local profile_source='default; use `triton profile set ` to change' fi - echo "Executing in '$(triton profile get | awk 'NR == 1 {print $2}')' (${profile_source})" + # Get and the user's account information and CloudAPI URL for parsing later + local triton_account="$(triton account get)" + + echo "Executing in '$(echo "${triton_account}" | awk 'NR == 1 {print $2}')' (${profile_source})" + + # Check if CNS is enabled, require it + if [ ! "true" == "$(echo "${triton_account}" | awk -F": " '/cns/{print $2}')" ] + then + echo + tput rev # reverse + tput bold # bold + echo 'Error! Triton CNS is not enabled.' + tput sgr0 # clear + echo + echo 'Please run the following to activate:' + echo ' triton account update triton_cns_enabled=true' + echo + fi } # Set env vars to make using CNS easier @@ -90,22 +107,6 @@ function cnsEnvVars () { return fi - # Check if CNS is enabled, require it - local triton_cns_enabled="$(echo "${triton_account}" | awk -F": " '/cns/{print $2}')" - if [ ! "true" == "$triton_cns_enabled" ] - then - echo - tput rev # reverse - tput bold # bold - echo 'Error! Triton CNS is required and not enabled.' - tput sgr0 # clear - echo - echo 'Please run:' - echo ' triton account update triton_cns_enabled=true' - echo - exit 1 - fi - # Get the user's UUID local triton_account_uuid="$(echo "${triton_account}" | awk -F": " '/id:/{print $2}')" @@ -115,6 +116,7 @@ function cnsEnvVars () { local triton_dc="$(echo "${triton_url}" | awk -F'.' '{print $1}')" # Set the CNS base for public and private names + # Note, this also makes assumptions that only work in our public cloud export TRITON_CNS_SEARCH_DOMAIN_PUBLIC="${triton_account_uuid}.${triton_dc}.triton.zone" export TRITON_CNS_SEARCH_DOMAIN_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com" } From f265bb9b5801f1d4c4da8a4cff2000b3a9fd9695 Mon Sep 17 00:00:00 2001 From: Casey Bisson Date: Sat, 3 Jun 2017 08:58:09 -0700 Subject: [PATCH 3/3] nits --- triton-docker | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/triton-docker b/triton-docker index d5df59e..9fd8f94 100755 --- a/triton-docker +++ b/triton-docker @@ -74,12 +74,12 @@ function currentProfile () { echo "Executing in '$(echo "${triton_account}" | awk 'NR == 1 {print $2}')' (${profile_source})" # Check if CNS is enabled, require it - if [ ! "true" == "$(echo "${triton_account}" | awk -F": " '/cns/{print $2}')" ] + if [ ! "true" == "$(echo "${triton_account}" | awk -F": " '/^triton_cns_enabled:/{print $2}')" ] then echo tput rev # reverse tput bold # bold - echo 'Error! Triton CNS is not enabled.' + echo 'Warning! Triton CNS is not enabled.' tput sgr0 # clear echo echo 'Please run the following to activate:' @@ -108,7 +108,7 @@ function cnsEnvVars () { fi # Get the user's UUID - local triton_account_uuid="$(echo "${triton_account}" | awk -F": " '/id:/{print $2}')" + local triton_account_uuid="$(echo "${triton_account}" | awk -F": " '/^id:/{print $2}')" # Get current data center name # Note: this makes assumptions that work in our public cloud, but might not work elsewhere