Merge pull request #421 from FoxxMD/secretsInterpolation
Some checks are pending
Publish Docker image to Dockerhub / test (push) Waiting to run
Publish Docker image to Dockerhub / Build OCI Images (push) Blocked by required conditions
Publish Docker image to Dockerhub / Build OCI Images-1 (push) Blocked by required conditions
Publish Docker image to Dockerhub / Merge OCI Images and Push (push) Blocked by required conditions

Secrets interpolation
This commit is contained in:
Matt Foxx 2025-12-16 21:00:53 -05:00 committed by GitHub
commit 9bef0791c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 281 additions and 37 deletions

View file

@ -166,6 +166,83 @@ See the [Configuration Types](#configuration-types) above for your options for c
Each entry for a Source/Client includes a **Configuration** section that describes how to configure it using a [configuration type](#configuration-types).
## Secrets Interpolation
When using [File](./?configType=file#configuration-types) or [AIO](./?configType=aio#configuration-types) Configuration, Multi-Scrobbler can interpolate Environmental Variables into your json files. This can be used, for example, to keep sensitive data (like [Last.fm Client/Secret](/configurations/clients/lastfm#configuration)) out of your configuration files so that they can be committed to git.
Multi-scrobbler will look for patterns in text fields within _all_ of your json files:
* Some part of the text field matches: `[[MY_ENV]]`
* Is replaced by the value of the Environmental Variable named `MY_ENV`
<details>
<summary>Example</summary>
Given this [Last.fm](/configurations/clients/lastfm#configuration) [File](./?configType=file#configuration-types) config:
```json title="lastfm.json"
[
{
"name": "myLastFmClient",
"configureAs": "client",
"data": {
"apiKey": "[[MY_APIKEY]]",
"secret": "[[MY_SECRET]]",
"redirectUri": "http://localhost:9078/lastfm/callback"
}
}
]
```
And these environmental variables, in this scenario set through `environment` in the [docker compose installation](/quickstart#create-docker-compose-file):
```
MY_APIKEY=a89cba1569901a0671d5a9875fed4be1
MY_SECRET=ec42e09d5ae0ee0f0816ca151008412a
```
The resulting json multi-scrobbler would use:
```json title="lastfm.json"
[
{
"name": "myLastFmClient",
"configureAs": "client",
"data": {
"apiKey": "a89cba1569901a0671d5a9875fed4be1",
"secret": "ec42e09d5ae0ee0f0816ca151008412a",
"redirectUri": "http://localhost:9078/lastfm/callback"
}
}
]
```
</details>
:::note[Caveats]
* ENV variable names/interpolation keys are case-insensitive
* Interpolation only works for **string** values within json. This cannot be used for numbers, booleans, objects, etc...
:::
:::warning[Missing ENVS]
Multi-scrobbler **will not** throw an error if the environmental value is not found. Instead, it will leave the string as-is and log a warning (`WARN` level) with the names of the missing environmental variable names like so:
```
WARN : [App] [Sources] [spotify Secrets] Matched: None | Unmatched: SPOTIFY_SECRET
```
:::
:::warning[ENV Name Collisions]
**Verify that interpolation keys/environmental variable names you will use do not collide with existing ENV names used by multi-scrobbler.** Use the docs search to verify the name you want to use is not already used elsewhere by multi-scrobbler.
:::
## Application Options
These options affect multi-scrobbler's behavior and are not specific to any source/client.