Repository navigation
Description
Problem
The top-level secrets: block parses (Config.secrets: Option<SecretsAdapter> in crates/jiji-config/src/schema.rs) but nothing reads it. Configuring it is a silent no-op: no values are fetched and no warning is printed. Secret values can only come from a .env file, or from the host environment with --host-env.
Goal
When secrets: names an adapter, secret values come from that adapter instead of the .env file. Everything else about secrets stays as it is: the same config fields reference secrets by ALL_CAPS name, and the values are staged, redacted, and injected the same way.
Doppler is the first and only adapter in this ticket. The code should make a second adapter a small addition, but do not build one.
secrets:
adapter: doppler
project: my-app # optional
config: prd # optional
environment:
secrets:
- DATABASE_PASSWORD # value now comes from DopplerBehavior
Source of values
- No
secrets:block: unchanged. Values come from.env.{environment}/.env(orsecrets_path), then the host environment with--host-env. secrets:block present: the.envfile is not read at all. Values come from the adapter, then the host environment with--host-env.secrets_pathset together withsecrets:is a validation error (secrets_pathwould have no effect). The message tells the user to remove one of them.
What resolves through the adapter
Every field that resolves a name through env_resolution::resolve_secret_name today, with no per-field special cases:
environment.secrets(shared and per service)build.secretsand ALL_CAPS references inbuild.argsbuilder.registry.passwordwhen it is an ALL_CAPS name ($(command)and literal values are unchanged)servers.<name>.hostandssh.keys/servers.<name>.keysALL_CAPS referencesproxy.ssl.certificate_pem/private_key_pem
All of these take a loaded: &BTreeMap<String, String> today. The adapter's job is to produce that map; the lookups do not change.
Doppler adapter
- Runs the local
dopplerCLI once and reads the whole config as JSON from stdout:
doppler secrets download --no-file --format json, plus--project <project>and--config <config>when they are set injiji.yml. - When
projectorconfigis omitted, the flag is not passed and the CLI uses its own scope (doppler setup). jiji does not guess defaults. - Authentication belongs to the CLI (
doppler loginor a service token). jiji passes its environment through and adds no auth handling or flags of its own. - Use
crate::local_exec::run_captured_with_timeoutwith a 30 second timeout, asresolve_command_valuedoes. Pass arguments as an argv list, never throughsh -c. - Every value in the returned JSON object must be a string; anything else is an error naming the key.
Fetch timing
- At most one
dopplerinvocation per jiji process.load_config_for_sshand the command body both load secret values today (config_loading.rs:42plus a second call in the command), so the fetched map has to be shared between them rather than fetched twice. - Fetch only when needed. A command with nothing to resolve must not call Doppler. In
load_config_for_sshthat means fetching only when aservers.*.hostor SSH key entry is an ALL_CAPS reference, sojiji service logs,jiji lock, and similar commands work without a Doppler login.
Errors
Each error says what to do next.
- Unknown adapter name: rejected at config validation, listing the supported adapters. Make
adapteran enum rather than aStringso an unknown name cannot reach runtime. dopplernot onPATH: tell the user to install the Doppler CLI.dopplerexits non-zero (not logged in, wrong project or config, no network): include its trimmed stderr and tell the user to rundoppler loginor checksecrets.project/secrets.config. Never include stdout.- Timeout and unparseable output each get their own message.
- Missing secret names are still reported together in one error. The hint depends on the source: with an adapter it names the adapter, project, and config and says to add the secret there or pass
--host-env; without one it keeps the current.envwording. The hard-coded.envhints to update are inenv_resolution.rs(resolve_environment),config_loading.rs,registry.rs(resolve_registry_password),ssh_adapter.rs, andbuild_plan.rs.
Output
jiji deployprintsEnvironment loaded from: <path>today. With an adapter it prints the source instead, for exampleSecrets loaded from: doppler (project my-app, config prd). The same applies to the other commands that print the loaded path.jiji secrets printshows the adapter line in place ofSecrets file:, and reports[SET]/[MISSING]against adapter values. Values stay hidden unless--show-valuesis passed. Itsrunis synchronous today and will need to become async.- Secret values never appear in default or verbose output, including the Doppler command's stdout.
Implementation notes
- Replace the eight
env_resolution::load_env_filecall sites with one function that returns the value map plus a description of where it came from (env file path, adapter, or nothing). Call sites:config_loading.rs,commands/deploy.rs,commands/build.rs,commands/registry/login.rs,commands/secrets/print.rs,commands/service/restart.rs,commands/service/rollback.rs,commands/service/scale.rs. - Put the adapter behind a small interface (one method that returns the name-to-value map) with a factory keyed on the adapter enum. A new file is fine here; it is a new logical component.
- Follow the repo rules in
AGENTS.md: all output throughjiji-tui'sUi, nounwrap()/expect()in non-test code,validate_config()collects every error.
Out of scope
- Any adapter other than Doppler.
- Calling the Doppler HTTP API directly, or managing Doppler tokens.
- Mixing
.envand adapter values, or per-service adapters. - Writing or syncing secrets to Doppler.
- New commands.
jiji secrets printis the only command surface that changes.
Tests
No mock framework; use the layers in docs/testing.md.
- A fake
dopplerexecutable first onPATHthat logs its argv and prints canned JSON (the pattern incrates/jiji-cli/tests/registry_auth_test.rs). Cover:--project/--configare passed when set and omitted when not.- A deploy with
secrets:configured stages the Doppler values in the service env file and does not read.env, even when a.envwith conflicting values exists. - The fake is invoked exactly once for a command that resolves both an SSH key reference and service secrets.
- The fake is not invoked for a command with nothing to resolve (for example
jiji service logswith literal hosts and keys). - Non-zero exit, missing binary, invalid JSON, and a non-string value each produce the actionable error.
- Unit tests for precedence: adapter value used, host env used only with
--host-envand only when the adapter lacks the name, all missing names reported in one error with the adapter hint. - Validation tests in
crates/jiji-config/tests/validation_test.rs: unknown adapter name, andsecrets_pathtogether withsecrets:. jiji secrets printwith an adapter: source line,[SET]/[MISSING], values hidden without--show-values.
Done when
- The behavior above is implemented and
mise fmt,mise lint,mise test, andmise scanpass. - It has been run once against a real Doppler project with the real CLI (
jiji secrets printand a deploy to a real host), and the PR description says what was checked. If you have no Doppler access, say so in the PR instead of claiming it works. crates/jiji-config/src/jiji.yml: the "External Secret Adapters (NOT YET IMPLEMENTED)" block is rewritten to describe the working behavior, and the nearby comments that say secrets come only from.envare corrected.AGENTS.md: the line "Config.secretsparses but nothing reads it; no secrets adapter exists." is removed.- The website's configuration reference section "External secrets adapters" (it currently says the block has no effect) is updated in the website repository, along with the CI/CD guide if it describes secrets. Link that PR from this one.
Activity
[-]config: implement external secrets adapters (secrets: is currently a silent no-op)[/-][+]config: resolve secrets through an external adapter, starting with Doppler[/+]