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]>
103 lines
5.3 KiB
Plaintext
103 lines
5.3 KiB
Plaintext
# images: the images, by name, unfinished builds last, each with what its
|
|
# base started from, its digest, key, state and size; then the shared tool
|
|
# images by the name images have them by, each with the C library it's
|
|
# built for; then the total. Project VMs aren't images. Listing never
|
|
# resolves the tools lock.
|
|
env IMAGES=$XDG_DATA_HOME/devvm/images
|
|
env SHARE=$XDG_DATA_HOME/devvm/tools
|
|
|
|
# Nothing built: the headers, and every name not installed.
|
|
exec devvm images
|
|
stdout '^IMAGE +FROM +DIGEST +KEY +STATE +SIZE\n\nNAME +TOOL +VERSION +LIBC +SIZE +VMS +STATE\n'
|
|
stdout '^node +- +- +- +- +- +not installed$'
|
|
stdout '^opencode +- +- +- +- +- +not installed$'
|
|
stderr '^images_total size=0B$'
|
|
! stderr images_unused
|
|
stub_calls
|
|
stdout '^limactl list --json\n\z'
|
|
|
|
# base, foo on it, a build that didn't finish, and a project VM.
|
|
mkdir $XDG_CONFIG_HOME/devvm/layers
|
|
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
|
|
exec devvm build foo
|
|
exec stub vm devvm-img-000000000000 Stopped
|
|
exec stub vm devvm-proj-12345612345601 Stopped
|
|
exec sh -c 'for i in base foo; do grep -lxF " \"name\": \"$i\"," "$IMAGES"/*/record.json | xargs dirname | xargs basename > "$i.key"; done'
|
|
exec devvm images
|
|
stdout '^base +ubuntu 26\.04 \(\d{8}\) +[0-9a-f]{12} +[0-9a-f]{12} +current +\S+\nfoo +ubuntu 26\.04 \(\d{8}\) +[0-9a-f]{12} +[0-9a-f]{12} +current +\S+\n- +- +- +000000000000 +unfinished +-\n\n'
|
|
! stdout devvm-proj
|
|
# An edited script: foo is stale.
|
|
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"'
|
|
exec devvm images
|
|
stdout '^foo +ubuntu .* +stale +\S+$'
|
|
|
|
# --backend is no flag of devvm's.
|
|
! exec devvm images --backend lima
|
|
stderr '^devvm: flag_unknown command=devvm images flag=--backend$'
|
|
|
|
# Shared tools: each version newest first, how many VMs list it, and
|
|
# whether it's the lock's; the lock's go, not built, and an older one no
|
|
# VM uses. claude's built for a VM that's gone since.
|
|
project ag
|
|
exec devvm --tools none --agents claude --network open --no-git-protect
|
|
exec devvm rm --force --no-export
|
|
cd $WORK
|
|
exec sh -c 'cd "$SHARE" && : > go-1.20.0-0123456789ab.erofs && : > go-1.9.0-0123456789ab.erofs'
|
|
json_set $SHARE/go-1.20.0-0123456789ab.erofs.json sha256=x libc=musl backend=lima built=2020-01-01T00:00:00Z
|
|
mkdir $VMS/12345612345602
|
|
exec sh -c 'printf "{\"version\": 1, \"id\": \"x\", \"name\": \"devvm-p-12345612345602\", \"image\": \"base\", \"dir\": \"/p\", \"backend\": \"lima\", \"created\": \"2020-01-01T00:00:00Z\", \"tools\": {\"names\": [\"claude\", \"go\"], \"made\": {\"libc\": \"musl\", \"files\": [\"%s\", \"go-1.20.0-0123456789ab.erofs\"]}}}\n" "$(cd "$SHARE" && ls claude-*.erofs)" > "$VMS/12345612345602/vm.json"'
|
|
stub_reset
|
|
exec devvm images
|
|
# The lock's go isn't built; the old go has the C library its record
|
|
# names, the oldest, without a record, none; claude's build says its own.
|
|
stdout '^go +go +1\.27\.2 +- +- +- +not built\ngo +go +1\.20\.0 +musl +\S+ +1 +in use\ngo +go +1\.9\.0 +- +\S+ +0 +unused\n'
|
|
stdout '^claude +claude +2\.1\.295 +gnu +\S+ +1 +current$'
|
|
stderr '^images_total size=\S+$'
|
|
stdout '^node +- '
|
|
stub_calls
|
|
! stdout mise
|
|
# --json: the same as fields, sizes in bytes; the notes stay on stderr.
|
|
exec devvm images --json
|
|
stdout '^{\n "version": 1,\n "images": \[\n {\n "name": "base",\n "from": "ubuntu 26\.04 \(\d{8}\)",\n "digest": "sha256:[0-9a-f]{64}",\n "key": "[0-9a-f]{12}",\n "state": "current",\n "size": \d+,\n "sized": true,\n "backend": "lima"\n'
|
|
stdout '^ "name": "go",\n "tool": "go",\n "version": "1\.20\.0",\n "built": true,\n "backend": "lima",\n "libc": "musl",\n "size": \d+,\n "vms": 1,\n "state": "in use"\n'
|
|
stdout '^ "name": "go",\n "tool": "go",\n "version": "1\.27\.2",\n "built": false,\n "size": 0,\n "vms": 0,\n "state": "not built"\n'
|
|
stdout '^ "total": \d+,\n "unused_tools": \d+,\n "nix_cache": {\n "files": 0,\n "size": 0,\n "cap": \d+\n }\n}\n\z'
|
|
stderr '^images_total size=\S+$'
|
|
! stdout '^IMAGE'
|
|
|
|
# images rm: by key (an unfinished build), or by name; nothing else.
|
|
# A name is its image as it is now: foo is current again.
|
|
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
|
|
! exec devvm images rm 000000000000 base+foo
|
|
stderr '^images_rm_confirm images=000000000000 base\+foo\ndevvm: no_input answer=--force$'
|
|
exec devvm images rm --force 000000000000 base+foo
|
|
stdout '^==> deleted_unfinished_build key=000000000000$'
|
|
stdout '^==> deleted_image image=foo key=[0-9a-f]{12}$'
|
|
exec sh -c 'grep "^limactl delete" "$STUB_LOG"'
|
|
stdout '^limactl delete -f devvm-img-000000000000$'
|
|
! stdout 'devvm-proj'
|
|
exec sh -c '! test -e "$IMAGES/$(cat foo.key)"'
|
|
|
|
# A key no image has, a name no layer has, what isn't built and shared
|
|
# tools: errors, and nothing is deleted.
|
|
stub_reset
|
|
! exec devvm images rm --force fedcba987654
|
|
stderr '^devvm: unknown_layer '
|
|
! exec devvm images rm --force base nope
|
|
stderr '^devvm: unknown_layer .*layer=nope'
|
|
! exec devvm images rm --force foo
|
|
stderr '^devvm: no_image_named image=foo$'
|
|
! exec devvm images rm --force node+foo
|
|
stderr '^devvm: tool_not_layer tool=node$'
|
|
! exec devvm images rm --force --from node:24 base
|
|
stderr '^devvm: no_image_named_from '
|
|
! exec devvm images rm
|
|
stderr '^devvm: arg_missing args=IMAGE\|KEY\.\.\. command=devvm images rm$'
|
|
exec sh -c 'grep -c "^limactl delete" "$STUB_LOG" || true'
|
|
stdout '^0$'
|
|
exec sh -c 'test -e "$IMAGES/$(cat base.key)"'
|
|
|
|
-- foo.sh --
|
|
#!/bin/bash
|
|
echo foo
|