mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -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]>
45 lines
1.7 KiB
Plaintext
45 lines
1.7 KiB
Plaintext
# A backend a VM uses that can't list its images: gc warns, leaves
|
|
# everything of that backend's alone (its images, its shared tool images
|
|
# and those without a record naming their backend, its VMs' leftovers),
|
|
# and succeeds. devvm images still fails.
|
|
env SHARE=$XDG_DATA_HOME/devvm/tools
|
|
|
|
# foo on Lima, made stale.
|
|
mkdir $XDG_CONFIG_HOME/devvm/layers
|
|
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
|
|
exec devvm build foo
|
|
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"'
|
|
|
|
# Unused tool images: one recorded as Lima's, one nobody can tell;
|
|
# claude's build, for a VM that's gone since, makes the lock, so they're
|
|
# unused.
|
|
project ag
|
|
exec devvm --tools none --agents claude --network open --no-git-protect
|
|
exec devvm rm --force --no-export
|
|
exec sh -c 'cd "$SHARE" && for v in 1.2.0 1.3.0; do echo x > go-$v-0123456789ab.erofs; done'
|
|
json_set $SHARE/go-1.2.0-0123456789ab.erofs.json sha256=x libc=gnu backend=lima built=2020-01-01T00:00:00Z
|
|
|
|
# A Lima VM that's gone, so Lima is used; then Lima stops answering.
|
|
mkdir $VMS/12345612345612
|
|
json_set $VMS/12345612345612/vm.json version:=1 id=x name=devvm-gone-12345612345612 image=base dir=/p/gone backend=lima created=2020-01-01T00:00:00Z net.tier=open
|
|
exec touch -t 202001010000 $VMS/12345612345612/vm.json
|
|
exec sh -c 'touch "$STUB_DIR/list-fails"'
|
|
|
|
exec devvm gc --force --orphans
|
|
stderr '^devvm: gc_backend_skipped backend=lima$'
|
|
stderr '^gc_orphans_unknown backend=lima$'
|
|
! stderr gc_failed
|
|
! stdout '^gc_image '
|
|
! stdout '^gc_orphan'
|
|
exists $VMS/12345612345612/vm.json
|
|
exists $SHARE/go-1.2.0-0123456789ab.erofs
|
|
exists $SHARE/go-1.3.0-0123456789ab.erofs
|
|
|
|
# devvm images lists every backend's or none.
|
|
! exec devvm images
|
|
stderr '^devvm: images_failed '
|
|
|
|
-- foo.sh --
|
|
#!/bin/bash
|
|
echo foo
|