mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
A global --no-input (persistent on the root, with --help and -v): no question is asked or read. The ui's prompts (Ask, Confirm, Answer, Secret, Pick/PickOne in a terminal) show the question, then fail with no_input naming what answers it (msg.AnswerFor, by the question's ID), or no_input_terminal for a question only a terminal answers. ui.Flags and SetFlags carry -v and --no-input. Answers: --network-policy/--no-network-policy, --here, devvm size -g, devvm setup --features/--backend, devvm network -g, devvm ssh-agent add, devvm restart, --ssh-config (new, on devvm, host and code: the Include line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude), --stdin, and --force. --force (-f) only skips a confirmation, and destructive commands need it without a terminal (force_needed, a failure, not a usage error): rm (new rm_confirm), gc (it went ahead without a terminal), gc --caches (now allowed without a terminal with --force), images rm (images_rm_confirm), secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images are built on the one rebuilt (build.Env.Force). rm --no-export skips the export; rm's parent-folder, earlier-folder and --clone confirmations are terminal-only and --force never answers them (vm.RmOptions). gc --tools --force splits: --recent (only with --tools, gc_recent_needs_tools) drops the hour's hold and keeps the refusal while a VM is being made (gc_recent_making); gc_tools_recent names devvm gc --tools --recent. gc_caches_need_terminal goes. Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt (--force), TestRebuild (force_needed, then Force); secret, rebuild, images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images rm/secret rm/rebuild with --force (and --no-export where rm -f skipped the export), and the clone section's rm with its checks. Docs: commands.md (Questions devvm asks, rm, flags), first-vm, clone, images (cleaning up, --recent), space, coding-agents, internals overview and images; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
369 lines
20 KiB
Plaintext
369 lines
20 KiB
Plaintext
# The docker backend (experimental), on the docker stub: its checks, base
|
|
# built by committing a container, a project VM made from it with its
|
|
# mounts and its own home volume, made again when its mounts change, and
|
|
# the features it lacks refused in one line naming the VM. The stub is a
|
|
# Linux engine of this machine's (DEVVM_DOCKER_KIND, read by test builds),
|
|
# where builds are confined; on Docker Desktop their confinement is
|
|
# emulated, through a proxy of devvm's. Registries
|
|
# are never reached: the pinned image needs no lookup, and HTTPS_PROXY
|
|
# points at nothing.
|
|
env DEVVM_MESSAGES=names
|
|
env DEVVM_DOCKER_KIND=linux
|
|
env VMS=$XDG_DATA_HOME/devvm/vms
|
|
env HTTPS_PROXY=http://127.0.0.1:9
|
|
env https_proxy=http://127.0.0.1:9
|
|
env PIN=ubuntu:26.04@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
# Its checks: an engine it reaches, which doctor names; one the user can't
|
|
# reach, with the fix.
|
|
exec devvm doctor --backend docker
|
|
stdout '^docker_engine_linux version=29\.1\.3$'
|
|
stdout '^doctor_ok backend=docker version=\S+$'
|
|
stdout '^FEATURE +DOCKER +LIMA +SMOLVM$'
|
|
stdout '^build-confinement +native +native +native$'
|
|
stdout '^egress-proxy +emulated +native +emulated$'
|
|
stdout '^ssh +emulated +native +emulated$'
|
|
stdout '^ports-all +emulated +emulated +emulated$'
|
|
stdout '^agent-toggle +emulated +native +emulated$'
|
|
stdout '^docker-layer +none +native +native$'
|
|
! stdout docker_sysbox
|
|
exec sh -c ': > "$STUB_DIR/docker-denied"'
|
|
! exec devvm doctor --backend docker
|
|
stderr '^devvm: docker_access fix=sudo usermod -aG docker \S+$'
|
|
rm $STUB_DIR/docker-denied
|
|
|
|
# Base: the image pulled by its digest, a labelled container from it with
|
|
# base.yaml's size, prepared, its scripts run between the stand-ins, then
|
|
# committed as devvm's image and deleted. Every container devvm makes sets
|
|
# the proxy variables empty, so the Docker client's own proxies stay out.
|
|
# Without a company proxy, the build is on Docker's own network, with no
|
|
# proxy of devvm's (from here on, until the company proxy's own case at the
|
|
# end: its builds need devvm's Linux build).
|
|
env HTTPS_PROXY=
|
|
env https_proxy=
|
|
exec devvm --backend docker --from $PIN build base
|
|
stdout '^==> building_image_from from=ubuntu:26\.04@sha256:a+ image=base key=[0-9a-f]{12}$'
|
|
stub_calls
|
|
stdout '^docker image pull ubuntu:26\.04@sha256:a+$'
|
|
stdout '^docker container create --name devvm-img-[0-9a-f]{12}-[0-9a-f]{8} --label devvm\.data=\S+/data/devvm --label devvm\.key=[0-9a-f]{12} --label devvm\.kind=build --init --user 0:0 --entrypoint sleep -e HTTP_PROXY= -e http_proxy= -e HTTPS_PROXY= -e https_proxy= -e FTP_PROXY= -e ftp_proxy= -e NO_PROXY= -e no_proxy= -e ALL_PROXY= -e all_proxy= --cpus 4 --memory \d+m --memory-swap \d+m --hostname devvm-build --network bridge ubuntu:26\.04@sha256:a+ infinity$'
|
|
stdout '^docker container start devvm-img-[0-9a-f]{12}-[0-9a-f]{8}$'
|
|
stdout '^docker exec -i -u 0 devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -s -- \S+ \d+( \d+)?$'
|
|
stdout '^docker exec -i -u 0 devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -s -- on$'
|
|
stdout '^docker exec -i -u \S+ -w / .* devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -c .* sh bash -s$'
|
|
stdout '^docker exec -i -u 0 devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -s -- off$'
|
|
! stdout 'env-file|-proxy '
|
|
stdout '^docker container commit --change LABEL devvm\.kind=image --change LABEL devvm\.key=[0-9a-f]{12} devvm-img-[0-9a-f]{12}-[0-9a-f]{8} devvm-[0-9a-f]{8}:[0-9a-f]{12}$'
|
|
stdout '^docker container rm -f -v devvm-img-[0-9a-f]{12}-[0-9a-f]{8}$'
|
|
! stdout limactl
|
|
exec devvm images
|
|
stdout '^base +ubuntu:26\.04@sha256:a+ +a{12} +[0-9a-f]{12} +current +\S+ +docker$'
|
|
|
|
# What it lacks is refused in one line naming the VM, before anything is
|
|
# made: a disk size; the docker layer without Sysbox, saying to install it
|
|
# on this Linux engine (on Docker Desktop, to use a VM backend).
|
|
mkdir $WORK/web
|
|
cd $WORK/web
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none --disk 200 base
|
|
stderr '^devvm: backend_lacks backend=docker feature=disk vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none docker
|
|
stderr '^devvm: docker_layer_no_sysbox vm=devvm-web-[0-9a-f]{14}$'
|
|
env DEVVM_DOCKER_KIND=desktop
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none docker
|
|
stderr '^devvm: docker_layer_needs_vm vm=devvm-web-[0-9a-f]{14}$'
|
|
env DEVVM_DOCKER_KIND=linux
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none nix
|
|
stderr '^devvm: backend_lacks backend=docker feature=nix-layer vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm --backend docker --from $PIN build nix
|
|
stderr '^devvm: backend_lacks backend=docker feature=nix-layer vm=\S+$'
|
|
stub_calls
|
|
! stdout 'container create'
|
|
! exists $VMS
|
|
|
|
# A VM: its home a volume of its own, the project folder bind-mounted,
|
|
# the tools volume read-only, its hostname the folder's; started, its
|
|
# services run without Docker's daemon and with its sshd's config, set
|
|
# up, then the shell, an ssh session forwarding no agent. A default disk
|
|
# size doesn't apply to it, said.
|
|
exec devvm size -g --disk 150
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ports none base
|
|
stderr '^devvm: size_disk_default_unused backend=docker vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^==> creating_from image=base vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-web-[0-9a-f]{14}-home$'
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-tools-[0-9a-f]{8}$'
|
|
stdout '^docker container create --name devvm-web-[0-9a-f]{14} --label devvm\.data=\S+ --label devvm\.config=[0-9a-f]{16} --label devvm\.kind=vm --init --user 0:0 --entrypoint sleep (-e [A-Za-z_]+= ){10}--cpus 4 --memory \d+m --memory-swap \d+m --hostname web --network bridge --mount type=bind,src=\S+/web,dst=\S+/web --mount type=volume,src=devvm-tools-[0-9a-f]{8},dst=/mnt/devvm-tools,readonly --mount type=volume,src=devvm-web-[0-9a-f]{14}-home,dst=/home/\S+\.guest --cap-drop NET_RAW devvm-[0-9a-f]{8}:[0-9a-f]{12} infinity$'
|
|
stdout '^docker container start devvm-web-[0-9a-f]{14}$'
|
|
stdout '^docker exec -i -u 0 -e DEVVM_DOCKERD=off -e DEVVM_LOOP=off -e DEVVM_SSHD=inetd devvm-web-[0-9a-f]{14} sh -s -- ssh \S+ ssh-ed25519 \S+ devvm$'
|
|
stdout '^ssh -F none -T .* -o IdentityAgent=none .* -o ForwardAgent=no .* cd -- ''\S+/web'' && exec bash -l$'
|
|
! stdout 'devvm-web-[0-9a-f]{14} sh -c .* sh bash -l$'
|
|
! stderr backend_unreviewed
|
|
exists $STUB_DIR/sync.tar
|
|
exec devvm ls
|
|
stdout '^devvm-web-[0-9a-f]{14} +Running .*image=base +\S+ +off +docker +\S+/web$'
|
|
exec sh -c 'cat "$VMS"/devvm-web-*'
|
|
stdout '^backend=docker$'
|
|
! stdout '^disk='
|
|
|
|
# devvm size: its CPUs and memory, and what its disk holds; changed with
|
|
# docker update on a stopped VM; a disk size refused.
|
|
exec devvm size
|
|
stdout '\Acpus=4 memory=\S+GiB disk_used=\S+GiB\n\z'
|
|
exec devvm stop
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm size --cpus 2
|
|
stdout '^==> vm_size size=cpus=2 memory=\S+ vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^docker update --cpus 2 devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm size --disk 300
|
|
stderr '^devvm: backend_lacks backend=docker feature=disk vm=devvm-web-[0-9a-f]{14}$'
|
|
|
|
# Started again with the same mounts: the same container.
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
! stdout 'container (commit|create|rm)'
|
|
stdout '^docker container start devvm-web-[0-9a-f]{14}$'
|
|
|
|
# rm deletes its container, its home volume and its record.
|
|
exec devvm rm --force --no-export
|
|
stdout '^==> deleted vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^docker container rm -f -v devvm-web-[0-9a-f]{14}$'
|
|
stdout '^docker volume rm devvm-web-[0-9a-f]{14}-home$'
|
|
! stdout 'volume rm devvm-tools'
|
|
! exec sh -c 'ls "$XDG_DATA_HOME"/devvm/docker/vms/devvm-web-*'
|
|
exec devvm ls
|
|
! stdout devvm-web
|
|
|
|
# Under Sysbox, where the engine has it, emulated and reviewed, so
|
|
# unwarned: the VM runs under its runtime, said, recorded, on a network of
|
|
# its own, with volumes of its own for Docker's engine, Docker's daemon
|
|
# started after each start; ls shows it; no network policy, at creation or
|
|
# later; rm deletes its network and volumes. Named for a VM that exists,
|
|
# refused before anything changes: only a new VM gets a layer.
|
|
exec sh -c ': > "$STUB_DIR/docker-sysbox"'
|
|
env DEVVM_DOCKER_PROC_SYS=$WORK/sys
|
|
mkdir $WORK/sys/net/ipv4/conf/br-id-net-devvm
|
|
exec sh -c 'echo 0 > "$DEVVM_DOCKER_PROC_SYS/net/ipv4/conf/br-id-net-devvm/route_localnet"'
|
|
exec devvm doctor --backend docker
|
|
stdout '^docker-layer +emulated +native +native$'
|
|
stdout '^docker_sysbox$'
|
|
mkdir $WORK/sysbox
|
|
cd $WORK/sysbox
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none docker
|
|
stderr '^devvm: net_docker_layer backend=docker vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm --backend docker --from $PIN --ports none docker
|
|
stdout '^==> docker_layer_runtime backend=docker runtime=sysbox vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
stderr '^devvm: net_off_docker_layer backend=docker vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
! stderr 'net_about|net_ask'
|
|
! stderr backend_unreviewed
|
|
stub_calls
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-sysbox-[0-9a-f]{14}-docker$'
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-sysbox-[0-9a-f]{14}-containerd$'
|
|
stdout '^docker network create --label devvm\.data=\S+ --label devvm\.kind=vm devvm-sysbox-[0-9a-f]{14}-docker-net$'
|
|
stdout '^docker container create --name devvm-sysbox-[0-9a-f]{14} .* --network devvm-sysbox-[0-9a-f]{14}-docker-net .* --mount type=volume,src=devvm-sysbox-[0-9a-f]{14}-containerd,dst=/var/lib/containerd --runtime sysbox-runc devvm-[0-9a-f]{8}:[0-9a-f]{12} infinity$'
|
|
! stdout 'container create --name devvm-sysbox-.* --cap-drop'
|
|
stdout '^docker exec -i -u 0 -e DEVVM_LOOP=off -e DEVVM_SSHD=inetd devvm-sysbox-[0-9a-f]{14} sh -s -- ssh '
|
|
exec sh -c 'cat "$VMS"/devvm-sysbox-*'
|
|
stdout '^docker_layer=sysbox$'
|
|
stdout '^net=off$'
|
|
exec devvm ls
|
|
[darwin] stdout '^devvm-sysbox-[0-9a-f]{14} +Running +.*image=docker +on +off +docker \(sysbox\) +\S+/sysbox$'
|
|
[linux] stdout '^devvm-sysbox-[0-9a-f]{14} +Running +.*image=docker +off +off +docker \(sysbox\) +\S+/sysbox$'
|
|
! exec devvm network on
|
|
stderr '^devvm: net_docker_layer backend=docker vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
exec devvm rm --force --no-export
|
|
stub_calls
|
|
stdout '^docker volume rm devvm-sysbox-[0-9a-f]{14}-docker$'
|
|
stdout '^docker volume rm devvm-sysbox-[0-9a-f]{14}-containerd$'
|
|
stdout '^docker network rm devvm-sysbox-[0-9a-f]{14}-docker-net$'
|
|
mkdir $WORK/inplace
|
|
cd $WORK/inplace
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ports none base
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
! exec devvm docker
|
|
stderr '^devvm: vm_lacks_layer image=docker layer=docker vm=devvm-inplace-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'docker container (stop|commit|create)'
|
|
exec devvm rm --force --no-export
|
|
# A bridge routing to this machine's loopback (Docker's userland proxy
|
|
# off): refused.
|
|
exec sh -c 'echo 1 > "$DEVVM_DOCKER_PROC_SYS/net/ipv4/conf/br-id-net-devvm/route_localnet"'
|
|
mkdir $WORK/localnet
|
|
cd $WORK/localnet
|
|
! exec devvm --backend docker --from $PIN --ports none docker
|
|
stderr '^devvm: docker_route_localnet vm=devvm-localnet-[0-9a-f]{14}$'
|
|
! exec sh -c 'ls -d "$STUB_DIR"/docker/containers/devvm-localnet-*'
|
|
rm $STUB_DIR/docker-sysbox
|
|
|
|
# Its emulations, reviewed, so unwarned: ssh for editors through docker
|
|
# exec, nothing published (devvm's ssh config names devvm _docker-connect
|
|
# as ProxyCommand); every port, through a forwarder of devvm's over that
|
|
# ssh (its host key read through docker exec and pinned); the shell an ssh
|
|
# session forwarding the user's agent. The port that listens in the VM is
|
|
# one free here; the forwarder checks look for this run's own (its key in
|
|
# this run's data folder).
|
|
free_port PORT
|
|
mkdir $WORK/emu
|
|
cd $WORK/emu
|
|
exec sh -c 'printf "0100007F:%04X\n" "$PORT" > "$STUB_DIR/guest-ports"; : > "$STUB_LOG"'
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ssh-agent base
|
|
! stderr backend_unreviewed
|
|
! stderr 'ports_(no_ssh|forward_failed)'
|
|
stub_calls
|
|
! stdout 'docker container create .* (-p|--publish) '
|
|
stdout '^docker exec -u 0 devvm-emu-[0-9a-f]{14} sh -c if \[ -x /usr/sbin/sshd \]; then echo sshd; else echo none; fi$'
|
|
stdout '^docker exec -i -u 0 -e DEVVM_DOCKERD=off -e DEVVM_LOOP=off -e DEVVM_SSHD=inetd devvm-emu-[0-9a-f]{14} sh -s -- ssh \S+ ssh-ed25519 \S+ devvm$'
|
|
stdout '^docker exec -u 0 devvm-emu-[0-9a-f]{14} cat /etc/ssh/ssh_host_ed25519_key\.pub$'
|
|
stdout '^ssh -F none -M -S \S+/data/devvm/run/docker-[0-9a-f]{16}\.ctl -T .* -o IdentityAgent=none -o IdentityFile=\S+/docker/vms/devvm-emu-[0-9a-f]{14}\.key .* -o HostKeyAlias=devvm-emu-[0-9a-f]{14} .* -o ForwardAgent=no .* -o ProxyCommand=''\S+'' ''_docker-connect'' ''-docker'' ''\S+/docker'' ''-data'' ''\S+/data/devvm'' ''devvm-emu-[0-9a-f]{14}'' -l \S+ devvm-emu-[0-9a-f]{14} sh -s$'
|
|
stdout '^ssh -F none -T -o ControlMaster=no -o ControlPath=none .* -o IdentityAgent=SSH_AUTH_SOCK .* -o ForwardAgent=yes .* -o ProxyCommand=.* -l \S+ devvm-emu-[0-9a-f]{14} cd -- ''\S+/emu'' && exec bash -l$'
|
|
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/docker/vms/devvm-emu-*.ports.log'
|
|
stdout '^devvm ports: port '$PORT': forwarded$'
|
|
grep '^Host devvm-emu devvm-emu-[0-9a-f]{14}$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
grep '^ ProxyCommand ''\S+'' ''_docker-connect'' ''-docker'' ''\S+/docker'' ''-data'' ''\S+/data/devvm'' ''devvm-emu-[0-9a-f]{14}''$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
grep '^ ForwardAgent yes$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
! grep '^ Port ' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
grep '^devvm-emu-[0-9a-f]{14} ssh-ed25519 AAAAstub$' $XDG_CONFIG_HOME/devvm/known_hosts
|
|
exec devvm host
|
|
stdout '^ssh_host_info dir=\S+/emu host=devvm-emu$'
|
|
|
|
# The agent turned off while it runs: from its next start, the shell's and
|
|
# the ssh config entry's alike; then none.
|
|
exec devvm ssh-agent off
|
|
stdout '^==> agent_set_running mode=off vm=devvm-emu-[0-9a-f]{14}$'
|
|
! stderr backend_unreviewed
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
stdout '^ssh -F none -T .* -o IdentityAgent=SSH_AUTH_SOCK .* -o ForwardAgent=yes .* cd -- ''\S+/emu'' && exec bash -l$'
|
|
grep '^ ForwardAgent yes$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
exec devvm stop
|
|
! exec sh -c 'ps -axww -o command= | grep "[_]docker-ports -vm devvm-emu-" | grep -F -- "-key $XDG_DATA_HOME/devvm/"'
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
stdout '^ssh -F none -T .* -o IdentityAgent=none .* -o ForwardAgent=no .* cd -- ''\S+/emu'' && exec bash -l$'
|
|
grep '^ ForwardAgent no$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
|
|
# Listed ports: through the forwarder too, those alone; one a program on
|
|
# this machine has is left out, warned.
|
|
exec devvm stop
|
|
exec devvm ports $PORT,9-10
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/docker/vms/devvm-emu-*.ports.log'
|
|
stdout '^devvm ports: forwarding devvm-emu-[0-9a-f]{14}''s ports$'
|
|
exec sh -c 'ps -axww -o command= | grep "[_]docker-ports -vm devvm-emu-" | grep -F -- "-key $XDG_DATA_HOME/devvm/"'
|
|
stdout ' -only '$PORT',9-10$'
|
|
# Running: a change starts its forwarder again at once, for the same
|
|
# start of its container.
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm ports rm 9-10
|
|
stdout '^==> ports_forwarding ports='$PORT' vm=devvm-emu-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout '^docker (container )?(stop|start|create|commit|rm) '
|
|
exec sh -c 'ps -axww -o command= | grep "[_]docker-ports -vm devvm-emu-" | grep -F -- "-key $XDG_DATA_HOME/devvm/"'
|
|
stdout ' -only '$PORT'$'
|
|
! stdout ' -only '$PORT',9-10$'
|
|
|
|
# rm deletes its forwarder, its keys and its entry.
|
|
exec devvm rm --force --no-export
|
|
! exec sh -c 'ls "$XDG_DATA_HOME"/devvm/docker/vms/devvm-emu-*'
|
|
! grep devvm-emu $XDG_CONFIG_HOME/devvm/ssh_config
|
|
rm $STUB_DIR/guest-ports
|
|
|
|
# On Docker Desktop builds' confinement is emulated, and reviewed, as its
|
|
# containers reach the host's loopback (its builds are the unit tests').
|
|
# An image built already is used.
|
|
env DEVVM_DOCKER_KIND=desktop
|
|
mkdir $WORK/desk
|
|
cd $WORK/desk
|
|
exec devvm doctor --backend docker
|
|
stdout '^docker_engine_desktop version=29\.1\.3$'
|
|
stdout '^build-confinement +emulated +native +native$'
|
|
stdout '^egress-proxy +emulated +native +emulated$'
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ports none base
|
|
! stderr backend_unreviewed
|
|
stdout '^==> creating_from image=base vm=devvm-desk-[0-9a-f]{14}$'
|
|
exec devvm rm --force --no-export
|
|
|
|
# Another machine's engine can't confine a VM to its proxy: without a
|
|
# flag, the VM is made without network policy, unasked and warned;
|
|
# --network-policy is refused before anything is made.
|
|
env DEVVM_DOCKER_KIND=other
|
|
mkdir $WORK/other
|
|
cd $WORK/other
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none base
|
|
stderr '^devvm: backend_lacks backend=docker feature=egress-proxy vm=devvm-other-[0-9a-f]{14}$'
|
|
! exec sh -c 'ls -d "$STUB_DIR"/docker/containers/devvm-other-*'
|
|
exec devvm --backend docker --from $PIN --ports none base
|
|
stderr '^devvm: net_off_backend backend=docker vm=devvm-other-[0-9a-f]{14}$'
|
|
! stderr 'net_about|net_ask'
|
|
exec sh -c 'cat "$VMS"/devvm-other-*'
|
|
stdout '^net=off$'
|
|
exec devvm rm --force --no-export
|
|
env DEVVM_DOCKER_KIND=desktop
|
|
|
|
# A release fetches its own version's Linux build, which network policy's
|
|
# relay runs, the first time a Docker VM needs it: from the release's Linux
|
|
# archive (here a loopback server, with a test build of devvm for Linux),
|
|
# checked against the SHA-256 the release has before it's used. One that
|
|
# doesn't match is refused, and nothing kept; doctor never fetches.
|
|
mkdir $WORK/fetch
|
|
cd $WORK/fetch
|
|
linux_release mismatch
|
|
exec devvm doctor --backend docker
|
|
! stdout docker_linux_build
|
|
! exists $XDG_DATA_HOME/devvm/docker/bin/devvm-linux-$LINUX_ARCH
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none base
|
|
stdout '^==> docker_linux_build_fetching url=http://127\.0\.0\.1:\d+/devvm-0\.0\.0-linux-\w+\.tar\.gz$'
|
|
stderr '^devvm: docker_linux_build_mismatch url=http://127\.0\.0\.1:\d+/devvm-0\.0\.0-linux-\w+\.tar\.gz$'
|
|
! exists $XDG_DATA_HOME/devvm/docker/bin/devvm-linux-$LINUX_ARCH
|
|
exec devvm rm --force --no-export
|
|
linux_release match
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none base
|
|
stdout '^==> docker_linux_build_fetching url='
|
|
! stderr docker_linux_build
|
|
# The stub's VM answers the self-check's direct connection, so devvm stops
|
|
# it; the fetch is what's checked here.
|
|
stderr '^devvm: net_direct_route vm=devvm-fetch-[0-9a-f]{14}$'
|
|
exists $XDG_DATA_HOME/devvm/docker/bin/devvm-linux-$LINUX_ARCH
|
|
stub_calls
|
|
stdout '^docker container create --name devvm-fetch-[0-9a-f]{14}-proxy .* --mount type=bind,src=\S+/docker/bin/devvm-linux-\w+,dst=/devvm,readonly '
|
|
# Kept: the next start fetches nothing.
|
|
! exec devvm
|
|
! stdout docker_linux_build_fetching
|
|
stderr '^devvm: net_direct_route vm=devvm-fetch-[0-9a-f]{14}$'
|
|
exec devvm rm --force --no-export
|
|
|
|
# Behind a company proxy, a Linux engine's build goes through a proxy of
|
|
# devvm's on its own network, as on Docker Desktop: its commands get that
|
|
# proxy's address and a password made for the build, never the company
|
|
# proxy's, which is in no command and nothing left behind.
|
|
env DEVVM_DOCKER_KIND=linux
|
|
env HTTPS_PROXY=http://corp:[email protected]:9
|
|
env https_proxy=
|
|
exec devvm layer new corp
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm --backend docker build corp
|
|
stub_calls
|
|
stdout '^docker network create --internal .* devvm-img-[0-9a-f]{12}-[0-9a-f]{8}-net$'
|
|
stdout '^docker container create --name devvm-img-[0-9a-f]{12}-[0-9a-f]{8}-proxy '
|
|
stdout '^docker container create --name devvm-img-[0-9a-f]{12}-[0-9a-f]{8} .* --network devvm-img-[0-9a-f]{12}-[0-9a-f]{8}-net '
|
|
stdout '^docker exec --env-file \S+/builds/devvm-img-[0-9a-f]{12}-[0-9a-f]{8}/env -i -u '
|
|
! stdout c0rp-pa55
|
|
exec sh -c 'grep -rl c0rp-pa55 "$XDG_DATA_HOME" "$STUB_DIR" || true'
|
|
! stdout .
|
|
|
|
# Every container devvm made in this script, VMs, builds and relays, set
|
|
# each proxy variable empty.
|
|
exec sh -c 'grep -c . "$STUB_DIR/containers-made"; grep -vF -- "-e HTTP_PROXY= -e http_proxy= -e HTTPS_PROXY= -e https_proxy= -e FTP_PROXY= -e ftp_proxy= -e NO_PROXY= -e no_proxy= -e ALL_PROXY= -e all_proxy= " "$STUB_DIR/containers-made" || true'
|
|
stdout '^[1-9][0-9]*$'
|
|
! stdout '^docker '
|
|
exec sh -c 'grep -c -- "-proxy " "$STUB_DIR/containers-made"'
|
|
! stdout '^0$'
|