Support combining config sources (e.g. YAML and env vars)

Open
#471 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
backend

Research direction

Start in ImmichFrame.WebApi/Helpers/Config/ConfigLoader.cs, which currently tries JSON, then YAML, then environment variables and stops at the first source found. Trace how each source is bound to the settings classes before changing the order. The issue leaves open whether to merge all sources per setting or only the secrets, and how Accounts entries should be matched, so get a maintainer decision first. Done means the agreed merge rules are implemented and covered by config tests.

Written by the indexing model from the issue text.

Description

enhancement
Description

The ConfigLoader attempts to load from JSON format first, then YAML, and finally environment variables, meaning that environment config is ignored if a config file is present.
This isn't ideal for admins who usually want to use the preferred config format (YAML) but don't want secrets like ApiKey in the same Git-tracked config file, especially when environment secrets are quite well supported by Docker and container tools in general.

IMHO, a better approach would be to read all config sources and override the lower-priority ones on a per-setting basis, with an option to dump the final effective config to the log to help with troubleshooting.

If this is too complex, a stopgap solution only for secrets (AuthenticationSecret, WeatherApiKey, per-account ApiKey) would already go a long way.

Use Case

This would allow storing secrets like ApiKey in a separate git-ignored .env file, or other secrets manager, or passing them interactively on the command-line, while keeping the main config in Settings.yml.

Details

This would involve loading the env config first, then attempt to load the JSON (overriding any existing keys), then with YAML. Arrays like Albums, People, WebCalendars would combine (union), while Accounts elements would probably need a Name or other identifier, so that accounts with the same name can be combined.

Pre-Submission Checklist
  • This is a feature request and not a bug report

  • I have checked for related issues and checked the documentation

Dominant language
C#
Stars
2.4k
Forks
121
Avg merge
18d 20h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from immichFrame/ImmichFrame

All issues in immichFrame/ImmichFrame

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.