Skip to content

feat: Accept config values with !env_file in yaml - #185

Merged
contre95 merged 1 commit into
mainfrom
feat/env_files
Sep 18, 2026
Merged

contre95 merged 1 commit into
mainfrom
feat/env_files

Conversation

@contre95

@contre95 contre95 commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds a new !env_file YAML tag to the config loader, alongside the existing !env_var tag. Where !env_var NAME reads the secret directly from env var NAME, !env_file NAME treats NAME's value as a file path and reads the secret from that file's (trimmed) contents.
  • This follows the standard Docker/Kubernetes secrets convention (SOMETHING_FILE=/run/secrets/something), so secrets can be mounted as files instead of passed as plaintext env vars — useful for Docker Swarm/Compose secrets, Kubernetes Secret volumes, and avoiding secrets showing up in docker inspect, process env, or shell history.
  • Applies to any secret field in the config, not just AcoustID — e.g. telegram.token, metadata.providers.discogs.secret, metadata.providers.acoustid.secret.
  • Same failure semantics as !env_var: startup fails with a clear error if the env var is unset, the file can't be read, or the file is empty.

Changes

  • src/features/config/manager.go — new !env_file branch in processEnvVarNodes.
  • src/features/config/manager_test.go — new tests: !env_var + !env_file resolving correctly together, and the error path when the referenced file is missing.
  • config.example.yaml, docs/features/config.md, README.md — document the new tag with examples for AcoustID/Discogs/Telegram.

Test plan

  • CGO_ENABLED=0 go build ./...
  • CGO_ENABLED=0 go test ./src/features/config/... (both new tests pass)
  • Manually verified a config with secret: !env_file ACOUSTID_CLIENT_KEY_FILE resolves against a real file and fails cleanly when the file is absent/empty

Summary by CodeRabbit

  • New Features

    • Added support for loading secret values from files using the !env_file configuration tag.
    • File paths are provided through environment variables, with trimmed file contents used as configuration values.
    • Startup now reports errors when referenced files are missing, unreadable, or empty.
  • Documentation

    • Updated configuration documentation and examples with !env_file usage and Docker/Kubernetes secret conventions.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 1c039ac7-3bd4-4b5c-8151-bd2a662dadef

📥 Commits

Reviewing files that changed from the base of the PR and between 30d4006 and 27e0eeb.

📒 Files selected for processing (5)
  • README.md
  • config.example.yaml
  • docs/features/config.md
  • src/features/config/manager.go
  • src/features/config/manager_test.go

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The configuration manager now supports !env_file tags. It reads a file path from an environment variable and uses the trimmed file contents as the value. Tests and documentation cover successful resolution and startup errors.

Changes

Environment file configuration support

Layer / File(s) Summary
Resolve environment file tags
src/features/config/manager.go, src/features/config/manager_test.go
processEnvVarNodes resolves !env_file tags, validates environment variables and file contents, and reports errors. Tests cover successful resolution and missing files.
Document environment file configuration
README.md, config.example.yaml, docs/features/config.md
Documentation describes !env_file, secret file paths, startup errors, and Docker/Kubernetes secret usage.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ConfigManager
  participant Environment
  participant SecretFile
  ConfigManager->>Environment: Look up the !env_file variable
  Environment-->>ConfigManager: Return the file path
  ConfigManager->>SecretFile: Read the file
  SecretFile-->>ConfigManager: Return trimmed contents or an error
Loading

Merge Risk: ⚪ Minimal · up to 27e0e

The new secret-file configuration behavior, error handling, tests, and documentation are aligned in the supplied change context. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (3 skipped: 3 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for !env_file configuration values in YAML.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/env_files

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@contre95
contre95 marked this pull request as ready for review September 15, 2026 12:11
@contre95

contre95 commented Sep 15, 2026 •

Copy link
Copy Markdown
Owner Author

Attempts to address #183

@contre95
contre95 merged commit 6c90991 into main Sep 18, 2026
2 checks passed
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