Every setting can be given as an environment variable (closes #128) #131

Merged
clawbot merged 3 commits from issue-128-env-settings into next 2026-09-28 13:46:56 +02:00
Collaborator

Closes #128, part of #17. Also covers #99 (the port from PORT).

Every config key can be set by PIXA_ plus the key in upper case (. written as _), the port by PORT. One list in internal/config/config.go pairs keys with variables; the existing getters read a variable present in the environment, even an empty one, before the config file, so every existing check covers it. Errors a variable can reach name the key and the variable. The image no longer bakes in config.docker.yml or passes --config.

What a reader would trip over:

  • The loader searched /etc/pixad/ (the daemon name), not /etc/pixa/ as the issue assumed, so without --config a file mounted at /etc/pixa/config.yml would go unread. It now searches under pixa (/etc/pixa/, ~/.config/pixa/), and config.Params drops its now unused Globals.
  • A config file's env: section sets process variables while the file loads, so a PORT or PIXA_ name listed there beats the file's own key and replaces the value the process started with.
  • blocked_networks: "" and trusted_proxies: "" in the file now mean an empty list instead of aborting: one parser serves both sources, as allowlist_hosts already did.
  • The config tests unset PORT and every PIXA_ variable first.
  • The image's HEALTHCHECK (from #130) now probes ${PORT:-8080}, so it follows PORT; a port set only in a mounted config file is not seen by it.

Judgement call: the search directory change above.
Rule suppressed: one //nolint:gosec (G101) on the list, which gosec reads as a hard-coded password.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/pixa/issues/128, part of https://git.eeqj.de/sneak/pixa/issues/17. Also covers https://git.eeqj.de/sneak/pixa/issues/99 (the port from `PORT`). Every config key can be set by `PIXA_` plus the key in upper case (`.` written as `_`), the port by `PORT`. One list in `internal/config/config.go` pairs keys with variables; the existing getters read a variable present in the environment, even an empty one, before the config file, so every existing check covers it. Errors a variable can reach name the key and the variable. The image no longer bakes in `config.docker.yml` or passes `--config`. What a reader would trip over: - The loader searched `/etc/pixad/` (the daemon name), not `/etc/pixa/` as the issue assumed, so without `--config` a file mounted at `/etc/pixa/config.yml` would go unread. It now searches under `pixa` (`/etc/pixa/`, `~/.config/pixa/`), and `config.Params` drops its now unused `Globals`. - A config file's `env:` section sets process variables while the file loads, so a `PORT` or `PIXA_` name listed there beats the file's own key and replaces the value the process started with. - `blocked_networks: ""` and `trusted_proxies: ""` in the file now mean an empty list instead of aborting: one parser serves both sources, as `allowlist_hosts` already did. - The config tests unset `PORT` and every `PIXA_` variable first. - The image's `HEALTHCHECK` (from https://git.eeqj.de/sneak/pixa/pulls/130) now probes `${PORT:-8080}`, so it follows `PORT`; a port set only in a mounted config file is not seen by it. Judgement call: the search directory change above. Rule suppressed: one `//nolint:gosec` (G101) on the list, which gosec reads as a hard-coded password. Model: opus-5-5
clawbot added the needs-review label 2026-09-28 11:49:29 +02:00
clawbot self-assigned this 2026-09-28 11:49:29 +02:00
clawbot added needs-rebase and removed needs-review labels 2026-09-28 12:07:28 +02:00
clawbot force-pushed issue-128-env-settings from 07f3433764 to 2005143e3d 2026-09-28 12:09:08 +02:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-09-28 12:13:19 +02:00
Author
Collaborator

Rebased onto next, which now has the Docker health check from #130. The Dockerfile conflict keeps both that HEALTHCHECK and this PR's ENTRYPOINT without --config; the health check now probes ${PORT:-8080} instead of a fixed 8080, so it follows PORT. TODO.md keeps both completed entries, this one on top.

Model: opus-5-5

Rebased onto `next`, which now has the Docker health check from https://git.eeqj.de/sneak/pixa/pulls/130. The `Dockerfile` conflict keeps both that `HEALTHCHECK` and this PR's `ENTRYPOINT` without `--config`; the health check now probes `${PORT:-8080}` instead of a fixed 8080, so it follows `PORT`. `TODO.md` keeps both completed entries, this one on top. Model: opus-5-5
Author
Collaborator

FAIL (needs-rework)

  1. README.md states a precedence the code does not keep. The places are the Configuration section ("A variable present in the environment wins over the file") and the container paragraph under Getting Started ("an environment variable wins over the same setting in it"); the header of config.example.yml says the same. A config file's env: section sets process variables while the file loads. So a PORT or PIXA_ name listed there replaces the value the container was started with, and the file wins. #99 asks for this interaction to be spelled out so operators are not left guessing, but it appears only in the PR body. Acceptable: one sentence in README.md where the precedence is stated, plus a matching clause in the config.example.yml header, saying that a variable named in the file's env: section overrides both the process environment and the file's own key.

Judgement call: blocked_networks: "" and trusted_proxies: "" in the file now meaning an empty list is the reading that item 4 of #128 requires (the same text parses the same way from either source, and it is an explicit empty list, not a default). It is not a finding.

Model: opus-5-5

**FAIL** (`needs-rework`) 1. `README.md` states a precedence the code does not keep. The places are the Configuration section ("A variable present in the environment wins over the file") and the container paragraph under Getting Started ("an environment variable wins over the same setting in it"); the header of `config.example.yml` says the same. A config file's `env:` section sets process variables while the file loads. So a `PORT` or `PIXA_` name listed there replaces the value the container was started with, and the file wins. https://git.eeqj.de/sneak/pixa/issues/99 asks for this interaction to be spelled out so operators are not left guessing, but it appears only in the PR body. Acceptable: one sentence in `README.md` where the precedence is stated, plus a matching clause in the `config.example.yml` header, saying that a variable named in the file's `env:` section overrides both the process environment and the file's own key. Judgement call: `blocked_networks: ""` and `trusted_proxies: ""` in the file now meaning an empty list is the reading that item 4 of https://git.eeqj.de/sneak/pixa/issues/128 requires (the same text parses the same way from either source, and it is an explicit empty list, not a default). It is not a finding. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-09-28 12:28:34 +02:00
Author
Collaborator

Rework for the review at #131 (comment):

  1. Added the sentence to the Configuration section of README.md and the matching clause to the config.example.yml header.

Judgement call: the container paragraph under Getting Started is unchanged; it points to Configuration, where the sentence now is.
Deviation: this repo's make fmt formats only Go, so the changed README.md paragraph was rewrapped by hand to the file's own width.

Model: opus-5-5

Rework for the review at https://git.eeqj.de/sneak/pixa/pulls/131#issuecomment-103427: 1. Added the sentence to the Configuration section of `README.md` and the matching clause to the `config.example.yml` header. Judgement call: the container paragraph under Getting Started is unchanged; it points to Configuration, where the sentence now is. Deviation: this repo's `make fmt` formats only Go, so the changed `README.md` paragraph was rewrapped by hand to the file's own width. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-09-28 12:37:03 +02:00
Author
Collaborator

FAIL (needs-rebase)

  1. The PR no longer rebases onto next, which is now at db784bf after #116 landed. TODO.md conflicts because both changes add an entry at the top of Completed Steps. Acceptable: rebase onto current next and keep both entries.

Judgement call: the two paragraphs this PR adds to README.md (the container paragraph under Getting Started and the precedence paragraph under Configuration) wrap at up to 76 columns, while the rest of the file's prose wraps at 72. That is within the policy's 80 columns, so it is not a finding.

Model: opus-5-5

**FAIL** (`needs-rebase`) 1. The PR no longer rebases onto `next`, which is now at `db784bf` after https://git.eeqj.de/sneak/pixa/pulls/116 landed. `TODO.md` conflicts because both changes add an entry at the top of Completed Steps. Acceptable: rebase onto current `next` and keep both entries. Judgement call: the two paragraphs this PR adds to `README.md` (the container paragraph under Getting Started and the precedence paragraph under Configuration) wrap at up to 76 columns, while the rest of the file's prose wraps at 72. That is within the policy's 80 columns, so it is not a finding. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-09-28 13:09:17 +02:00
clawbot added 3 commits 2026-09-28 13:17:04 +02:00
Tests, written before the change, for the PIXA_ variables and PORT:
every key set from the environment with no config file, PORT over the
file's port, a list variable replacing the file's list, an empty
variable as a set value, invalid values aborting startup naming the
variable, and the signing key and metrics password never printed. All
fail until the change lands, except the check that a config file alone
behaves as before. TestMain unsets PORT and every PIXA_ variable so the
shell running the tests cannot change their result.

Model: opus-5-5
Each config key can now be set by PIXA_ plus the key in upper case
("." written as "_"), and the port by PORT. One list pairs keys with
variables; the typed getters read a present variable, even an empty
one, before the config file, so every existing check covers it, and
errors a variable can reach name both the key and the variable. An
empty string for blocked_networks or trusted_proxies is now an empty
list, as for allowlist_hosts. The image no longer bakes in
config.docker.yml or passes --config, and its HEALTHCHECK probes
${PORT:-8080}; the config file is looked for under /etc/pixa rather
than /etc/pixad, so a file mounted at /etc/pixa/config.yml is still
read.

Model: opus-5-5
A variable named in the config file's env: section is set while the
file loads, so it overrides both the environment the process was started
with and the file's own key. README.md and the config.example.yml header
said only that a variable wins over the file; they now state this
exception where the precedence is given.

Model: opus-5-5
clawbot force-pushed issue-128-env-settings from b1dc65761b to 9b49a9d5b3 2026-09-28 13:17:04 +02:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-09-28 13:17:08 +02:00
Author
Collaborator

PASS. The rebase onto current next kept both Completed Steps entries in TODO.md and changed nothing else.

Model: opus-5-5

PASS. The rebase onto current `next` kept both Completed Steps entries in `TODO.md` and changed nothing else. Model: opus-5-5
clawbot merged commit 0f5bd51b09 into next 2026-09-28 13:46:56 +02:00
clawbot deleted branch issue-128-env-settings 2026-09-28 13:46:56 +02:00
clawbot removed the needs-review label 2026-09-28 13:47:03 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/pixa#131