Add an Environment Variable
A backend variable has three homes: the code that reads it, its value per environment, and the docs. Values never go in the backend repo, and nobody sets them in the Northflank UI by hand.
1. The code
- Read and validate it in
internal/app/env-setup.go. - Add it to
.env.example, with a comment if the meaning isn't obvious. - Add it to Backend Configuration.
A required variable that is missing stops the api at boot. On a deploy, the new container then never becomes ready, and the old one keeps serving.
2. The value, per environment
A plain value (a URL, a bucket name, a flag) goes in qubital-infra:
- Open a pull request that adds the key to the
apinode'sruntimeEnvironmentin bothstaging/backend.jsonandproduction/backend.json. The two files must declare the same keys (validate rule 8); use""where an environment doesn't use it. - After review, merge it. Merging deploys: each environment's api restarts once to pick up the value. The prod restart is a rolling one; prod's current code ignores a key it doesn't read.
A secret (a key, a password, a token) goes in a Northflank secret group:
- In Northflank, open the project (
qubital-staging, thenqubital-prod) → Secrets → the group (api-secretsfor the api) → add the key with its value → save. - Restart dependents from the group page in the same sitting, or the value goes live at some later, untested restart.
- Open a pull request in
qubital-infraadding the key name to that group instaging/secret-groups.yamlandproduction/secret-groups.yaml. Never the value. A key must never also appear in a template file: a service-level key silently overrides the group's (validate rule 4).
3. The order
Set the value in both environments before merging the code that requires it: staging deploys on that merge, and the next prod release would ship it. A variable the code only reads optionally can follow in any order.
To change an existing value later, it's the same pull request (plain value) or the same group edit plus restart dependents (secret).