Loading
Let a lab move between state dirs: SIM_STATE_DIR, export and import
What
A lab can now live in any state dir and move between them.
SIM_STATE_DIRsets the state dir for the engine, providers, preflight, multiplexer, receipts and the token-config dir. The default stays~/.gitlab-simulation.- Per-lab file paths (
root_password_file,ssh_key_file,gitlab_ca_cert) are stored relative to the state dir and resolved at read time. A record written with absolute paths keeps working, and the status JSON still carries absolute paths. just lab export --instance <name> --out <file>writes one lab's files as a mode 0600 tarball. It holds no other lab, no pointer and no token-config, and it refuses a lab that is mid-create.just lab import --in <file> [--force]unpacks into the current state dir. It refuses an existing record without--force, an archive with two labs, a link, and an absolute or..path.- operations.md gains one paragraph, with the warning that the export holds the root password and SSH key. Equal words were cut elsewhere, so the word budget stays at 40489.
Closes #55 (closed)
Proof
state-dir-selftest.sh is new and runs in just test. Each group goes red when its change is reverted:
| Reverted | Red |
|---|---|
STATE_DIR ignores SIM_STATE_DIR |
27 checks, the record, key, password and receipt locations |
receipts written under HOME |
4 checks |
| key gate compares full paths | the absolute-record gate check |
| status keeps the stored path | the key path resolves under the current dir |
export without umask 077 and chmod 600 |
the archive is mode 600 |
| export packs whole subtrees | it holds no other lab's file, plus the import checks that follow |
| import accepts a link, two labs, or an existing record | one named refusal check each |
import validation and tar path guards removed |
the trav archive is accepted |
| import drops evidence | the files after are the files before |
The traversal check is one of four layers (member-name check, lab-name check, one-lab check, then tar), so it only goes red when the others go too.
engine-selftest.sh changes two assertions: the record stores state/<name>.ssh, and status resolves it.
Live, on a caproni --no-gitlab lab with a state dir named A and an empty one named B:
upin A, thenexport(3 paths, mode 600).- A renamed away, then
importinto B. - From B,
status --json --live,sshthrough IAP using the imported key, anddownall worked. - No instance, disk, snapshot, address or firewall rule for the lab remains, and nothing was written under
~/.gitlab-simulation.