refactor
It seemed wise to expose only the CNS variables that were most relevant
This commit is contained in:
parent
9d8ed9e18f
commit
e4a1385439
@ -74,20 +74,14 @@ function currentProfile () {
|
|||||||
# Extra env vars
|
# Extra env vars
|
||||||
function extraEnvVars () {
|
function extraEnvVars () {
|
||||||
|
|
||||||
# Get the user's UUID and current data center name
|
# If the CNS env vars are already set, don't bother continuing
|
||||||
local triton_account="$(triton account get)"
|
if [ -n "$TRITON_CNS_SUFFIX_PUBLIC" ] && [ -n "$TRITON_CNS_SUFFIX_PRIVATE" ]
|
||||||
export TRITON_ACCOUNT_UUID="$(echo "$triton_account" | awk -F": " '/id:/{print $2}')"
|
then
|
||||||
export TRITON_DC="$(triton profile get | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}')"
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# Set the CNS base for public and private names
|
# Get and the user's account information for parsing later
|
||||||
if [ ! -n "$TRITON_CNS_SUFFIX_PUBLIC" ]
|
local triton_account="$(triton account get)"
|
||||||
then
|
|
||||||
export TRITON_CNS_SUFFIX_PUBLIC="${TRITON_ACCOUNT}.${TRITON_DC}.triton.zone"
|
|
||||||
fi
|
|
||||||
if [ ! -n "$TRITON_CNS_SUFFIX_PRIVATE" ]
|
|
||||||
then
|
|
||||||
export TRITON_CNS_SUFFIX_PRIVATE="${TRITON_ACCOUNT}.${TRITON_DC}.cns.joyent.com"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if CNS is enabled, require it
|
# Check if CNS is enabled, require it
|
||||||
local triton_cns_enabled="$(echo "$triton_account" | awk -F": " '/cns/{print $2}')"
|
local triton_cns_enabled="$(echo "$triton_account" | awk -F": " '/cns/{print $2}')"
|
||||||
@ -103,6 +97,18 @@ function extraEnvVars () {
|
|||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get the user's UUID
|
||||||
|
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
|
||||||
|
# Further note: set TRITON_CNS_SUFFIX_PUBLIC and TRITON_CNS_SUFFIX_PRIVATE to work around this
|
||||||
|
local triton_dc="$(triton profile get | awk -F"/" '/url:/{print $3}' | awk -F'.' '{print $1}')"
|
||||||
|
|
||||||
|
# Set the CNS base for public and private names
|
||||||
|
export TRITON_CNS_SUFFIX_PUBLIC="${triton_account_uuid}.${triton_dc}.triton.zone"
|
||||||
|
export TRITON_CNS_SUFFIX_PRIVATE="${triton_account_uuid}.${triton_dc}.cns.joyent.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run all checks
|
# Run all checks
|
||||||
|
Loading…
Reference in New Issue
Block a user