Skip to content

Split framework env vars off the CDT prefix#9

Merged
jdevera merged 6 commits into
mainfrom
env-var-split
May 17, 2026
Merged

Split framework env vars off the CDT prefix#9
jdevera merged 6 commits into
mainfrom
env-var-split

Conversation

@jdevera
Copy link
Copy Markdown
Owner

@jdevera jdevera commented May 17, 2026

Summary

Four atomic commits that move the launcher's own behaviour env vars off the hardcoded CDT_* prefix and onto the binary-derived <APPNAME>_* form everything else in the codebase already uses.

Commit What
3af5b9c Delete dead helper.ReadPassword — zero callers; cmd/login.go reads passwords directly. Removes CDT_JENKINS_PASSWORD.
852f785 helper.LoadDebugFlags / HasDebugFlag read from appCtx.DebugFlagsEnvVar() (<APPNAME>_DEBUG_FLAGS).
633a209 New VaultSecretEnvVar() / VaultSecretFileEnvVar() on LauncherContext; gvault.readSecret() reads through them. Test uses a func init() to set appName=testvault, so the env var is a stable TESTVAULT_VAULT_SECRET.
358d66a Drop CDT_VAULT_SECRET from .github/workflows/go.yml — tests now own their env lifecycle via t.Setenv.

The design call: <APPNAME>_* (binary-derived) rather than a fixed COLA_* framework prefix. Same pattern as every other launcher-managed env var already routed through appCtx.EnvVarName(). A user running two launchers gets independent state; mirrors the on-disk story where ~/.<appname>/ is per-binary.

Test plan

Verified locally before push:

  • ./build.sh clean
  • go build ./... && go vet ./... clean
  • go test ./... all packages pass
  • ./test/integration.sh 19/19 suites pass
  • cd gh-pages && npm install && npm run test markdownlint clean
  • Vault tests pass with CDT_VAULT_SECRET unset in the shell
  • Fork CI green across the matrix (Windows / Linux / macOS × amd64 / arm64)

jdevera added 6 commits May 17, 2026 22:39
Zero callers across the tree. cmd/login.go reads passwords directly
with terminal.ReadPassword and uses appCtx.PasswordEnvVar() for the
non-interactive override; this helper was superseded scaffolding.

Removes the hardcoded CDT_JENKINS_PASSWORD literal from scope.
helper.LoadDebugFlags and helper.HasDebugFlag were reading the
hardcoded CDT_DEBUG_FLAGS literal, contradicting the context's
DebugFlagsEnvVar() method that was supposed to be the source of
truth for the env var name.

Route both reads through appCtx.DebugFlagsEnvVar() (returns
<APPNAME>_DEBUG_FLAGS — e.g. COLA_DEBUG_FLAGS for the cola binary).
Fall back to an empty string when no context is initialised, so
early bootstrap paths don't crash.
readSecret() was reading hardcoded CDT_VAULT_SECRET and
CDT_VAULT_SECRET_FILE literals. Vault state is per-launcher (the
file vault directory and cache live under the per-app tree), so the
env vars that unlock that state should match the launcher the user
is invoking, not stay frozen on the upstream CDT prefix.

Add VaultSecretEnvVar() and VaultSecretFileEnvVar() to
LauncherContext; route the two reads through them. For the cola
binary the names become COLA_VAULT_SECRET and COLA_VAULT_SECRET_FILE.

file-vault_test.go now initialises the context once via TestMain-
style init() with appName "testvault" so the derived env var is a
stable TESTVAULT_VAULT_SECRET that all three tests can target.
Vault tests now own their env var lifecycle via t.Setenv against a
known-initialised context (TESTVAULT_VAULT_SECRET), so no test
relies on an inherited shell variable any more. The hardcoded CDT_*
literal here was the last reference to the upstream prefix in CI.
TestAccessConsents flows through helper.SetSecret, which on Linux
runners always picks the file vault. Vault init calls readSecret(),
which after the env-var split looks up the per-app
<APPNAME>_VAULT_SECRET. The test was previously relying on the
workflow's CDT_VAULT_SECRET env block to satisfy that read; with
that env block gone in Bundle 4 the test crashed on CI runners that
have no ~/.ssh fallback.

Set the env var explicitly via t.Setenv, keyed off the context's
own VaultSecretEnvVar() so the test stays correct if the derivation
rule changes. Also switch the appName from "test-vault" to
"testconsent" so the derived env var name has no dash.
The integration test binary builds with appName=cl, so after the
env-var split the file vault now reads CL_VAULT_SECRET rather than
the inherited CDT_VAULT_SECRET from the workflow env. CI runners
have no ~/.ssh fallback, so without the env var being set, every
helper.GetSecret/SetSecret call on Linux fails — which broke
test-consent, test-manifest, test-template and the new test-workspace
suites once the workflow env block went away.

Set CL_VAULT_SECRET in the test runner itself so the integration
tests are self-contained on this dimension regardless of how CI is
configured. Safe on macOS / Windows where keyring is preferred.
@jdevera jdevera merged commit 2c048c0 into main May 17, 2026
16 checks passed
@jdevera jdevera deleted the env-var-split branch May 17, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant