mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).
The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.
devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.
Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
121 lines
4.6 KiB
Plaintext
121 lines
4.6 KiB
Plaintext
# devvm update: the folder's VM moved to newer shared tools without a
|
|
# question, then made again from its own image's new build, after
|
|
# asking, when that image changed since the VM was made, keeping its
|
|
# settings and its home folder; a current VM is said to be so, and
|
|
# nothing runs. Each launch's outdated and newer-tools warnings name
|
|
# devvm update.
|
|
env LAYERS=$XDG_CONFIG_HOME/devvm/layers
|
|
|
|
# No VM.
|
|
project web
|
|
! exec devvm update --force
|
|
stderr '^devvm: no_vm dir=/\S*/web$'
|
|
|
|
# A VM of a layer of the user's, with ports, a rule and files in its
|
|
# project folder and its home.
|
|
exec devvm layer new foo
|
|
exec devvm --network open --no-git-protect --agents claude --layers foo --ports 3000
|
|
vm_name WEB web
|
|
exec devvm network allow example.com
|
|
exec sh -c 'echo kept > notes && mkdir -p "$STUB_DIR/vmhome-$WEB" && echo ls > "$STUB_DIR/vmhome-$WEB/.bash_history"'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^image=foo$'
|
|
|
|
# Current: said, and nothing runs.
|
|
stub_reset
|
|
exec devvm update
|
|
stdout '^==> vm_current image=foo vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl (stop|rename|clone|delete)'
|
|
|
|
# Only newer shared tools: each launch warns, naming devvm update, which
|
|
# moves the VM to them and opens a shell, asking nothing, even without a
|
|
# terminal.
|
|
json_set $WEB_dir/vm.json tools.made.files:=["claude-1.0.0-0123456789ab.erofs"]
|
|
exec devvm
|
|
stderr '^devvm: newer_tools tools=claude \S+$'
|
|
stub_reset
|
|
exec devvm update
|
|
stdout '^==> tools_switch vm=devvm-web-[0-9a-f]{14}$'
|
|
! stdout 'vm_current|vm_changed'
|
|
! stderr remake_confirm
|
|
stub_calls
|
|
! stdout 'limactl (stop|rename|clone|delete)'
|
|
stdout 'limactl shell --workdir /\S*/web devvm-web-[0-9a-f]{14}\n'
|
|
vm_state $WEB_dir/vm.json
|
|
! stdout 'claude-1\.0\.0'
|
|
|
|
# Its layer's script edited: each launch warns, naming devvm update.
|
|
exec sh -c 'echo "echo again" >> "$LAYERS/foo.sh"'
|
|
exec devvm
|
|
stderr 'vm_outdated changed=foo$'
|
|
|
|
# Without a terminal it refuses unless --force, before its tools change;
|
|
# in one it asks, and no keeps the VM.
|
|
json_set $WEB_dir/vm.json tools.made.files:=["claude-1.0.0-0123456789ab.erofs"]
|
|
stub_reset
|
|
! exec devvm update
|
|
stdout '^==> vm_changed changed=foo vm=devvm-web-[0-9a-f]{14}$'
|
|
stderr '^devvm: no_input answer=--force$'
|
|
! stdout tools_switch
|
|
vm_state $WEB_dir/vm.json
|
|
stdout 'claude-1\.0\.0'
|
|
# No keeps it with its newer tools, and opens a shell.
|
|
ttyin -stdin $WORK/no.txt
|
|
exec devvm update
|
|
stdout '^==> tools_switch vm=devvm-web-[0-9a-f]{14}$'
|
|
stderr '^remake_confirm image=foo vm=devvm-web-[0-9a-f]{14} \[y/N\] '
|
|
stdout '==> kept vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl (stop|rename|clone|delete)'
|
|
stdout 'limactl shell --workdir /\S*/web devvm-web-[0-9a-f]{14}\n'
|
|
vm_state $WEB_dir/vm.json
|
|
! stdout 'claude-1\.0\.0'
|
|
|
|
# --force: in order, the new build, the history exported, home saved, the
|
|
# VM stopped and set aside, made again from the same image name and
|
|
# started, home put back, the old machine deleted, then a shell.
|
|
stub_reset
|
|
exec devvm update --force
|
|
stdout '^==> building_image image=foo '
|
|
stdout '==> exported '
|
|
stdout '==> saving_home vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '==> creating_from image=foo vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '==> remade image=foo vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout 'tar -czf - --one-file-system.*\n(.*\n)*limactl stop devvm-web-[0-9a-f]{14}\n(.*\n)*limactl rename --tty=false devvm-web-[0-9a-f]{14} devvm-[0-9a-f]{14}-old\n(.*\n)*limactl clone --tty=false devvm-img-[0-9a-f]+ devvm-web-[0-9a-f]{14} .*\n(.*\n)*limactl start --tty=false devvm-web-[0-9a-f]{14}\n(.*\n)*.*tar -xzf - --skip-old-files.*\n(.*\n)*limactl delete -f devvm-[0-9a-f]{14}-old\n(.*\n)*limactl shell --workdir /\S*/web devvm-web-[0-9a-f]{14}\n'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^image=foo$'
|
|
stdout '^ports.forward=3000$'
|
|
stdout '^net.tier=open$'
|
|
stdout '^tools.names=claude$'
|
|
! stdout '^remake'
|
|
grep '^example\.com$' $WEB_dir/policy
|
|
grep '^kept$' notes
|
|
exec tar -tzf $STUB_DIR/home-in.tgz
|
|
stdout '^\.bash_history$'
|
|
|
|
# Current again: no warning, and devvm update does nothing.
|
|
exec devvm
|
|
! stderr vm_outdated
|
|
stub_reset
|
|
exec devvm update --force
|
|
stdout '^==> vm_current image=foo vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl (stop|rename|clone|delete)'
|
|
|
|
# Refused like devvm layer add: a --clone VM, and a parent folder's VM
|
|
# without a terminal.
|
|
exec sh -c 'echo "echo once more" >> "$LAYERS/foo.sh"'
|
|
json_set $WEB_dir/vm.json 'clone:={"on":true}'
|
|
! exec devvm update --force
|
|
stderr '^devvm: remake_clone vm=devvm-web-[0-9a-f]{14}$'
|
|
json_set $WEB_dir/vm.json 'clone:={}'
|
|
mkdir sub
|
|
cd sub
|
|
! exec devvm update --force
|
|
stderr '^devvm: remake_parent_vm command=devvm update dir=/\S*/web vm=devvm-web-[0-9a-f]{14}$'
|
|
|
|
-- no.txt --
|
|
n
|