Stages (test, prod, …)
With stages a project has its own values per environment, for example a different DB_PASSWORD for test and for production. Each stage is a separate encrypted file with its own values and its own recipients: whoever only works on test does not have to be able to read prod.
Files and names
./secrets.enc # no stage ./secrets.test.enc # stage test ./secrets.prod.enc # stage prod
Stage names have 1 to 32 characters from a-z, 0-9, - and _; - and _ not at the start. Upper case is converted to lower case, Prod becomes prod.
Choosing a stage
Every command works on the file of a stage with --stage NAME. For several commands in a row or in CI, set the environment variable SECRETS_TOOL_STAGE instead:
secrets-tool --stage prod set DB_PASSWORD "..." secrets-tool --stage prod load $env:SECRETS_TOOL_STAGE = "prod" # PowerShell: applies to all following commands export SECRETS_TOOL_STAGE=prod # Bash
--file and --stage cannot be combined, since the stage is part of the file name. An explicit --file takes precedence over SECRETS_TOOL_STAGE. A typo? If the file of the chosen stage does not exist but the folder has other stages (e.g. with --stage prdo), the CLI stops with a hint listing the existing stages instead of silently carrying on with an empty file. If the name is missing altogether (secrets-tool load --stage at the end of the line), it stops as well (from 0.9.1.22).
Creating a new stage
secrets-tool stages new prod # from the current file secrets-tool stages new prod --from test # from the stage test secrets-tool --stage prod set DB_PASSWORD "..." # enter values secrets-tool --stage prod list-recipients # check recipients secrets-tool --stage prod remove-recipient HASH # whoever should not read prod
stages new NAME copies from the source stage (default: the current file, another one with --from STAGE) the recipients, as verified during decryption, and all names without values. That way no name is missing in the new stage and you only enter the values. --no-names (German --ohne-namen) leaves the names out. Remove whoever should not read prod afterwards with remove-recipient.
Overview and comparison
secrets-tool stages lists, without asking for a password, the stage files in the folder with number of recipients, whether you have access, and the link to the web app; the active stage is marked with *. secrets-tool stages diff shows which names are missing or empty in which stage, without arguments across all stages in the folder, with stages diff test prod only across those two. It never shows values.
In the interactive menu
The entry Stage: … switches the stage, creates a new one and compares stages. The header always shows the active stage, e.g. PROD · READY, so nobody works in prod by accident.
In the web app
Projects have stages on the web too. Projects with the same name share one row in the project list, with a badge per stage; on the project page tabs switch between the stages. + Stage and Create stage create a new stage with the same recipients and copy the project's members, optionally also the names without values; tenant owners and admins can do this. For prod, narrow the access afterwards under Access. Each stage counts as one project for the fair-use limit.
Syncing with the server
remote pull and remote push match by project name and stage; the stage comes from the file name.
secrets-tool --stage prod remote pull shop-backend # fetches ./secrets.prod.enc secrets-tool --stage prod remote push # uploads the stage
A stage created locally with stages new is uploaded with secrets-tool --stage prod remote push without a name: the CLI takes the project name from the link of another stage in the same folder and creates the stage on the server. If you are a tenant owner or admin, the members are copied; otherwise the stage is created without members and you share it in the web app. remote projects shows the stage in its own column as soon as there are stages. Each stage has its own link file, e.g. secrets.prod.enc.remote; it belongs in .gitignore as well.