Projects and secrets
A project you work on in goinfre disappears when you change machines. 42space remembers two things about each repo, its git remote and its secret files, and on another machine clones it again (if it isn't there already) and puts the secrets back.
42space add repo:/goinfre/$USER/myproject
syncing repo myproject: git@github.com:you/myproject.git → {goinfre}/myproject
secret files: .env, certs/dev.pem
kept in ~/.local/state/42space/secrets/myproject (HOME, mode 600), never in git; linked into the repo
How secrets are kept
Git-ignored files whose names look like secrets are found automatically:
.env, .env.*, *.pem, *.key, *.p12, id_rsa*, credentials*.json,
anything with secret in its name, and a few more. Templates such as
.env.example are skipped. Add other files with --secret:
42space add repo:/goinfre/$USER/myproject --secret config/local.json
Each secret moves to ~/.local/state/42space/secrets/<repo>/ with private
permissions, and the file in the project becomes a symlink to it:
- Never in git. The secrets folder is outside the environment repo, so it is never committed or pushed. It reaches your other machines because HOME follows you.
- One copy. Every machine reads and edits the same file through the link.
- Nothing lost. If a machine has a different copy of a secret, the newer
one is kept and the other is saved next to it as a
.bak.
Only git-ignored files are synced this way. Files committed to the repo
already travel with it, and 42space warns when a secret isn't in .gitignore.
On another machine
42space sync (which runs at login) clones every synced repo that is missing,
then links its secrets. Existing clones are never touched. Credentials are
never prompted for, so set up an SSH key in ~/.ssh (HOME) once.
Other machines clone from the remote, so commit and push before you leave a
machine. 42space add warns about unpushed commits.
Finding repos
42space scan && 42space review
The scan offers every repo in goinfre that isn't synced, explains what to do for repos without a remote, and offers new secret files that appear in synced repos.
Inspect and stop
42space repos # is each repo cloned, are its secrets linked?
42space remove repo:myproject --secret .env # stop syncing one file (a real copy stays)
42space remove repo:myproject # stop syncing the repo (the clone stays)
Tools that refuse symlinks, such as a Docker COPY .env, need that secret
removed from syncing so a plain copy stays.