tritonshell/pkgs/triton-docker-env-shell.nix

37 lines
1.5 KiB
Nix

{ pkgs, ... }:
with pkgs.nodePackages;
''
# Script to set the docker, triton, manta and CNS env vars for the current
# triton profile
# Docs: https://docs.greenbaum.cloud/en/devops/triton-cli.html
# triton CLI source: https://github.com/tritonDataCenter/node-triton
cnsBaseDomain=$TRITONSHELL_CNS_BASE_DOMAIN
dataCenters=$TRITONSHELL_DATA_CENTERS
mantaDomain=$TRITONSHELL_MANTA_DOMAIN
tritonApiDomain=$TRITONSHELL_TRITON_API_DOMAIN
# Set triton and docker host environment variables
eval "$(${triton}/bin/triton env)"
# Get the user's UUID
triton_account_uuid="$(${triton}/bin/triton account get --json | ${json}/bin/json id)"
# Set the CNS (container name service) base domain for auto-generated DNS
# records in public and private networks
# Note: the defaults are configured to work with our data centers, adjust the
# nix module options like config.environment.cnsBaseDomain in your devshell
# if you'd like to use tritonshell with your own, self-hosted TritonDataCenter
for dc in "''${dataCenters[@]}"; do
if env | grep -q -E "SDC_URL=https://''${dc}.''${tritonApiDomain}"; then
export \
TRITON_CNS_SEARCH_DOMAIN_PUBLIC="''${triton_account_uuid}.''${dc}.''${cnsBaseDomain}" \
TRITON_CNS_SEARCH_DOMAIN_PRIVATE="''${triton_account_uuid}.''${dc}.int.''${cnsBaseDomain}" \
TRITON_DC=''$dc
fi
done
export MANTA_URL=https://''${mantaDomain}
export MANTA_USER=$SDC_ACCOUNT
export MANTA_KEY_ID=$SDC_KEY_ID
''