Configuration should prefer environment variables per CODE_STYLEGUIDE #10

Closed
opened 2026-03-01 19:07:55 +01:00 by clawbot · 0 comments
Collaborator

Per CODE_STYLEGUIDE rule: "Almost all services/servers should accept their configuration via environment variables. Only go full config file if absolutely necessary."

The current internal/config/config.go uses a custom pkg/config package that wraps Viper with a YAML-based multi-environment config file format (with configDefaults, environments.dev.config, environments.prod.config sections, and value resolution via $ENV:, $GSM:, $ASM:, $FILE: prefixes). This is significantly more complex than the standard Viper + AutomaticEnv() pattern from GO_HTTP_SERVER_CONVENTIONS §8.

Additionally, the example config file (configs/config.yaml.example) references PostgreSQL (dburl: postgres://...) but the application uses SQLite.

Recommendation: Simplify to use Viper directly with AutomaticEnv() as the primary configuration method, with optional config file fallback. Environment variable names should be WEBHOOKER_PORT, WEBHOOKER_DBURL, etc. The pkg/config package could remain as a library but the internal config should follow the standard pattern.

Per CODE_STYLEGUIDE rule: "Almost all services/servers should accept their configuration via environment variables. Only go full config file if absolutely necessary." The current `internal/config/config.go` uses a custom `pkg/config` package that wraps Viper with a YAML-based multi-environment config file format (with `configDefaults`, `environments.dev.config`, `environments.prod.config` sections, and value resolution via `$ENV:`, `$GSM:`, `$ASM:`, `$FILE:` prefixes). This is significantly more complex than the standard Viper + `AutomaticEnv()` pattern from GO_HTTP_SERVER_CONVENTIONS §8. Additionally, the example config file (`configs/config.yaml.example`) references PostgreSQL (`dburl: postgres://...`) but the application uses SQLite. Recommendation: Simplify to use Viper directly with `AutomaticEnv()` as the primary configuration method, with optional config file fallback. Environment variable names should be `WEBHOOKER_PORT`, `WEBHOOKER_DBURL`, etc. The `pkg/config` package could remain as a library but the internal config should follow the standard pattern.
clawbot added the
bot
label 2026-03-01 19:07:55 +01:00
sneak closed this issue 2026-03-04 01:19:43 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/webhooker#10
No description provided.