mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
Messages that said the same thing for different settings are one message each, given what differs: - new_vm_flags_ignored and new_vm_flags_ignored_run (flags, vm, command) replace from_ignored, net_flag_ignored, git_protect_flag_ignored, size_flags_ignored, ports_flag_ignored, parts_flags_ignored, ssh_agent_flag_ignored and no_devcontainer_flag_ignored: one warning for each command that changes the same on the VM, naming only the flags given (ignoredFlags). - setting_already (command, vm) replaces net_already, agent_already, clone_on_already and clone_off_already. - setting_set (vm), for a stopped VM, replaces net_set_stopped, agent_set_stopped and links_next_start. - next_start (count, vm), for a running VM, replaces net_set_running, agent_set_running, size_next_start, agent_next_start, mounts_next_start, folder_next_start and net_off_next_start; a launch warns of each change with its next_start_* line, then next_start once. - program_missing, program_broken and program_old (+ _fix) replace lima_missing, lima_broken, lima_old, qemu_missing, macos_old and their _fix messages; the minimum versions are minLima and minMacOS in the lima backend, passed into program_old. - ports_list_needed replaces link_ports_invalid: devvm link publish and unpublish check their ports with ParsePortList, as devvm ports add does, and ParsePublish is gone. - no_vm replaces no_vm_link. - vm_unfinished says nothing of the user's is in the VM, as remake_unfinished does. Kept apart: git_protect_next_stop (it applies at the next stop, and devvm stop applies it), already_stopped and ports_all_already (not settings), group_already (joining again syncs the group's links), has_tools and has_layers (they name which of those given were there), docker_missing (Docker is optional, so it never says to install it). Co-Authored-By: Claude Opus 5.5 <[email protected]>
343 lines
15 KiB
Plaintext
343 lines
15 KiB
Plaintext
# A project's devcontainer.json, read when its VM is made: its image is
|
|
# the VM's --from (pinned to the digest its registry gives anyone), its
|
|
# features devvm's layers, its forwardPorts the VM's listed ports, its
|
|
# variables the VM's environment, its commands run in the VM, once or at
|
|
# each start. A later launch only warns when the file changed, and devvm
|
|
# update makes the VM again as it says now. Nothing is written to the
|
|
# project folder, and nothing in the file runs on the host.
|
|
# Registries are never reached: HTTPS_PROXY points at nothing, so lookups
|
|
# are offline, and a digest recorded before stands for the registry's.
|
|
env HTTPS_PROXY=http://127.0.0.1:9
|
|
env https_proxy=http://127.0.0.1:9
|
|
env PIN=node:24@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
mkdir $XDG_DATA_HOME/devvm/cache
|
|
cp digests.json $XDG_DATA_HOME/devvm/cache/from-digests.json
|
|
mkdir $XDG_CONFIG_HOME/devvm/layers
|
|
cp extra.sh $XDG_CONFIG_HOME/devvm/layers/extra.sh
|
|
exec devvm ports -g none
|
|
|
|
# Refused before anything is made, the file named: the host's environment,
|
|
# a container to build, the host's Docker, a feature devvm has no layer
|
|
# for, invalid JSON (where), an image the registry can't be asked about,
|
|
# an image on this machine's registry (never asked).
|
|
project bad
|
|
cp $WORK/localenv.json .devcontainer.json
|
|
! exec devvm --no-network-policy
|
|
stderr '^devvm: devcontainer_local_env file=\.devcontainer\.json variable=\$\{localEnv:GITHUB_TOKEN\}$'
|
|
cp $WORK/build.json .devcontainer.json
|
|
! exec devvm --no-network-policy
|
|
stderr '^devvm: devcontainer_build file=\.devcontainer\.json key=build$'
|
|
cp $WORK/outside.json .devcontainer.json
|
|
! exec devvm --no-network-policy
|
|
stderr '^devvm: devcontainer_docker_outside feature=ghcr\.io/devcontainers/features/docker-outside-of-docker:1 file=\.devcontainer\.json$'
|
|
cp $WORK/java.json .devcontainer.json
|
|
! exec devvm --no-network-policy
|
|
stderr '^devvm: devcontainer_feature feature=ghcr\.io/devcontainers/features/java:1 file=\.devcontainer\.json$'
|
|
cp $WORK/invalid.json .devcontainer.json
|
|
! exec devvm --no-network-policy
|
|
stderr '^devvm: devcontainer_invalid column=3 file=\.devcontainer\.json line=4$'
|
|
cp $WORK/unknown-image.json .devcontainer.json
|
|
! exec devvm --no-network-policy
|
|
stderr '^devvm: from_unreachable from=debian:13 host=registry-1\.docker\.io$'
|
|
cp $WORK/local-image.json .devcontainer.json
|
|
! exec devvm --no-network-policy
|
|
stderr '^devvm: devcontainer_image_not_public file=\.devcontainer\.json from=localhost:5000/app:1$'
|
|
! stdout 'creating_from|building'
|
|
stub_calls
|
|
! stdout 'limactl (create|clone|start|shell)'
|
|
! exists $VMS
|
|
exec ls -A
|
|
cmp stdout $WORK/bad-ls
|
|
|
|
# A new VM: made as the file says, its image's recorded digest standing in
|
|
# for the registry's (offline), --layers the exact list of its layers (the
|
|
# docker layer docker-in-docker calls for, and the user's on top), the
|
|
# localhost ports forwarded, added to the user's (none here) as devvm
|
|
# ports add adds them; what's ignored is said, initializeCommand never
|
|
# runs.
|
|
mkdir $WORK/web/.devcontainer
|
|
cd $WORK/web
|
|
exec git init -q
|
|
cp $WORK/web.json .devcontainer/devcontainer.json
|
|
exec devvm --no-network-policy --layers docker,extra
|
|
stdout '^==> devcontainer_using file=\.devcontainer/devcontainer\.json vm=devvm-web-[0-9a-f]{14}$'
|
|
stderr '^devvm: from_cached_unreachable from=node:24 host=registry-1\.docker\.io$'
|
|
stderr '^devvm: devcontainer_initialize file=\.devcontainer/devcontainer\.json$'
|
|
stderr '^devvm: devcontainer_feature_options features=ghcr\.io/devcontainers/features/docker-in-docker:2 file=\.devcontainer/devcontainer\.json$'
|
|
stderr '^devvm: devcontainer_ports_ignored file=\.devcontainer/devcontainer\.json ports="db:5432"$'
|
|
stderr '^devvm: devcontainer_ignored file=\.devcontainer/devcontainer\.json keys=runArgs$'
|
|
stderr '^devvm: devcontainer_unknown file=\.devcontainer/devcontainer\.json keys=bogus$'
|
|
stdout '^==> building_image_from from=node@sha256:a{64} image=base key=[0-9a-f]{12}$'
|
|
stdout '^==> creating_from image=docker\+extra vm=devvm-web-[0-9a-f]{14}$'
|
|
# The commands: once, in order (named ones sorted), then postStartCommand;
|
|
# in the VM, as its user, in the project folder, in a login shell; then
|
|
# the shell.
|
|
stdout '^==> running_script script=onCreateCommand vm=devvm-web-[0-9a-f]{14}\n==> running_script script=postCreateCommand a vm=devvm-web-[0-9a-f]{14}\n==> running_script script=postCreateCommand b vm=devvm-web-[0-9a-f]{14}\n==> running_script script=postStartCommand vm=devvm-web-[0-9a-f]{14}\n'
|
|
stub_calls
|
|
stdout '^limactl shell --workdir / devvm-web-[0-9a-f]{14} sh -c cd ''/\S*/web'' && exec ''bash'' ''-lc'' ''exec "\$@"'' ''devvm'' ''sh'' ''-c'' ''echo made > ~/made''\n'
|
|
stdout '^limactl shell --workdir / devvm-web-[0-9a-f]{14} sh -c cd ''/\S*/web'' && exec ''bash'' ''-lc'' ''exec "\$@"'' ''devvm'' ''touch'' ''b''\nlimactl shell --workdir / devvm-web-[0-9a-f]{14} sh -c cd ''/\S*/web'' && exec ''bash'' ''-lc'' ''exec "\$@"'' ''devvm'' ''sh'' ''-c'' ''echo started >> ~/started''\n(limactl list --json\n)*limactl shell --workdir /\S*/web devvm-web-[0-9a-f]{14}\n\z'
|
|
! stdout pwned
|
|
# Its variables are in its environment file, before devvm's own.
|
|
exec tar -xOf $STUB_DIR/sync.tar env
|
|
stdout '\Aexport GREETING=''it''\\''''s web''\nexport PATH="\$\{PATH\}"'':/opt/web''\n'
|
|
# Its state.
|
|
vm_name WEB web
|
|
vm_state $WEB_dir/vm.json
|
|
stdout '^devcontainer.file=\.devcontainer/devcontainer\.json$'
|
|
stdout '^devcontainer.sum=[0-9a-f]{64}$'
|
|
stdout '^from=node@sha256:a{64}$'
|
|
stdout '^image=docker\+extra$'
|
|
stdout '^ports.forward=3000,5173$'
|
|
stdout '^devcontainer.ports=3000 5173$'
|
|
stdout '^devcontainer.ports_gave=3000 5173$'
|
|
stdout '^devcontainer.made.created=true$'
|
|
stdout '^devcontainer.start.0.name=postStartCommand$'
|
|
stdout '^devcontainer.start.0.argv=sh -c echo started >> ~/started$'
|
|
# Nothing in the project folder but what was there.
|
|
exec ls -A
|
|
cmp stdout $WORK/web-ls
|
|
cmp .devcontainer/devcontainer.json $WORK/web.json
|
|
|
|
# Launched again, running: nothing runs again.
|
|
stub_reset
|
|
exec devvm
|
|
! stdout running_script
|
|
! stderr devcontainer
|
|
stub_calls
|
|
! stdout 'bash'' ''-lc'''
|
|
|
|
# Changed: a warning each launch, nothing applied; --no-devcontainer is for
|
|
# new VMs.
|
|
cp $WORK/changed.json .devcontainer/devcontainer.json
|
|
exec devvm --no-devcontainer
|
|
stderr '^devvm: devcontainer_changed file=\.devcontainer/devcontainer\.json vm=devvm-web-[0-9a-f]{14}$'
|
|
stderr '^devvm: new_vm_flags_ignored flags=--no-devcontainer vm=devvm-web-[0-9a-f]{14}$'
|
|
! stdout 'running_script|devcontainer_using'
|
|
! stderr 'devcontainer_(ignored|unknown|initialize)'
|
|
# Gone: the same.
|
|
rm .devcontainer/devcontainer.json
|
|
exec devvm
|
|
stderr '^devvm: devcontainer_changed file=\.devcontainer/devcontainer\.json vm=devvm-web-[0-9a-f]{14}$'
|
|
cp $WORK/web.json .devcontainer/devcontainer.json
|
|
exec devvm
|
|
! stderr devcontainer
|
|
|
|
# Stopped and launched: postStartCommand runs again, the others don't.
|
|
exec devvm stop
|
|
stub_reset
|
|
exec devvm
|
|
stdout '^==> running_script script=postStartCommand vm=devvm-web-[0-9a-f]{14}$'
|
|
! stdout 'running_script script=(onCreate|postCreate)'
|
|
stub_calls
|
|
stdout 'echo started >> ~/started'
|
|
! stdout 'echo made'
|
|
|
|
# A command that fails: a warning naming it, the rest of its group skipped,
|
|
# the VM kept and opened; postStartCommand still runs at the start. Without
|
|
# --layers, the file's docker-in-docker gives it the docker layer.
|
|
project fail
|
|
cp $WORK/web.json .devcontainer.json
|
|
exec sh -c 'echo "''echo a''" > "$STUB_DIR/shell-fails-on"'
|
|
exec devvm --no-network-policy
|
|
stdout '^==> new_vm_gets layers=docker tools=none vm=devvm-fail-[0-9a-f]{14}$'
|
|
stderr '^devvm: devcontainer_command_failed command=postCreateCommand a vm=devvm-fail-[0-9a-f]{14}$'
|
|
! stdout 'running_script script=postCreateCommand b'
|
|
stdout '^==> running_script script=postStartCommand vm=devvm-fail-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl shell --workdir /\S*/fail devvm-fail-[0-9a-f]{14}\n\z'
|
|
rm $STUB_DIR/shell-fails-on
|
|
|
|
# --no-devcontainer: the file isn't read (this one would be refused), and
|
|
# later changes aren't warned about.
|
|
project skip
|
|
cp $WORK/build.json .devcontainer.json
|
|
exec devvm --no-network-policy --no-devcontainer
|
|
! stdout devcontainer_using
|
|
vm_name SKIP skip
|
|
vm_state $SKIP_dir/vm.json
|
|
stdout '^devcontainer.off=true$'
|
|
cp $WORK/web.json .devcontainer.json
|
|
exec devvm
|
|
! stderr devcontainer
|
|
|
|
# A VM made without a file: one that appears is warned about.
|
|
project plain
|
|
exec devvm --no-network-policy
|
|
vm_name PLAIN plain
|
|
vm_state $PLAIN_dir/vm.json
|
|
! stdout '^devcontainer\.'
|
|
cp $WORK/web.json .devcontainer.json
|
|
exec devvm
|
|
stderr '^devvm: devcontainer_new file=\.devcontainer\.json vm=devvm-plain-[0-9a-f]{14}$'
|
|
|
|
# What's given on the command line wins: --from over image, --ports over
|
|
# forwardPorts.
|
|
project flags
|
|
cp $WORK/web.json .devcontainer.json
|
|
exec devvm --no-network-policy --from $PIN --ports 8080
|
|
stderr '^devvm: devcontainer_flag_wins file=\.devcontainer\.json flag=from key=image$'
|
|
stderr '^devvm: devcontainer_flag_wins file=\.devcontainer\.json flag=ports key=forwardPorts$'
|
|
vm_name FLAGS flags
|
|
vm_state $FLAGS_dir/vm.json
|
|
stdout '^from=node:24@sha256:a{64}$'
|
|
stdout '^ports.forward=8080$'
|
|
stdout '^devcontainer.from_flag=true$'
|
|
! stdout '^devcontainer.ports_gave='
|
|
# devvm update reads the changed file: --from still wins, and the port
|
|
# the file lists anew is added.
|
|
cp $WORK/changed.json .devcontainer.json
|
|
exec devvm update --force
|
|
stdout '^==> devcontainer_reread file=\.devcontainer\.json vm=devvm-flags-[0-9a-f]{14}$'
|
|
stderr '^devvm: devcontainer_flag_wins file=\.devcontainer\.json flag=from key=image$'
|
|
vm_state $FLAGS_dir/vm.json
|
|
stdout '^from=node:24@sha256:a{64}$'
|
|
stdout '^ports.forward=8080,9000$'
|
|
stdout '^devcontainer.ports_gave=9000$'
|
|
! stdout '^remake'
|
|
exec devvm
|
|
! stderr devcontainer
|
|
|
|
# devvm update after the file changed: made again as it says now. What
|
|
# the file gave (the docker layer, its image) is replaced, and what the
|
|
# user chose (claude) stays; its new image is pinned; its ports are the
|
|
# file's new ones and the user's own, and one the user removed stays
|
|
# removed; its variables and commands are the new file's, which run on
|
|
# the new disk; the home folder is kept.
|
|
project upd
|
|
cp $WORK/web.json .devcontainer.json
|
|
exec devvm --no-network-policy --agents claude
|
|
vm_name UPD upd
|
|
vm_state $UPD_dir/vm.json
|
|
stdout '^image=docker$'
|
|
stdout '^devcontainer.gave=docker$'
|
|
stdout '^devcontainer.image=node:24$'
|
|
stdout '^ports.forward=3000,5173$'
|
|
exec devvm ports add 9000
|
|
exec devvm ports rm 5173
|
|
exec sh -c 'mkdir -p "$STUB_DIR/vmhome-$UPD" && echo ls > "$STUB_DIR/vmhome-$UPD/.bash_history"'
|
|
cp $WORK/updated.json .devcontainer.json
|
|
exec devvm
|
|
stderr '^devvm: devcontainer_changed file=\.devcontainer\.json vm=devvm-upd-[0-9a-f]{14}$'
|
|
# Without a terminal it's refused before anything changes.
|
|
stub_reset
|
|
! exec devvm update
|
|
stdout '^==> devcontainer_reread file=\.devcontainer\.json vm=devvm-upd-[0-9a-f]{14}$'
|
|
stderr '^devvm: no_input answer=--force$'
|
|
stub_calls
|
|
! stdout 'limactl (stop|rename|clone|delete)'
|
|
vm_state $UPD_dir/vm.json
|
|
stdout '^image=docker$'
|
|
stub_reset
|
|
exec devvm update --force
|
|
stdout '^==> devcontainer_reread file=\.devcontainer\.json vm=devvm-upd-[0-9a-f]{14}$'
|
|
stdout '^==> building_image_from from=node@sha256:b{64} image=base key=[0-9a-f]{12}$'
|
|
stdout '^==> creating_from image=base vm=devvm-upd-[0-9a-f]{14}$'
|
|
stdout '^==> running_script script=postCreateCommand vm=devvm-upd-[0-9a-f]{14}$'
|
|
stdout '^==> remade image=base vm=devvm-upd-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout 'limactl rename --tty=false devvm-upd-[0-9a-f]{14} devvm-[0-9a-f]{14}-old\n(.*\n)*.*tar -xzf - --skip-old-files.*\n(.*\n)*limactl delete -f devvm-[0-9a-f]{14}-old\n'
|
|
stdout 'echo updated > ~/updated'
|
|
exec tar -tzf $STUB_DIR/home-in.tgz
|
|
stdout '^\.bash_history$'
|
|
exec tar -xOf $STUB_DIR/sync.tar env
|
|
stdout '\Aexport STAGE=''two''\n'
|
|
vm_state $UPD_dir/vm.json
|
|
stdout '^image=base$'
|
|
stdout '^from=node@sha256:b{64}$'
|
|
stdout '^tools.names=node claude$'
|
|
stdout '^devcontainer.image=node:22$'
|
|
stdout '^devcontainer.gave=node$'
|
|
stdout '^devcontainer.parts=node$'
|
|
stdout '^devcontainer.made.created=true$'
|
|
stdout '^ports.forward=9000,8000$'
|
|
stdout '^devcontainer.ports_gave=8000$'
|
|
! stdout '^remake'
|
|
exec devvm
|
|
! stderr devcontainer
|
|
# Current: nothing runs.
|
|
stub_reset
|
|
exec devvm update --force
|
|
stdout '^==> vm_current image=base vm=devvm-upd-[0-9a-f]{14}$'
|
|
# Gone: what the file gave goes, and the base starts from $DEVVM_FROM's.
|
|
rm .devcontainer.json
|
|
env DEVVM_FROM=$PIN
|
|
exec devvm update --force
|
|
stdout '^==> devcontainer_gone file=\.devcontainer\.json vm=devvm-upd-[0-9a-f]{14}$'
|
|
vm_state $UPD_dir/vm.json
|
|
stdout '^from=node:24@sha256:a{64}$'
|
|
stdout '^tools.names=claude$'
|
|
stdout '^ports.forward=9000$'
|
|
! stdout '^devcontainer\.(file|image|gave|ports|ports_gave)='
|
|
env DEVVM_FROM=
|
|
|
|
# devvm update after a file appeared for a VM made without one.
|
|
cd $WORK/plain
|
|
exec devvm update --force
|
|
stdout '^==> devcontainer_reread file=\.devcontainer\.json vm=devvm-plain-[0-9a-f]{14}$'
|
|
stdout '^==> creating_from image=docker vm=devvm-plain-[0-9a-f]{14}$'
|
|
vm_state $PLAIN_dir/vm.json
|
|
stdout '^from=node@sha256:a{64}$'
|
|
stdout '^image=docker$'
|
|
stdout '^devcontainer.file=\.devcontainer\.json$'
|
|
stdout '^devcontainer.gave=docker$'
|
|
stdout '^ports.forward=3000,5173$'
|
|
exec devvm
|
|
! stderr devcontainer
|
|
|
|
-- digests.json --
|
|
{"digests": {"node:24": "node@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "node:22": "node@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}}
|
|
-- extra.sh --
|
|
#!/bin/bash
|
|
echo extra
|
|
-- localenv.json --
|
|
{"containerEnv": {"TOKEN": "${localEnv:GITHUB_TOKEN}"}}
|
|
-- build.json --
|
|
{"build": {"dockerfile": "Dockerfile"}}
|
|
-- outside.json --
|
|
{"features": {"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}}}
|
|
-- java.json --
|
|
{"features": {"ghcr.io/devcontainers/features/java:1": {}}}
|
|
-- invalid.json --
|
|
{
|
|
// a missing comma
|
|
"image": "node:24"
|
|
"forwardPorts": [3000]
|
|
}
|
|
-- unknown-image.json --
|
|
{"image": "debian:13"}
|
|
-- local-image.json --
|
|
{"image": "localhost:5000/app:1"}
|
|
-- bad-ls --
|
|
.devcontainer.json
|
|
-- web-ls --
|
|
.devcontainer
|
|
.git
|
|
-- web.json --
|
|
{
|
|
// The project's container.
|
|
"name": "web",
|
|
"image": "node:24",
|
|
"features": {
|
|
"ghcr.io/devcontainers/features/docker-in-docker:2": {"moby": false},
|
|
},
|
|
"forwardPorts": [3000, "localhost:5173", "db:5432"],
|
|
"containerEnv": {"GREETING": "it's ${containerWorkspaceFolderBasename}"},
|
|
"remoteEnv": {"PATH": "${containerEnv:PATH}:/opt/web"},
|
|
"initializeCommand": "touch pwned",
|
|
"onCreateCommand": "echo made > ~/made",
|
|
"postCreateCommand": {"b": ["touch", "b"], "a": "echo a"},
|
|
"postStartCommand": "echo started >> ~/started",
|
|
"runArgs": ["--privileged"],
|
|
"bogus": true,
|
|
}
|
|
-- changed.json --
|
|
{"image": "node:24", "forwardPorts": [9000]}
|
|
-- updated.json --
|
|
{
|
|
"image": "node:22",
|
|
"features": {"ghcr.io/devcontainers/features/node:1": {}},
|
|
"forwardPorts": [8000],
|
|
"containerEnv": {"STAGE": "two"},
|
|
"postCreateCommand": "echo updated > ~/updated",
|
|
}
|