8000 config: resolve secrets through an external adapter, starting with Doppler · Issue #113 · acidtib/jiji · GitHub
[go: up one dir, main page]

Skip to content

config: resolve secrets through an external adapter, starting with Doppler #113

Closed

Description

@acidtib

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 Doppler

Behavior

Source of values

  • No secrets: block: unchanged. Values come from .env.{environment} / .env (or secrets_path), then the host environment with --host-env.
  • secrets: block present: the .env file is not read at all. Values come from the adapter, then the host environment with --host-env.
  • secrets_path set together with secrets: is a validation error (secrets_path would 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.secrets and ALL_CAPS references in build.args
  • builder.registry.password when it is an ALL_CAPS name ($(command) and literal values are unchanged)
  • servers.<name>.host and ssh.keys / servers.<name>.keys ALL_CAPS references
  • proxy.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 doppler CLI 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 in jiji.yml.
  • When project or config is 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 login or 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_timeout with a 30 second timeout, as resolve_command_value does. Pass arguments as an argv list, never through sh -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 doppler invocation per jiji process. load_config_for_ssh and the command body both load secret values today (config_loading.rs:42 plus 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_ssh that means fetching only when a servers.*.host or SSH key entry is an ALL_CAPS reference, so jiji 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 adapter an enum rather than a String so an unknown name cannot reach runtime.
  • doppler not on PATH: tell the user to install the Doppler CLI.
  • doppler exits non-zero (not logged in, wrong project or config, no network): include its trimmed stderr and tell the user to run doppler login or check secrets.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 .env wording. The hard-coded .env hints to update are in env_resolution.rs (resolve_environment), config_loading.rs, registry.rs (resolve_registry_password), ssh_adapter.rs, and build_plan.rs.

Output

  • jiji deploy prints Environment loaded from: <path> today. With an adapter it prints the source instead, for example Secrets loaded from: doppler (project my-app, config prd). The same applies to the other commands that print the loaded path.
  • jiji secrets print shows the adapter line in place of Secrets file:, and reports [SET] / [MISSING] against adapter values. Values stay hidden unless --show-values is passed. Its run is 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_file call 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 through jiji-tui's Ui, no unwrap()/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 .env and adapter values, or per-service adapters.
  • Writing or syncing secrets to Doppler.
  • New commands. jiji secrets print is the only command surface that changes.

Tests

No mock framework; use the layers in docs/testing.md.

  • A fake doppler executable first on PATH that logs its argv and prints canned JSON (the pattern in crates/jiji-cli/tests/registry_auth_test.rs). Cover:
    • --project / --config are 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 .env with 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 logs with 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-env and 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, and secrets_path together with secrets:.
  • jiji secrets print with 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, and mise scan pass.
  • It has been run once against a real Doppler project with the real CLI (jiji secrets print and 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 .env are corrected.
  • AGENTS.md: the line "Config.secrets parses 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

  1. changed the title [-]config: implement external secrets adapters (secrets: is currently a silent no-op)[/-] [+]config: resolve secrets through an external adapter, starting with Doppler[/+] on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0