mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -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]>
128 lines
4.9 KiB
Plaintext
128 lines
4.9 KiB
Plaintext
# devvm clone [on|off]: bare, it shows whether the folder's VM has its own
|
|
# clone of the repo. On makes a VM that mounts the folder again with its
|
|
# own clone instead, after asking, keeping its settings: nothing of the
|
|
# folder mounted, the repo's branches copied in as it starts, a git remote
|
|
# for it, and .git's locks taken off. Off checks the clone as devvm rm
|
|
# does, fetching the work this repo lacks first, then makes it again
|
|
# mounting the folder: .git locked as a new VM's, and the remote removed.
|
|
# (The stubs keep the VM's files in $STUB_DIR/vmfs.)
|
|
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
|
|
mkdir $WORK/web
|
|
cd $WORK/web
|
|
|
|
# Usage errors, before anything runs.
|
|
! exec devvm clone maybe
|
|
stderr '^devvm: arg_not_choice choices=on, off command=devvm clone given=maybe$'
|
|
! exec devvm clone on off
|
|
stderr '^devvm: args_too_many '
|
|
! exec devvm clone --json on
|
|
stderr '^devvm: json_shows_only command=devvm clone$'
|
|
! exec devvm clone --json --force
|
|
stderr '^devvm: json_shows_only command=devvm clone$'
|
|
|
|
# No VM.
|
|
! exec devvm clone
|
|
stderr '^devvm: no_vm dir=/\S*/web$'
|
|
! exec devvm clone on --force
|
|
stderr '^devvm: no_vm dir=/\S*/web$'
|
|
|
|
# A VM that mounts the folder, which is a repo with two branches.
|
|
exec git init -q -b main
|
|
exec git commit -q --allow-empty -m one
|
|
exec git branch other
|
|
exec devvm --network open
|
|
vm_name WEB web
|
|
exec devvm clone
|
|
stdout '\Aoff\n\z'
|
|
exec devvm clone --json
|
|
stdout '\A{\n "version": 1,\n "clone": "off"\n}\n\z'
|
|
! exec devvm --clone
|
|
stderr '^devvm: clone_needs_new_vm vm=devvm-web-[0-9a-f]{14}$'
|
|
|
|
# Without a terminal, on refuses unless --force; in one, it says what
|
|
# changes and asks, and no keeps the VM.
|
|
stub_reset
|
|
! exec devvm clone on
|
|
stderr '^devvm: no_input answer=--force$'
|
|
ttyin -stdin $WORK/no.txt
|
|
exec devvm clone on
|
|
stdout '^==> clone_switch_on vm=devvm-web-[0-9a-f]{14}$'
|
|
stderr '^remake_confirm image=base 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)'
|
|
|
|
# --force: made again with nothing of the folder mounted, its branches
|
|
# copied into its clone as it starts, the remote added, and on macOS
|
|
# .git's locks taken off.
|
|
stub_reset
|
|
exec devvm clone on --force
|
|
stdout '==> remade image=base vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^==> clone_ready branch=main remote=devvm$'
|
|
stub_calls
|
|
stdout 'limactl rename --tty=false devvm-web-[0-9a-f]{14} devvm-[0-9a-f]{14}-old\n'
|
|
stdout '^limactl clone --tty=false devvm-img-[0-9a-f]{12} devvm-web-[0-9a-f]{14} --mount-none --set \.mounts = \[\{"location":"[^"]*/data/devvm/tools","mountPoint":"/mnt/devvm-tools","writable":false\}\] '
|
|
stdout 'git-receive-pack ''/\S*/web''$'
|
|
stdout 'limactl delete -f devvm-[0-9a-f]{14}-old\n'
|
|
[darwin] stdout 'limactl delete -f devvm-[0-9a-f]{14}-old\n(.*\n)*chflags -R -P nouchg /\S*/web/\.git/config\n'
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^clone.on=true$'
|
|
stdout '^clone.made.remote=devvm$'
|
|
stdout '^clone.made.seeded=true$'
|
|
stdout '^git.mode=clone$'
|
|
! stdout '^remake'
|
|
exec git remote get-url devvm
|
|
stdout '^devvm-web-[0-9a-f]{14}:/\S*/web$'
|
|
exec sh -c 'git -C "$STUB_DIR/vmfs$(pwd -P)" branch --format="%(refname:short)"'
|
|
stdout '\Amain\nother\n\z'
|
|
exec devvm clone
|
|
stdout '\Aon\n\z'
|
|
|
|
# Again: said, and nothing made.
|
|
stub_reset
|
|
exec devvm clone on --force
|
|
stdout '^==> setting_already command=devvm clone on vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl (stop|rename|clone)'
|
|
|
|
# Off: the VM's own commit isn't fetched, so without a terminal it
|
|
# refuses, --force or not, and keeps the VM as it is.
|
|
exec sh -c 'git -C "$STUB_DIR/vmfs$(pwd -P)" commit -q --allow-empty -m from-vm'
|
|
stub_reset
|
|
! exec devvm clone off --force
|
|
stdout '^unfetched_commits refs="main"$'
|
|
stderr '^devvm: no_terminal_fetch command=devvm clone off remote=devvm$'
|
|
stub_calls
|
|
! stdout 'limactl (rename|clone)'
|
|
|
|
# In a terminal, the work is fetched into saved/devvm/*, then the VM is
|
|
# made again mounting the folder: the remote removed, then .git locked,
|
|
# before it starts.
|
|
stub_reset
|
|
ttyin -stdin $WORK/yes.txt
|
|
exec devvm clone off --force
|
|
stdout '^==> clone_switch_off vm=devvm-web-[0-9a-f]{14}$'
|
|
stderr 'fetch_before_delete prefix=saved/devvm'
|
|
stdout '==> saved_branches branches="saved/devvm/main"$'
|
|
stdout '==> removed_remote remote=devvm\n(.*\n)*==> starting vm=devvm-web-[0-9a-f]{14}\n'
|
|
stdout '==> remade image=base vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl clone --tty=false devvm-img-[0-9a-f]{12} devvm-web-[0-9a-f]{14} --mount-none --set \.mounts = \[.*"location":"/\S*/web","writable":true'
|
|
[darwin] stdout '^chflags -R -P uchg /\S*/web/\.git/config\n(.*\n)*limactl start --tty=false devvm-web-[0-9a-f]{14}\n'
|
|
exec git log --format=%s -1 saved/devvm/main
|
|
stdout '^from-vm$'
|
|
! exec git remote get-url devvm
|
|
vm_state $WEB_dir/vm.json
|
|
! stdout '^clone\.(on=true|made)'
|
|
[darwin] stdout '^git.mode=on$'
|
|
[linux] stdout '^git.mode=off$'
|
|
! stdout '^remake'
|
|
exec devvm clone
|
|
stdout '\Aoff\n\z'
|
|
exec devvm rm --force --no-export
|
|
|
|
-- no.txt --
|
|
n
|
|
-- yes.txt --
|
|
y
|