|
7 | 7 | # STS_URL - url of the StackState instance to configure (empty means don't configure) |
8 | 8 | # STS_API_TOKEN - API-TOKEN of the StackState instance to configure (empty means don't configure) |
9 | 9 | # STS_CLI_LOCATION - Path you want to install CLI (empty means `/usr/local/bin`) |
| 10 | +# STS_CA_CERT_PATH - Path to CA certificate file for HTTPS verification |
| 11 | +# STS_CA_CERT_BASE64_DATA - Base64 encoded CA certificate data for HTTPS verification |
| 12 | +# STS_SKIP_SSL - Skip SSL verification (if set, CA cert options are ignored) |
10 | 13 | #----------------------------------- |
11 | 14 |
|
12 | 15 | #!/usr/bin/env bash |
|
75 | 78 | # Verify that 'sts' works |
76 | 79 | ${TARGET_CLI_PATH}/sts > /dev/null 2>&1 |
77 | 80 |
|
| 81 | +# Validate SSL/CA certificate environment variables |
| 82 | +if [[ -n "${STS_SKIP_SSL}" ]]; then |
| 83 | + if [[ -n "${STS_CA_CERT_PATH}" || -n "${STS_CA_CERT_BASE64_DATA}" ]]; then |
| 84 | + printf "${RED}[WARNING]${NO_COLOR} STS_SKIP_SSL is set, ignoring STS_CA_CERT_PATH and STS_CA_CERT_BASE64_DATA\n" |
| 85 | + fi |
| 86 | +elif [[ -n "${STS_CA_CERT_PATH}" && -n "${STS_CA_CERT_BASE64_DATA}" ]]; then |
| 87 | + printf "${RED}[WARNING]${NO_COLOR} Both STS_CA_CERT_PATH and STS_CA_CERT_BASE64_DATA are set, STS_CA_CERT_PATH takes precedence\n" |
| 88 | +fi |
| 89 | + |
78 | 90 | # Configure the CLI if config parameters have been set |
79 | 91 | if [[ -n "${STS_URL}" && -n "${STS_API_TOKEN}" ]]; then |
80 | | - ${TARGET_CLI_PATH}/sts context save --url ${STS_URL} --api-token ${STS_API_TOKEN} |
| 92 | + if [[ -n "${STS_SKIP_SSL}" ]]; then |
| 93 | + COMMAND="${TARGET_CLI_PATH}/sts context save --url ${STS_URL} --api-token ${STS_API_TOKEN} --skip-ssl" |
| 94 | + elif [[ -n "${STS_CA_CERT_PATH}" ]]; then |
| 95 | + COMMAND="${TARGET_CLI_PATH}/sts context save --url ${STS_URL} --api-token ${STS_API_TOKEN} --ca-cert-path ${STS_CA_CERT_PATH}" |
| 96 | + elif [[ -n "${STS_CA_CERT_BASE64_DATA}" ]]; then |
| 97 | + COMMAND="${TARGET_CLI_PATH}/sts context save --url ${STS_URL} --api-token ${STS_API_TOKEN} --ca-cert-base64-data ${STS_CA_CERT_BASE64_DATA}" |
| 98 | + else |
| 99 | + COMMAND="${TARGET_CLI_PATH}/sts context save --url ${STS_URL} --api-token ${STS_API_TOKEN}" |
| 100 | + fi |
| 101 | + ${COMMAND} |
| 102 | + if [[ $? -ne 0 ]]; then |
| 103 | + error "Failed to configure the CLI with the provided parameters. Please check your STS_URL and STS_API_TOKEN." |
| 104 | + else |
| 105 | + printf "Successfully configured the CLI with the provided parameters.\n" |
| 106 | + fi |
81 | 107 | fi |
82 | 108 |
|
83 | 109 | if [ "$(whereis sts)" == "" ]; then |
|
0 commit comments