mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]>
63 lines
2.3 KiB
Plaintext
63 lines
2.3 KiB
Plaintext
# On a Linux host that pins (DEVVM_PINS stands in for devvm's check of the
|
|
# kernel), .git protection is on: a new VM's start pins .git in QEMU's
|
|
# namespace, which the stub limactl doesn't run, so this checks devvm's
|
|
# side: the mode, devvm git-protect, and the launches' warnings. A VM left
|
|
# off by a host that couldn't lock is told it can be locked now; a VM
|
|
# that's on doesn't start where the host can't pin, until it's off.
|
|
[!linux] skip 'macOS locks .git on the host: git_protect.txtar'
|
|
env DEVVM_PINS=on
|
|
|
|
project web git
|
|
exec devvm --network open
|
|
vm_name WEB web
|
|
! stderr git_unprotected
|
|
exec devvm git-protect
|
|
stdout '\Aon\n\z'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^git.mode=on$'
|
|
stdout '^git.made.protected=true$'
|
|
|
|
# A running VM's change waits for its next stop, as on macOS.
|
|
exec devvm git-protect on
|
|
stdout '^==> git_protect_next_stop mode=on vm=devvm-web-[0-9a-f]{14}$'
|
|
exec devvm stop
|
|
stdout '^==> git_locked vm=devvm-web-[0-9a-f]{14}$'
|
|
|
|
# A VM an earlier devvm left strict: the launch's check takes strict's
|
|
# diff.ignoreSubmodules = all out and says so, and the start pins .git as
|
|
# it does when it's on. devvm's own change is in the watch's sums, so the
|
|
# next check names nothing.
|
|
json_set $WEB_dir/vm.json git.mode=strict
|
|
exec git config --file .git/config diff.ignoreSubmodules all
|
|
exec devvm
|
|
stderr '^devvm: git_strict_converted vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec git config --file .git/config diff.ignoreSubmodules
|
|
grep '\{"path":"\.git/config","read_only":true\}' $WEB_dir/run/git-pins.json
|
|
exec devvm stop
|
|
! stderr 'git_changed|git_strict'
|
|
|
|
# The host can't pin any more: the VM that's on doesn't start, and says
|
|
# what it lacks, until devvm git-protect off.
|
|
env DEVVM_PINS='refused by this kernel'
|
|
! exec devvm
|
|
stderr '^devvm: backend_lacks backend=lima feature=read-only-paths what=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm git-protect on
|
|
stderr '^devvm: git_protect_on_needs_locks$'
|
|
exec devvm git-protect off
|
|
exec devvm
|
|
! stderr backend_lacks
|
|
|
|
# Made off by a host that couldn't lock (not the user's choice): once the
|
|
# host can, each launch says so.
|
|
project api git
|
|
exec devvm --network open
|
|
vm_name API api
|
|
stderr '^devvm: git_unprotected vm=devvm-api-[0-9a-f]{14}$'
|
|
env DEVVM_PINS=on
|
|
exec devvm
|
|
stderr '^devvm: git_protect_available vm=devvm-api-[0-9a-f]{14}$'
|
|
exec devvm stop
|
|
exec devvm git-protect off
|
|
exec devvm
|
|
! stderr git_protect_available
|