fix(digitalocean): use canonical DIGITALOCEAN_ACCESS_TOKEN env var (#3099)

Replaces all references to DO_API_TOKEN with DIGITALOCEAN_ACCESS_TOKEN,
matching DigitalOcean's official CLI and API documentation. This includes
TypeScript source, tests, shell scripts, Packer config, CI workflows,
and documentation.

Supersedes #3068 (rebased onto current main).

Agent: pr-maintainer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-03-29 18:48:56 -07:00 committed by GitHub
parent b9473f25b8
commit 0bd8930c09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 147 additions and 60 deletions

View file

@ -4,11 +4,19 @@
# Implements the standard cloud driver interface (_digitalocean_*) for
# provisioning and managing DigitalOcean droplets in the E2E test suite.
#
# Requires: DO_API_TOKEN, jq, ssh
# Accepts: DIGITALOCEAN_ACCESS_TOKEN, DIGITALOCEAN_API_TOKEN, or DO_API_TOKEN
# API: https://api.digitalocean.com/v2
# SSH user: root
set -eo pipefail
# ── Resolve DigitalOcean token (canonical > alternate > legacy) ───────────
if [ -n "${DIGITALOCEAN_ACCESS_TOKEN:-}" ]; then
DO_API_TOKEN="${DIGITALOCEAN_ACCESS_TOKEN}"
elif [ -n "${DIGITALOCEAN_API_TOKEN:-}" ]; then
DO_API_TOKEN="${DIGITALOCEAN_API_TOKEN}"
fi
export DO_API_TOKEN
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
@ -19,7 +27,7 @@ _DO_DEFAULT_REGION="nyc3"
# ---------------------------------------------------------------------------
# _do_curl_auth [curl-args...]
#
# Wrapper around curl that passes the DO_API_TOKEN via a temp config file
# Wrapper around curl that passes the token via a temp config file
# instead of a command-line -H flag. This keeps the token out of `ps` output.
# All arguments are forwarded to curl.
# ---------------------------------------------------------------------------
@ -37,19 +45,19 @@ _do_curl_auth() {
# ---------------------------------------------------------------------------
# _digitalocean_validate_env
#
# Validates that DO_API_TOKEN is set and the DigitalOcean API is reachable
# with valid credentials.
# Validates that a DigitalOcean token is set and the API is reachable.
# Accepts DIGITALOCEAN_ACCESS_TOKEN, DIGITALOCEAN_API_TOKEN, or DO_API_TOKEN.
# Returns 0 on success, 1 on failure.
# ---------------------------------------------------------------------------
_digitalocean_validate_env() {
if [ -z "${DO_API_TOKEN:-}" ]; then
log_err "DO_API_TOKEN is not set"
log_err "DigitalOcean token is not set (set DIGITALOCEAN_ACCESS_TOKEN, DIGITALOCEAN_API_TOKEN, or DO_API_TOKEN)"
return 1
fi
if ! _do_curl_auth -sf \
"${_DO_API}/account" >/dev/null 2>&1; then
log_err "DigitalOcean API authentication failed — check DO_API_TOKEN"
log_err "DigitalOcean API authentication failed — check your token"
return 1
fi