mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
The one remake in vm's Lifecycle (remake.go): the image built first, the agents' history exported and the home folder saved (home.go: the VM's tar stream filtered on the host), the VM stopped and its machine renamed aside (backend.Backend's Rename, limactl rename, vmname.Aside), the new machine made from vm.json, started, its home put back, then the old one deleted. A failure or interrupt before that puts the old VM back; a killed devvm leaves the remake section, which the next devvm or devvm layer add finishes. The VM keeps its ID (design.md). Co-Authored-By: Claude Opus 5.5 <[email protected]>
77 lines
2.6 KiB
Plaintext
77 lines
2.6 KiB
Plaintext
# devvm layer new NAME: a starter script and allowlist in the layers folder;
|
|
# bad, taken and existing names are refused.
|
|
env LAYERS=$XDG_CONFIG_HOME/devvm/layers
|
|
|
|
exec devvm layer new pg
|
|
stdout '^==> layer_created layer=pg policy=\S*/devvm/layers/pg\.policy script=\S*/devvm/layers/pg\.sh$'
|
|
exec bash -n $LAYERS/pg.sh
|
|
grep '^set -euo pipefail$' $LAYERS/pg.sh
|
|
grep '^# Hosts a VM with the pg layer can reach' $LAYERS/pg.policy
|
|
|
|
# It's a layer at once: images and --layers complete it, and it's among
|
|
# the layers.
|
|
exec devvm __complete build p
|
|
stdout '^pg$'
|
|
exec devvm __complete --layers p
|
|
stdout '^pg$'
|
|
! exec devvm build nope
|
|
stderr '^devvm: unknown_layer layer=nope layers=base desktop docker nix pg$'
|
|
# A shared tool is no layer: an image holds none.
|
|
! exec devvm build node+pg
|
|
stderr '^devvm: tool_not_layer tool=node$'
|
|
|
|
# An existing script is kept; an existing allowlist is kept for a new script.
|
|
! exec devvm layer new pg
|
|
stderr '^devvm: layer_exists file=\S*/devvm/layers/pg\.sh$'
|
|
cp mine.policy $LAYERS/db.policy
|
|
exec devvm layer new db
|
|
cmp $LAYERS/db.policy mine.policy
|
|
|
|
! exec devvm layer new node
|
|
stderr '^devvm: layer_name_reserved layer=node$'
|
|
! exec devvm layer new claude
|
|
stderr '^devvm: layer_name_reserved layer=claude$'
|
|
! exec devvm layer new base
|
|
stderr '^devvm: layer_name_reserved layer=base$'
|
|
! exec devvm layer new docker
|
|
stderr '^devvm: layer_name_reserved layer=docker$'
|
|
! exists $LAYERS/docker.sh
|
|
! exec devvm layer new nix
|
|
stderr '^devvm: layer_name_reserved layer=nix$'
|
|
! exists $LAYERS/nix.sh
|
|
! exec devvm layer new My_DB
|
|
stderr '^devvm: layer_name_invalid layer=My_DB$'
|
|
! exec devvm layer new ../x
|
|
stderr '^devvm: layer_name_invalid layer=\.\./x$'
|
|
! exec devvm layer new -- -x
|
|
stderr '^devvm: layer_name_invalid layer=-x$'
|
|
! exec devvm layer new
|
|
stderr '^devvm: arg_missing args=NAME command=devvm layer new$'
|
|
! exec devvm layer pg
|
|
stderr '^devvm: no_subcommand command=devvm layer commands=add, new given=pg$'
|
|
! exists $LAYERS/node.sh
|
|
! exists $LAYERS/My_DB.sh
|
|
|
|
# A layer may have a command's name: devvm takes no image as a word, so
|
|
# the layer is named only where a layer goes, and devvm stop stays the
|
|
# command.
|
|
exec devvm layer new log
|
|
exists $LAYERS/log.sh
|
|
exec devvm __complete build l
|
|
stdout '^log$'
|
|
! exec devvm log
|
|
stderr '^devvm: no_command_part flags=--layers log word=log$'
|
|
exec devvm layer new stop
|
|
exec devvm stop --help
|
|
stdout 'devvm stop \[flags\]'
|
|
rm $LAYERS/log.sh $LAYERS/log.policy $LAYERS/stop.sh $LAYERS/stop.policy
|
|
|
|
# A layers folder that can't be written to fails it.
|
|
rm $LAYERS
|
|
exec sh -c 'printf x > "$LAYERS"'
|
|
! exec devvm layer new web
|
|
stderr '^devvm: layer_new_failed reason='
|
|
|
|
-- mine.policy --
|
|
db.example.com
|