mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
feat(vm): devvm update reads a changed devcontainer.json again
devvm update now makes the folder's VM again from its devcontainer.json as it is now when the file changed, is gone or appeared since the VM was made, as well as when its image is outdated. devcontainer_changed and devcontainer_new name devvm update instead of devvm rm, then devvm. A file's forwardPorts now join the VM's ports as devvm ports add adds them, for a new VM and when devvm update reads the file again. - vm.json's devcontainer section records what of the VM is the file's: image (the file's image, when the base starts from it), from_flag (--from won), parts (what its features mapped to), gave (those the VM got from the file alone, not from --tools/--layers, setup's layers, the folder's other files, nor unchecked), ports (its forwardPorts) and ports_gave (those it added to the VM's ports). - devcontainer.Reread (pure) drops what the file gave that it no longer lists and adds what it lists anew that the VM lacks; the user's stay, and what the user took out stays out. It applies to parts (rereadParts) and to ports (filePorts, through AddPorts and RemovePorts, as devvm ports add and rm). devcontainers.reread re-pins a new image (or falls back to $DEVVM_FROM's), keeps --from's, and replaces variables and commands. - The remake section carries reread (the new from, shared tools, ports and devcontainer section; tools built for the new base after the image) and was (what the VM had, kept when the new machine is made), which the undo gives back, for every remake. - Messages: devcontainer_changed/new reworded, devcontainer_reread and devcontainer_gone added, devcontainer_ports_not_forwarded removed; the docs link points at the new "Updating a VM from the file" section. - Tests: TestReread, TestRereadParts, TestFilePorts, TestFileParts, TestUpdateDevcontainer (undo and finish), TestUpDevcontainer and TestPlanDevcontainerFrom (the file's ports added), devcontainer.txtar (a new VM's ports, update after a change with the user's port added and the file's removed, --from winning, the file removed, a file that appeared), e2e's devcontainer section (the file's port reaches this machine; devvm update, the home kept, the new port in place of the old one). - Docs: using/devcontainer (its ports, the security note), images, toolchains, commands, the internals overview's remake section and state table, the design note, the security model, attack vectors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
26 files changed
+2086
-1264
No files matched your search
@@ -16,7 +16,7 @@ devvm: one isolated VM per project folder, cloned from a base image, with toolch
|
||||
| `internal/fetch/` | every HTTP client (stdlib): `NewClient` (timeout, `HTTPSOnly`/`SameScheme`), `Retry`/`Transient`, `ReadCapped`, `Get`, `Download` (checks the SHA-256) |
|
||||
| `internal/from/` | `--from`: references, registry digests (anonymous token), Docker's IDs, the recorded digests |
|
||||
| `internal/redact/` | passwords out of logs (stdlib): `String` (the run log's lines: proxy keys, URL passwords), `File` (another program's log, in place, its length kept) |
|
||||
| `internal/devcontainer/`, `internal/jsonc/` | a project's devcontainer.json (pure): finding it, mapping it to a new VM's plan, refusals; JSON with comments (`jsonc.Strip`, stdlib) |
|
||||
| `internal/devcontainer/`, `internal/jsonc/` | a project's devcontainer.json (pure): finding it, mapping it to a new VM's plan, refusals, what devvm update's reading again replaces (`Reread`); JSON with comments (`jsonc.Strip`, stdlib) |
|
||||
| `internal/tools/` | the shared tools: the lock, host mise, the daily check, tool image builds, the share |
|
||||
| `internal/netpolicy/`, `internal/secrets/` | network policy (the choice, the VM's proxy, the self-check); tokens on the host and the VM's bindings |
|
||||
| `internal/trust/` | the user's CAs (`~/.config/devvm/ca`): read and checked, sent to VMs, build VMs' `Trust` scripts, the guest environment; each VM's own CA and its next (`InitCA`, in `vms/<hash>/run/ca/`) |
|
||||
|
||||
@@ -7,7 +7,7 @@ Bring this folder's VM up to date, then open a shell in it
|
||||
|
||||
## Synopsis
|
||||
|
||||
Move this folder's VM to the newest shared tools, as devvm tools update does, then open a shell in it. When its image changed since devvm made the VM, devvm then asks to make the VM again from the image's new build, with the same layers, keeping its home folder, the project folder and its settings, and everything else on its disk is lost. When its image has an agent, devvm first exports the agents' history, unless you give --no-export.
|
||||
Move this folder's VM to the newest shared tools, as devvm tools update does, then open a shell in it. When its image changed since devvm made the VM, or the folder's devcontainer.json did, devvm then asks to make the VM again from the image's new build and the file as it is now, keeping its home folder, the project folder and its settings, and everything else on its disk is lost. When its image has an agent, devvm first exports the agents' history, unless you give --no-export.
|
||||
|
||||
```text
|
||||
devvm update [flags]
|
||||
|
||||
@@ -29,7 +29,7 @@ You start the agent in the VM's shell, whose prompt starts with `(devvm)`, so th
|
||||
| `devvm` | open a shell in this folder's VM, at the same path, making the VM first with the toolchains, agents and layers you check in a list, or that `--tools`, `--agents` and `--layers` name ([details](../using/images.md#what-a-new-vm-gets)) |
|
||||
| `devvm restart` | stop this folder's VM, start it again and open a shell in it, for changes that apply only when it starts ([details](#restarting-and-stopping)) |
|
||||
| `devvm stop` | stop this folder's VM ([details](#restarting-and-stopping)) |
|
||||
| `devvm update [--force] [--no-export] [--clean-home]` | move this folder's VM to the newest shared tools, and when its image has changed, make it again from the image's new build, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#outdated-vms)) |
|
||||
| `devvm update [--force] [--no-export] [--clean-home]` | move this folder's VM to the newest shared tools, and when its image or its `devcontainer.json` has changed, make it again from the image's new build and the file as it is now, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#outdated-vms)) |
|
||||
| `devvm rm [--force] [--no-export] [--no-clone-check]` | delete this folder's VM after asking, exporting its agents' history first unless `--no-export` ([details](#deleting-a-vm)) |
|
||||
| `devvm rm VM [--force] [--no-export] [--no-clone-check]` | delete a VM whose folder is gone, by its name or ssh alias, after asking ([details](#a-vm-whose-folder-is-gone)), or one whose folder is on a disk that isn't connected, only after asking in a terminal ([details](#a-folder-on-a-disk-that-isnt-connected)) |
|
||||
| `devvm adopt` | use the VM made for an earlier folder at this path here ([details](#a-folder-made-again)), or the VM made for this folder before you moved or renamed it ([details](#a-moved-or-renamed-folder)) |
|
||||
|
||||
@@ -118,7 +118,7 @@ A new VM gets what the project's `devcontainer.json` says, as far as devvm does
|
||||
- **The docker layer:** the backend's own rules for it, as when it's named; the file never takes network policy away.
|
||||
- **The environment:** each variable's value is built as a shell word (single-quoted text, `"${X}"` for the VM's own), stored as JSON in the VM's state, and written as `export NAME=word` into the VM's environment file before devvm's own (which win); a name is checked again when it's written.
|
||||
- **Commands:** stored as argv in the VM's state; run by the backend's `Exec` (on Lima, one `sh -c` string, each word in single quotes), as the VM's user, in the folder, after the self-check, `.git`'s locks and a `--clone` VM's clone: confined like anything in the VM. Their output goes to the run log, shown only through `printable`.
|
||||
- **Ports:** only numbers and `localhost:N`/`127.0.0.1:N`, and never beyond the user's ports (`devvm ports -g`, or `--ports`, which wins): with every port forwarded, the default, they're among them; ports the user's list leaves out are said (`devvm ports add` forwards them), not added (`devcontainer_ports_not_forwarded`). Forwarded on this machine's loopback as any listed port, never a host port of another program's (`ports_taken`).
|
||||
- **Ports:** only numbers and `localhost:N`/`127.0.0.1:N`, added to the user's ports as `devvm ports add` adds them (`filePorts`, through `AddPorts` and `RemovePorts`; `--ports` wins when the VM is made): with every port forwarded, the default, they're among them already. The ones the file added are recorded (`devcontainer.ports_gave`), so `devvm update` takes out only those the file no longer lists and never brings back one `devvm ports rm` took out. Forwarded on this machine's loopback alone, as any listed port, by the one forwarder, never a host port of another program's (`ports_taken`). A repo's file can so widen a list the user narrowed, to more of this machine's loopback, which is the user's decision to accept by opening the folder; `--no-devcontainer` skips it.
|
||||
|
||||
**What it relies on:** `os.Root` and `O_NONBLOCK`; `encoding/json`; Lima's `Exec` passing arguments unchanged; the registry's digest naming what's pulled (a pull checks it); the backend's own confinement of the VM and its builds.
|
||||
|
||||
|
||||
@@ -44,18 +44,18 @@ When `devvm tools add`, or `devvm tools` in a terminal, adds shared tools to an
|
||||
|
||||
## Making a VM again
|
||||
|
||||
`devvm layer add LAYER...` makes the folder's VM again from a new image, its own layers with the new ones on top, and keeps devvm's settings for it and its home folder ([adding layers to a VM](../using/images.md#adding-layers-to-a-vm)). `devvm layer rm LAYER...` makes it again from an image of its other layers, in their order ([taking layers out of a VM](../using/images.md#taking-layers-out-of-a-vm)). `devvm update` first moves the VM to the newest shared tools, the step `devvm tools update` takes (`Tools.update`), which needs no remake because the tools are mounted. Then it makes the VM again from the image it has, when that image or one below it has a new key, so the VM gets the image's new build ([outdated VMs](../using/images.md#outdated-vms)). An outdated VM without `--force` or a terminal is refused before the tools step, so a refusal changes nothing. The remake is one path in the VM's lifecycle, which takes the image to make the VM from, so each command only works out that image and its own refusals: `devvm layer add` names the layers the VM has already, `devvm layer rm` names those it lacks (`lacks_layers`) and refuses a name that's no layer's, though it takes out one of the user's whose script is gone, and `devvm update` says the VM is current (`vm_current`) when it had the newest tools and nothing in its chain changed, or names what changed (`vm_changed`) before it asks.
|
||||
`devvm layer add LAYER...` makes the folder's VM again from a new image, its own layers with the new ones on top, and keeps devvm's settings for it and its home folder ([adding layers to a VM](../using/images.md#adding-layers-to-a-vm)). `devvm layer rm LAYER...` makes it again from an image of its other layers, in their order ([taking layers out of a VM](../using/images.md#taking-layers-out-of-a-vm)). `devvm update` first moves the VM to the newest shared tools, the step `devvm tools update` takes (`Tools.update`), which needs no remake because the tools are mounted. Then it makes the VM again from the image it has, when that image or one below it has a new key, so the VM gets the image's new build ([outdated VMs](../using/images.md#outdated-vms)), and when the folder's `devcontainer.json` isn't the one the VM was made from, as [reading the devcontainer.json again](#reading-the-devcontainerjson-again) describes. An outdated VM without `--force` or a terminal is refused before the tools step, so a refusal changes nothing. The remake is one path in the VM's lifecycle, which takes the image to make the VM from, so each command only works out that image and its own refusals: `devvm layer add` names the layers the VM has already, `devvm layer rm` names those it lacks (`lacks_layers`) and refuses a name that's no layer's, though it takes out one of the user's whose script is gone, and `devvm update` says the VM is current (`vm_current`) when it had the newest tools and nothing in its chain changed, or names what changed (`vm_changed`) before it asks.
|
||||
|
||||
Before anything changes, devvm refuses a name that isn't a layer, a VM made for another folder, one whose creation didn't finish and, except for `devvm clone`, a `--clone` VM, and it checks that the VM's backend has every feature the VM needs with the new image (`Require`) and that the disk has room for a VM. Then it asks (`remake_confirm`, or `remake_confirm_clean_home` with `--clean-home`), and a parent folder's VM only in a terminal (`remake_parent_vm_ask`). The remake then goes in this order:
|
||||
|
||||
1. devvm builds the new image, as for a new VM.
|
||||
2. It exports the agents' history as `devvm rm` does, unless `--no-export`, and saves the VM's home folder, unless `--clean-home`. The VM runs `tar --one-file-system --ignore-failed-read` in its home as its user, and devvm reads that stream on this machine and writes only what it keeps to `home.tar.gz` in the VM's folder ([the home folder's copy](design.md#the-home-folders-copy)). A failure in either keeps the VM as it was (`remake_export_failed`, `remake_home_failed`).
|
||||
3. devvm records the remake in the VM's state (`remake`), stops the VM, its proxy and its link session, and has the backend rename the VM's machine to its aside name, `devvm-<hash>-old`, which is no project VM's name, so nothing else takes it for one. On Lima that's `limactl rename`, which keeps the old disk whole.
|
||||
4. devvm makes the new machine by the VM's name from the new image, with what the state records: its project folder, its agents' folders, the tools share, its SSH agent, its size, its ports and its ssh port. It records that the new machine was made, and clears which of its `devcontainer.json`'s commands ran, so those that run once run again. Then it starts the VM as every start does ([an existing VM](#an-existing-vm), steps 4 to 8), which pins its new host keys.
|
||||
4. devvm makes the new machine by the VM's name from the new image, with what the state records: its project folder, its agents' folders, the tools share, its SSH agent, its size, its ports and its ssh port. It records that the new machine was made, and it keeps in the remake's section what the VM had of its base's `from`, its shared tools, its ports and its `devcontainer` section (`remake.was`), so an undo can give them back. It clears which of its `devcontainer.json`'s commands ran, so those that run once run again. Then it starts the VM as every start does ([an existing VM](#an-existing-vm), steps 4 to 8), which pins its new host keys.
|
||||
5. devvm puts the saved home folder in, with `tar --skip-old-files` as the VM's user, so what the new image has stays the image's. The new machine is the VM from then on, so devvm records the new `image` and `chain`, and that the new machine is done.
|
||||
6. devvm deletes the old machine and ends the remake, which removes the section, then deletes `home.tar.gz` and opens the VM as an existing VM, setting it up first. With network policy, the proxy reads the VM's layers from its image, so the new layers' allowlists apply from then, and those of layers taken out no longer do, as what the proxy started with has changed ([the proxy](network.md#the-proxy)). The VM's `id`, its alias and every other field stay as they were ([a VM made again](design.md#a-vm-made-again)).
|
||||
|
||||
Until the new machine has the home folder in step 5, a failure or an interrupt runs the remake's cleanup (`remake_undone`). It deletes the new machine, renames the old one back, whose next start makes it what the state asks for, as every start does, records that the machine by the VM's name is the old one, and ends the remake. When it can't, it warns (`remake_undo_failed`) and leaves the remake recorded. The section goes before `home.tar.gz` does, so the saved home folder is there for as long as the remake is recorded. After step 5, nothing deletes the new machine, and a failure to delete the old one leaves the remake recorded as done.
|
||||
Until the new machine has the home folder in step 5, a failure or an interrupt runs the remake's cleanup (`remake_undone`). It deletes the new machine, renames the old one back, whose next start makes it what the state asks for, as every start does, records that the machine by the VM's name is the old one, gives the VM back the `from`, shared tools, ports and `devcontainer` section that step 4 kept, and ends the remake. When it can't, it warns (`remake_undo_failed`) and leaves the remake recorded. The section goes before `home.tar.gz` does, so the saved home folder is there for as long as the remake is recorded. After step 5, nothing deletes the new machine, and a failure to delete the old one leaves the remake recorded as done.
|
||||
|
||||
`devvm clone on` and `devvm clone off` make the VM again from the image it has, in the other clone mode, which the remake records (`remake.clone`), so a remake that didn't finish is finished in that mode ([switching a VM that exists](../using/clone.md#switching-a-vm-that-exists)). Before anything changes, `devvm clone on` checks the folder as `--clone` does, and after the question `devvm clone off` checks the clone as `devvm rm` does, unless `--no-clone-check`. In step 4 the new machine mounts the project folder, or mounts none of it and keeps the clone at the folder's path, and devvm records its mode when it records that the new machine was made. For the folder mounted, the mode comes with the `.git` protection a new VM gets. Before the new machine starts, devvm removes the repo's remote for the clone, keeping the work fetched from it as [saved branches](#saved-branches), and then locks `.git`, because git can't change a locked `.git/config`. After `devvm clone on`, devvm takes the `.git` locks off in step 6, once the old machine is deleted and it has checked `.git` as a launch that finds the VM stopped does. Undoing the remake sets the old mode back, takes off the locks the new machine got, and adds the remote back.
|
||||
|
||||
@@ -63,13 +63,26 @@ A devvm holds the VM's remake lock, `run/remake.lock` in the VM's folder, from w
|
||||
|
||||
A remake that's recorded while no devvm holds the lock didn't finish, because devvm was killed or its cleanup failed. The next `devvm`, `devvm layer add`, `devvm layer rm`, `devvm update`, `devvm clone on` or `devvm clone off` in the folder finishes it without asking (`remake_resuming`). When the new machine is done, devvm deletes the old one and ends the remake. When the old machine is still aside, or the new one was never made, so the machine by the VM's name is the old one, devvm puts the old machine back and makes the VM again from step 1. Otherwise the old machine is gone, and the new one, made or not, never ran a shell, so devvm checks the remake again as before step 1, deletes the new machine and makes it again from step 4 with the saved home folder, or without one, warning, when the file is gone (`remake_home_lost`). Meanwhile every other command that acts on the VM refuses (`remake_pending`), `devvm gc --orphans` never takes the VM for an orphan, though the backend may have no machine by its name, and `devvm rm` deletes the VM and its old machine too.
|
||||
|
||||
### Reading the devcontainer.json again
|
||||
|
||||
A VM's `devcontainer` section records more than the file's SHA-256 and what it maps to of the VM's own. It records which of the VM's parts came from the file and which from you, so that `devvm update` can replace only the file's. `parts` lists the toolchains and layers the file's features mapped to when devvm last read it, and `gave` lists those of them the VM got from the file alone. A part isn't the file's when `--tools` or `--layers` chose that part's list, when `devvm setup`'s layers have it, when the folder's other files call for it, or when you unchecked it in the list. `ports` lists the file's `forwardPorts`, and `ports_gave` lists those of them that devvm added to the VM's ports, as `devvm ports add` adds them, because your ports didn't forward them already and you didn't give `--ports`. `image` is the container image the file names, recorded only when the VM's base starts from it, and `from_flag` records that you gave `--from`, which wins over the file's image for as long as the VM exists.
|
||||
|
||||
When the folder's file isn't the one the VM was made from, because it changed, it's gone or it appeared, `devvm update` reads it again as a new VM's file is read and refuses what a new VM refuses (`devcontainer_reread`, or `devcontainer_gone` for a file that's gone). Then it works out what the VM is made again with:
|
||||
|
||||
- **Its parts.** devvm drops the parts in `gave` that the file no longer calls for, and adds the ones the file now calls for that weren't in `parts` and that the VM lacks (`devcontainer.Reread`). A part you took out stays out, and your own parts stay. Layers go into the new image's name, after the layers the VM keeps, and toolchains go into its shared tools.
|
||||
- **Its base.** With `from_flag`, the base stays as it is, and devvm says the file's image is ignored. When the file names another image, devvm pins it to the digest its registry gives anyone, as for a new VM. When the file no longer names one, the base starts from `$DEVVM_FROM`, or else from Ubuntu's cloud image.
|
||||
- **Its ports.** In the same way, devvm takes out the ports in `ports_gave` that the file no longer lists, with the rule `devvm ports rm` follows, and adds the ones it lists anew that the VM's ports don't already forward, with the rule `devvm ports add` follows (`filePorts`). A port you took out with `devvm ports rm` stays out, your own ports stay, and with every port forwarded nothing changes. A port of the file's that's part of one of your ranges counts as yours.
|
||||
- **Its variables and commands.** The file's new ones replace the old ones, and the commands that run once run on the new disk.
|
||||
|
||||
The remake records all of this in its section (`remake.reread`): the new base's `from`, the shared tools, the ports and the new `devcontainer` section. After step 1 builds the new image from the new base, devvm builds the shared tools for that base, as for a new VM, and records their files there too, holding the lock that new VMs hold so that `devvm gc` keeps the tool images. In step 4 the VM gets all four, so the port forwarder starts with the new ports when the VM starts, and an undo gives back what it had. A remake that didn't finish keeps them, so it's finished with what the file said when `devvm update` read it.
|
||||
|
||||
## An existing VM
|
||||
|
||||
When you run `devvm` in a folder whose VM exists, devvm opens the VM as it is and starts it if it's stopped. Each time, it does these steps in this order:
|
||||
|
||||
1. devvm warns when an image the VM was made from has changed since, or when there are newer shared tools than the VM's, and both warnings name `devvm update`, which moves the VM to the newer tools and, after asking, makes it again from the changed image ([outdated VMs](../using/images.md#outdated-vms)). It also checks for newer tools once a day.
|
||||
2. devvm ignores the options for new VMs, with a warning for each. The VM keeps its shared tools, which `devvm tools` changes, and its layers, which `devvm layer add` and `devvm layer rm` change. It keeps its network policy, which `devvm network` changes, and its `.git` protection, which `devvm git-protect` changes. It keeps its size, which `devvm size` changes, its ports, which `devvm ports` changes, and its SSH agent forwarding, which `devvm ssh-agent` changes. It also keeps its backend, and ignores `--from` and `--no-devcontainer`.
|
||||
3. devvm warns when the folder's `devcontainer.json` isn't the one the VM was made from ([details](../using/devcontainer.md#when-its-read)).
|
||||
3. devvm warns when the folder's `devcontainer.json` isn't the one the VM was made from, and the warning names `devvm update`, which makes the VM again as the file says now ([details](../using/devcontainer.md#when-its-read)).
|
||||
4. devvm asks the backend for the VM's status and config, once for the whole start. It compares the VM's [agent folder mounts](../using/coding-agents.md#mounts) with the folders on this machine and names the folders that changed. A running VM gets the new mounts when it next starts. When a running VM has changes waiting for its next start, such as these mounts, a new size, a change to its agent forwarding or its network policy turned off while it ran confined, devvm names them in at most two lines, one for each change (`next_start_size`, `next_start_agent`, `next_start_mounts`, `next_start_net_off`), or past two the first change and how many more (`next_start_more`). Then it asks once, in a terminal, whether to restart it now (`restart_now`), yes by default (`[Y/n]`) when the mounts are among the changes and no by default (`[y/N]`) otherwise. A yes stops the VM here, so the steps below start it with the changes, and a no leaves it running.
|
||||
5. devvm checks `.git` ([on each launch](git-protection.md#on-each-launch)) and, on Linux hosts when it finds the VM stopped, names the set-id files in the folder. It skips both for a `--clone` VM, which mounts neither.
|
||||
6. devvm checks that the backend can still give the VM what its state asks for: its network policy, its ports and its [SSH agent forwarding](../using/ssh.md#agent-forwarding), and turning that forwarding on or off when the VM has it the other way. A backend that can't is refused before anything starts. When the VM forwards your agent, devvm checks that the agent has keys.
|
||||
@@ -196,10 +209,10 @@ A VM's state is `vm.json`, a JSON file that only devvm writes. It starts with th
|
||||
| `secrets` | secrets | the secrets bound to the VM |
|
||||
| `size` | `devvm size` | the CPUs, memory and disk asked for |
|
||||
| `clone` | `--clone` | whether the VM has its own clone, the repo's remote for it, and whether its branches were copied in |
|
||||
| `devcontainer` | a devcontainer.json | the file the VM was made from, its variables and commands, and which of them ran |
|
||||
| `devcontainer` | a devcontainer.json | the file the VM was made from, its variables and commands, which of them ran, and what of the VM came from the file and what from you ([reading it again](#reading-the-devcontainerjson-again)) |
|
||||
| `desktop` | `devvm desktop` | the desktop's password |
|
||||
| `links` | links and groups | the ports the VM publishes, its links and its group |
|
||||
| `remake` | `devvm layer add`, `devvm layer rm`, `devvm update` | while devvm [makes the VM again](#making-a-vm-again): the new image, the command, whether the home folder is kept and the history exported, whether the new machine was made, and whether it's done |
|
||||
| `remake` | `devvm layer add`, `devvm layer rm`, `devvm update` | while devvm [makes the VM again](#making-a-vm-again): the new image, the command, whether the home folder is kept and the history exported, what `devvm update` read again of the `devcontainer.json`, whether the new machine was made and what the VM had before it, and whether it's done |
|
||||
|
||||
Each section keeps what you asked for apart from what devvm made, which sits under the section's `made`. devvm reads fields it doesn't know without complaint and keeps them when it writes the file. A file that isn't JSON, lacks one of `version`, `id`, `name`, `image`, `dir` or `backend`, or holds a section devvm can't read is refused, and devvm names the file.
|
||||
|
||||
|
||||
@@ -26,11 +26,13 @@ A VM belongs to the folder it was made for, which devvm knows by its path and by
|
||||
|
||||
### A project's devcontainer.json
|
||||
|
||||
A project's [`devcontainer.json`](../using/devcontainer.md) belongs to the project, and so to the VM, which can rewrite it for the folder's next VM. devvm reads it only when it makes a VM, and uses only what it can do inside the VM. Nothing in it runs on this machine, so `initializeCommand` never runs. Nothing in it reaches this machine's files, because devvm doesn't follow a link out of the folder, or this machine's environment, because devvm refuses `${localEnv:…}` before it makes anything. It can't add a mount or change network policy or other confinement.
|
||||
A project's [`devcontainer.json`](../using/devcontainer.md) belongs to the project, and so to the VM, which can rewrite it for the folder's next VM, or for the VM itself when you run `devvm update`. devvm reads it only when it makes a VM, new or again, and uses only what it can do inside the VM. Nothing in it runs on this machine, so `initializeCommand` never runs. Nothing in it reaches this machine's files, because devvm doesn't follow a link out of the folder, or this machine's environment, because devvm refuses `${localEnv:…}` before it makes anything. It can't add a mount or change network policy or other confinement.
|
||||
|
||||
Its commands run in the VM as the VM's user, confined like anything else in it. Its features can only be devvm's own layers, so devvm never fetches or runs a feature's script, and it refuses `docker-outside-of-docker`. devvm uses its `image` only when the image's registry gives it to anyone who asks anonymously, so it never uses a container image that only your Docker has or that only your registry login reaches. It refuses a registry named `localhost` or by an address that isn't the internet's, and its lookup connects only to the internet's addresses, so it never uses an image on this machine or its network, except through a company proxy, which resolves the registry's name itself ([attack vectors](../safety/attack-vectors.md#spreading-beyond-the-vm)).
|
||||
|
||||
An existing VM never changes when the file does.
|
||||
An existing VM never changes when the file does, until you run `devvm update`, which says it reads the file again and asks before it makes the VM again. The file read again is held to the same refusals as a new VM's, and it can't replace a base you chose with `--from`, bring back a port you took out with `devvm ports rm`, or change its network policy, size, SSH agent or `.git` protection, which devvm keeps.
|
||||
|
||||
Its `forwardPorts` are added to the VM's ports, as `devvm ports add` adds them, even beyond a list you narrowed, both when devvm makes the VM and when `devvm update` reads the file again. They go through the one port forwarder, so they listen on this machine's loopback alone (127.0.0.1 and ::1), never take a port that a program on this machine has, and never take a port another VM forwards ([port forwarding](ports.md)). What a cloned repo's file opens is so only what `devvm ports add` could open, but it reaches whatever on this machine connects to those ports, a browser's pages included ([attack vectors](../safety/attack-vectors.md#network)).
|
||||
|
||||
### Read-only and confined builds
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
|
||||
- **Typosquatting, dependency confusion and made-up names.** Attackers publish packages under names one typo away from popular ones, under a company's internal package names with a higher version, and under names that AI coding agents invent and that attackers then register. Their code runs as the scripts above do.
|
||||
- **Compromised maintainers.** A trusted package can turn malicious when its maintainer's account is taken over or a new maintainer joins with bad intent, as event-stream (2018) and xz (2024) did. Updating such a package runs its new code in the VM.
|
||||
- **Malicious images.** An image from [`--from`](../using/from.md) or from a devcontainer's `image` runs its own code as root in the build VM ([the image is untrusted](../internals/images.md#the-image-is-untrusted)). devvm uses only images that the registry gives to anyone who asks anonymously, never one that only your Docker or your registry login reaches, and it confines builds so they reach the internet but not this machine's services ([read-only and confined builds](../internals/security.md#read-only-and-confined-builds)).
|
||||
- **A devcontainer.json's commands and features.** A project's `postCreateCommand` and its other commands run in the VM as the VM's user, as soon as devvm makes the VM. Its image and features decide what's in the VM, and devvm forwards its ports as far as your own port settings allow, so the VM is the project's from the start. Its features can only be devvm's own layers, so devvm never fetches or runs a feature's script. `devvm --no-devcontainer` skips the file for a project you don't trust that far ([devcontainer.json](../using/devcontainer.md)).
|
||||
- **A devcontainer.json's commands and features.** A project's `postCreateCommand` and its other commands run in the VM as the VM's user, as soon as devvm makes the VM. Its image and features decide what's in the VM, and devvm adds its ports to the ones it forwards to this machine's `localhost`, even beyond a list you narrowed, so the VM is the project's from the start. Its features can only be devvm's own layers, so devvm never fetches or runs a feature's script. `devvm --no-devcontainer` skips the file for a project you don't trust that far ([devcontainer.json](../using/devcontainer.md)).
|
||||
|
||||
### Rogue agents
|
||||
|
||||
@@ -95,7 +95,7 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
|
||||
### Network
|
||||
|
||||
- **Domain fronting.** The proxy checks the host name that a TLS connection asks for, its SNI, but not the `Host` inside the encrypted traffic, so a CDN that serves many sites on one address can route an allowed connection to a site that isn't allowed. The proxy reads the connections to hosts with a bound secret, and it refuses a request in them that names another host.
|
||||
- **Ports the VM listens on.** devvm forwards the VM's TCP ports from 1024 up to this machine's `localhost`, unless you list the ports with [`--ports`](../using/ports-size.md#size-and-ports), so a VM could take a port that a program on this machine trusts while that port is free, and what the VM serves there reaches whatever connects to it. devvm's forwarder never takes a port that a program on this machine already has, or one that devvm records for a VM, but a program that binds a port on all addresses after devvm forwarded it gets its `localhost` connections sent to the VM. `devvm ports` limits what a VM forwards, and `devvm ports none` forwards nothing ([ports](../using/ports-size.md#ports), [port forwarding](../internals/ports.md)).
|
||||
- **Ports the VM listens on.** devvm forwards the VM's TCP ports from 1024 up to this machine's `localhost`, unless you list the ports with [`--ports`](../using/ports-size.md#size-and-ports), so a VM could take a port that a program on this machine trusts while that port is free, and what the VM serves there reaches whatever connects to it. devvm's forwarder never takes a port that a program on this machine already has, or one that devvm records for a VM, but a program that binds a port on all addresses after devvm forwarded it gets its `localhost` connections sent to the VM. `devvm ports` limits what a VM forwards, and `devvm ports none` forwards nothing, though a project's `devcontainer.json` adds its `forwardPorts` to that list when devvm makes the VM or `devvm update` reads the file ([devcontainer.json](../using/devcontainer.md#security), [ports](../using/ports-size.md#ports), [port forwarding](../internals/ports.md)).
|
||||
- **VS Code's relays.** Over Remote-SSH, which `devvm code` opens, VS Code forwards the ports that programs in the VM listen on, and it answers git's prompts with your GitHub sign-in. devvm turns both off in the VM's VS Code settings each time it sets the VM up, but the VM can turn them back on, so turn them off in your own VS Code settings as well ([VS Code](../using/ssh.md#vs-code)).
|
||||
- **What a VM does through a link.** A [link between VMs](../using/links.md) joins the two VMs' trust. Code in the client can often run code in the target through the service it reaches, such as Postgres's `COPY … TO PROGRAM`, and it then has the target's network, the secrets it may use and its project folder. devvm limits a link to the ports the target publishes, on the target's loopback, and a client with network policy to targets with network policy, but it doesn't limit what the service does. In a [group](../using/links.md#groups), every VM trusts every other in the same way, and a VM that joins later gets the same reach ([links between VMs](network.md#links-between-vms)).
|
||||
- **What one VM learns of another through the shared Nix cache.** VMs with network policy and the nix layer share one cache of Nix's packages on this machine. A VM can tell by how fast the cache answers whether some VM fetched a public package. The packages are public, and a project's `flake.lock` names the ones it needs, so this tells a VM only that another project on this machine uses a package. A VM that fetches many packages can also fill the cache up to its cap and push other VMs' packages out, so they download them again, but it can't fill the disk past the cap or keep anything that cache.nixos.org didn't sign ([the shared Nix cache](../internals/network.md#the-shared-nix-cache)).
|
||||
|
||||
@@ -20,9 +20,9 @@ The settings devvm supports are the container image to start from, the features
|
||||
|
||||
## When it's read
|
||||
|
||||
- **Only when the folder's VM is made.** Comments and trailing commas are allowed. devvm reads the file only within the folder, so it doesn't follow a link out of the folder, and it reads only a regular file of up to 1 MiB. devvm never writes anything to the project folder.
|
||||
- **When the folder's VM is made, and again by `devvm update`.** Comments and trailing commas are allowed. devvm reads the file only within the folder, so it doesn't follow a link out of the folder, and it reads only a regular file of up to 1 MiB. devvm never writes anything to the project folder.
|
||||
- **What you give on the command line wins.** `--from` wins over `image`, which wins over `$DEVVM_FROM`, and `--ports` wins over `forwardPorts`, and devvm says so in one line for each. The toolchains and layers that the features map to are checked by default in the list devvm shows for the new VM, each row naming the file, and you can uncheck them there. `--tools` and `--layers` replace them, as they replace any part's default ([what a new VM gets](images.md#what-a-new-vm-gets)).
|
||||
- **An existing VM never changes.** Its state records the file's SHA-256. When the file differs from it on a launch, or is gone, or has appeared since, devvm warns once, and running `devvm rm` and then `devvm` makes the VM again from the file as it is. devvm doesn't check a VM made with `--no-devcontainer`.
|
||||
- **An existing VM changes only when devvm makes it again.** Its state records the file's SHA-256. When the file differs from it on a launch, or is gone, or has appeared since, devvm warns once and names `devvm update`. devvm doesn't check a VM made with `--no-devcontainer`, and `devvm update` doesn't read the file for it.
|
||||
|
||||
A new VM takes each of these from the first place that sets it.
|
||||
|
||||
@@ -30,7 +30,7 @@ A new VM takes each of these from the first place that sets it.
|
||||
flowchart TD
|
||||
subgraph ports["Its ports"]
|
||||
direction TB
|
||||
flag["--ports"] -- "or else" --> fwd["forwardPorts, as far<br>as your ports allow"]
|
||||
flag["--ports"] -- "or else" --> fwd["your ports, with<br>forwardPorts added"]
|
||||
end
|
||||
subgraph base["Its base starts from"]
|
||||
direction TB
|
||||
@@ -42,13 +42,26 @@ flowchart TD
|
||||
|
||||
When devvm refuses something in the file, it stops with one line that names the file, before it makes anything. For invalid JSON, it names the line and column.
|
||||
|
||||
## Updating a VM from the file
|
||||
|
||||
When you change the file, run `devvm update`. devvm reads the file as it is now, and before it changes anything, it refuses what it would refuse for a new VM. Then it asks to make the VM again from the file, keeping its home folder, the project folder and its settings, as for an [outdated VM](images.md#outdated-vms), and everything else on the VM's disk is lost. `devvm update --force` doesn't ask, and without a terminal devvm refuses unless you give `--force`.
|
||||
|
||||
devvm replaces only what the file gave the VM, and it keeps what you chose:
|
||||
|
||||
- **Toolchains and layers.** The ones the file's features gave the VM go when the file no longer has those features, and the ones the file's new features map to are added. The ones you chose yourself stay, whether you gave them with `--tools` or `--layers`, `devvm setup` chose them, or the folder's other files call for them. One you unchecked in the list, or took out later, stays out.
|
||||
- **The container image.** The VM's base starts from the file's new `image`, pinned as for a new VM. When the file no longer has one, the base starts from `$DEVVM_FROM`, or else from Ubuntu's cloud image. A VM made with `--from` keeps its base, and devvm says that it ignores `image`.
|
||||
- **The ports.** The ports the file added go when the file no longer lists them, and the ones it lists anew are added, as `devvm ports add` adds them. The ports you added with `devvm ports add` stay, and one of the file's that you took out with `devvm ports rm` stays out. A VM made with `--ports` gets the ports the file lists anew, but not the ones `--ports` won over.
|
||||
- **The environment and the commands.** They're the file's new ones, and the commands that run once run again on the new disk.
|
||||
|
||||
When the file is gone, devvm makes the VM again without it, so what the file gave goes, and so do its environment and commands. When a file appears for a VM made without one, devvm makes the VM again as the file says, as it would a new VM.
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | What devvm does |
|
||||
| --- | --- |
|
||||
| `image` | The VM's base starts from it, as with [`--from`](from.md). devvm uses only an image that its registry gives anyone who asks anonymously, pinned to that digest. It never uses an image only Docker has, one only your registry login reaches, or one on this machine or its network, which is `localhost` or a registry whose address is loopback, private or link-local, by name or as it resolves. |
|
||||
| `features` | `ghcr.io/devcontainers/features/docker-in-docker` is devvm's [docker layer](images.md#built-in-layers). `node`, `python`, `rust` and `go` under `ghcr.io/devcontainers/features/` are the [shared toolchains](images.md#shared-tools). devvm ignores their options and says so in one line. It refuses `docker-outside-of-docker`, which is this machine's Docker, and every other feature. devvm never fetches or runs a feature's script. |
|
||||
| `forwardPorts` | devvm forwards numbers, `localhost:N` and `127.0.0.1:N` as far as your ports allow ([ports](ports-size.md#ports)). With every port forwarded, which is the default, they're among them. devvm names the ones your ports leave out in one line and never adds them, and `devvm ports add` forwards them. It ignores other hosts' ports and says so in one line. |
|
||||
| `forwardPorts` | devvm forwards numbers, `localhost:N` and `127.0.0.1:N` to this machine's `localhost` alone, adding them to your ports as `devvm ports add` does ([ports](ports-size.md#ports)). With every port forwarded, which is the default, they're among them already. `devvm ports rm` takes one out, as for any port. It ignores other hosts' ports and says so in one line. |
|
||||
| `containerEnv`, `remoteEnv` | The VM's environment, which login shells and the commands below get. `remoteEnv` wins over `containerEnv`, and devvm's own variables, such as `LANG` and secrets, win over both. A `remoteEnv` of `null` sets nothing. |
|
||||
| `onCreateCommand`, `updateContentCommand`, `postCreateCommand` | They run once, in that order, once the VM is made and set up ([commands](#commands)). |
|
||||
| `postStartCommand` | It runs at each start, on the first launch after the VM started. |
|
||||
@@ -77,4 +90,6 @@ devvm leaves any other `${…}` as it is, for the VM's shell, such as `${HOME}`
|
||||
|
||||
## Security
|
||||
|
||||
The file belongs to the project, so a VM can rewrite it for the folder's next VM, and devvm never lets it run anything on this machine, reach this machine's files or environment, add a mount or weaken confinement. An `image` from it can still be any public container image, whose own code runs as root while devvm builds the VM's base, as with `--from` ([security model](../internals/security.md#a-projects-devcontainerjson)).
|
||||
The file belongs to the project, so a VM can rewrite it for the folder's next VM, or for itself when you run `devvm update`, and devvm never lets it run anything on this machine, reach this machine's files or environment, add a mount or weaken confinement. An `image` from it can still be any public container image, whose own code runs as root while devvm builds the VM's base, as with `--from` ([security model](../internals/security.md#a-projects-devcontainerjson)).
|
||||
|
||||
Its `forwardPorts` open ports on this machine, even when you've narrowed your ports with `devvm ports -g` or `devvm ports`. devvm forwards them only to this machine's `localhost`, never to its other addresses, and never takes a port that a program on this machine already has, just as for `devvm ports add`. Anything on this machine that connects to such a port reaches what the VM serves there, including a web page in your browser, so for a repo you don't trust, check its file first, or run `devvm --ports none` or `devvm --no-devcontainer` ([ports the VM listens on](../safety/attack-vectors.md#network)).
|
||||
@@ -170,7 +170,7 @@ Shared tools aren't images, so `devvm rebuild` refuses a shared tool's name, and
|
||||
|
||||
A VM keeps the image it was made from. When that image, or one it's built on, changes after an edited script, another choice of base's features or a rebuild, the VM is outdated. devvm then warns on each launch, names the images that changed and `devvm update`, and leaves the VM as it is.
|
||||
|
||||
`devvm update` brings this folder's VM up to date in two steps. First it moves the VM to the newest shared tools, as `devvm tools update` does, and that needs no question, because the shared tools aren't part of the image and nothing on the VM's disk changes ([adding and removing tools](toolchains.md#adding-and-removing-tools)). Then, when the VM is outdated, devvm makes it again from its own image as it builds now, with the same layers, in the same way that `devvm layer add` makes a VM again with more layers. devvm builds the image first, then gives the VM a new disk copied from it, and keeps its home folder, the project folder and its settings ([what a VM made again keeps](#what-a-vm-made-again-keeps)). Everything else on its disk is lost, such as the packages you installed with apt and Docker's images, so in a terminal devvm names the images that changed and asks first, with no as the default.
|
||||
`devvm update` brings this folder's VM up to date in two steps. First it moves the VM to the newest shared tools, as `devvm tools update` does, and that needs no question, because the shared tools aren't part of the image and nothing on the VM's disk changes ([adding and removing tools](toolchains.md#adding-and-removing-tools)). Then, when the VM is outdated, devvm makes it again from its own image as it builds now, with the same layers, in the same way that `devvm layer add` makes a VM again with more layers. devvm builds the image first, then gives the VM a new disk copied from it, and keeps its home folder, the project folder and its settings ([what a VM made again keeps](#what-a-vm-made-again-keeps)). Everything else on its disk is lost, such as the packages you installed with apt and Docker's images, so in a terminal devvm names the images that changed and asks first, with no as the default. When the folder's `devcontainer.json` changed since devvm made the VM, or is gone, or has appeared, devvm also makes the VM again, after asking, as the file says now ([updating a VM from the file](devcontainer.md#updating-a-vm-from-the-file)).
|
||||
|
||||
```sh
|
||||
devvm update # move the VM to the newest shared tools, and to its image's new build after asking
|
||||
|
||||
@@ -153,6 +153,6 @@ The commands below change the VM's tools from a script or the command line. They
|
||||
- `devvm tools add TOOL...` builds the tools that the share lacks and adds them to the VM. A new agent's config folders are mounted too, which needs the VM to start again, so for a running VM devvm asks before restarting it ([adding to a VM](../getting-started/commands.md#adding-to-a-vm)).
|
||||
- `devvm tools rm TOOL...` takes tools out. What the VM installed itself, such as other versions or global packages, stays.
|
||||
- `devvm tools update` checks upstream for newer versions, builds what's missing, and moves the VM to them. When the VM already has the newest versions, it builds any of them that are missing. It changes only the shared tools, and never makes the VM again.
|
||||
- `devvm update` does the same first, without asking, and then asks to make the VM again only when the VM's image has changed ([outdated VMs](images.md#outdated-vms)).
|
||||
- `devvm update` does the same first, without asking, and then asks to make the VM again only when the VM's image has changed ([outdated VMs](images.md#outdated-vms)), or its `devcontainer.json` has ([updating a VM from the file](devcontainer.md#updating-a-vm-from-the-file)).
|
||||
|
||||
`--tools`, `--agents` and `--layers` choose only what a new VM gets, so on a VM that exists they change nothing, and devvm warns and names `devvm tools`. Layers aren't shared tools, so `devvm tools` can't add or take out a layer such as `docker` or `nix`. A VM gets its layers when devvm makes it, so `devvm layer add` and `devvm layer rm` change them by making the VM again, after asking ([adding layers to a VM](images.md#adding-layers-to-a-vm)).
|
||||
@@ -14,7 +14,7 @@ func newUpdateCmd(a *app) *cobra.Command {
|
||||
Use: "update",
|
||||
Short: "Bring this folder's VM up to date, then open a shell in it",
|
||||
Long: "Move this folder's VM to the newest shared tools, as devvm tools update does, then open a shell in it. " +
|
||||
"When its image changed since devvm made the VM, devvm then asks to make the VM again from the image's new build, with the same layers, keeping its home folder, the project folder and its settings, and everything else on its disk is lost. " +
|
||||
"When its image changed since devvm made the VM, or the folder's devcontainer.json did, devvm then asks to make the VM again from the image's new build and the file as it is now, keeping its home folder, the project folder and its settings, and everything else on its disk is lost. " +
|
||||
"When its image has an agent, devvm first exports the agents' history, unless you give --no-export.",
|
||||
Example: examples(
|
||||
"devvm update", "move the VM to the newest tools, and to its image's new build after asking",
|
||||
@@ -23,6 +23,7 @@ func newUpdateCmd(a *app) *cobra.Command {
|
||||
),
|
||||
Args: noArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
o.DefaultFrom = fromRef("")
|
||||
return a.env(func(env *vm.Env) error {
|
||||
return vm.Lifecycle{Env: env}.Update(cmd.Context(), "devvm update", o)
|
||||
}, msg.RemakeFailed)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Package devcontainer reads a project's devcontainer.json as input for a
|
||||
// new VM: Find finds it in the project folder, Parse reads it (JSON with
|
||||
// comments and trailing commas) into a Plan, what devvm does with it, and
|
||||
// refuses what devvm won't do. The file is the project's, so the VM's: a
|
||||
// new VM, or one devvm update makes again: Find finds it in the project
|
||||
// folder, Parse reads it (JSON with comments and trailing commas) into a
|
||||
// Plan, what devvm does with it, and refuses what devvm won't do, and
|
||||
// Reread works out what a VM's parts become when it's read again. The file is the project's, so the VM's: a
|
||||
// plan only shapes what runs inside the VM, and nothing in it ever runs on
|
||||
// the host, reaches its paths or environment, or adds mounts.
|
||||
package devcontainer
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package devcontainer
|
||||
|
||||
import "slices"
|
||||
|
||||
// Reread is what a VM made with a devcontainer.json gets of its
|
||||
// features' toolchains and layers when the file is read again (devvm
|
||||
// update): was is what the features mapped to when the file was last
|
||||
// read (a Plan's Layers), gave those of them the VM got from the file
|
||||
// alone, has the toolchains and layers the VM has, and now what the
|
||||
// features map to now. It drops what the file gave that it no longer
|
||||
// calls for (drop), adds what it calls for anew that the VM lacks (add),
|
||||
// and leaves the rest as it is: what the user chose, added or took out,
|
||||
// and what the file called for before. gaveNow is what the VM then has
|
||||
// from the file alone; what it gave that the VM no longer has, taken out
|
||||
// since, is neither dropped nor kept.
|
||||
func Reread(was, gave, has, now []string) (add, drop, gaveNow []string) {
|
||||
for _, p := range gave {
|
||||
switch {
|
||||
case !slices.Contains(has, p):
|
||||
case !slices.Contains(now, p):
|
||||
drop = append(drop, p)
|
||||
default:
|
||||
gaveNow = append(gaveNow, p)
|
||||
}
|
||||
}
|
||||
for _, p := range now {
|
||||
if slices.Contains(was, p) || slices.Contains(has, p) || slices.Contains(add, p) {
|
||||
continue
|
||||
}
|
||||
add = append(add, p)
|
||||
gaveNow = append(gaveNow, p)
|
||||
}
|
||||
return add, drop, gaveNow
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package devcontainer
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Reread replaces what the file gave and nothing else: the user's parts
|
||||
// stay, what the user took out of the file's doesn't come back, and only
|
||||
// what the file calls for anew is added.
|
||||
func TestReread(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
was, gave, has, now []string
|
||||
add, drop, gaveNow []string
|
||||
}{
|
||||
{
|
||||
name: "unchanged", was: []string{"docker", "node"}, gave: []string{"docker", "node"},
|
||||
has: []string{"docker", "node"}, now: []string{"docker", "node"},
|
||||
gaveNow: []string{"docker", "node"},
|
||||
},
|
||||
{
|
||||
name: "the file's replaced", was: []string{"docker", "node"}, gave: []string{"docker", "node"},
|
||||
has: []string{"docker", "node", "claude"}, now: []string{"go"},
|
||||
add: []string{"go"}, drop: []string{"docker", "node"}, gaveNow: []string{"go"},
|
||||
},
|
||||
// docker was the user's (--layers), so the file dropping it keeps it.
|
||||
{name: "the user's kept", was: []string{"docker"}, has: []string{"docker", "extra"}, now: nil},
|
||||
// node was unchecked when the VM was made: still called for, it
|
||||
// stays out; rust is new.
|
||||
{
|
||||
name: "an unchecked one stays out", was: []string{"docker", "node"}, gave: []string{"docker"},
|
||||
has: []string{"docker"}, now: []string{"docker", "node", "rust"},
|
||||
add: []string{"rust"}, gaveNow: []string{"docker", "rust"},
|
||||
},
|
||||
// The VM has go already, the user's: it stays the user's.
|
||||
{
|
||||
name: "new and had", has: []string{"go"}, now: []string{"go", "docker"},
|
||||
add: []string{"docker"}, gaveNow: []string{"docker"},
|
||||
},
|
||||
// python was the file's, then taken out with devvm tools rm.
|
||||
{name: "taken out since", was: []string{"python"}, gave: []string{"python"}, now: nil},
|
||||
{name: "a new file", now: []string{"docker", "docker"}, add: []string{"docker"}, gaveNow: []string{"docker"}},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
add, drop, gaveNow := Reread(c.was, c.gave, c.has, c.now)
|
||||
if !slices.Equal(add, c.add) || !slices.Equal(drop, c.drop) || !slices.Equal(gaveNow, c.gaveNow) {
|
||||
t.Errorf("Reread = add %q, drop %q, gave %q; want %q, %q, %q", add, drop, gaveNow, c.add, c.drop, c.gaveNow)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+412
-413
@@ -6,419 +6,418 @@ package msg
|
||||
// prints the page's address on the line after the message's text.
|
||||
// TestDocLinks checks every entry.
|
||||
var docs = map[string]string{ //nolint:gosec // message IDs and pages, not credentials
|
||||
"backend_lacks": "backends#when-a-backend-lacks-something",
|
||||
"backend_unreviewed": "backends#when-a-backend-lacks-something",
|
||||
"backend_unreviewed_used": "contributing/testing#unreviewed-emulations",
|
||||
"backend_unknown_vm": "backends#a-vms-backend",
|
||||
"ports_forward_failed": "using/ports-size#ports",
|
||||
"net_off_backend": "backends#when-a-backend-lacks-something",
|
||||
"net_about": "safety/network#turning-it-on-or-off",
|
||||
"disk_low": "using/troubleshooting#not-enough-free-space",
|
||||
"disk_low_warning": "using/ports-size#free-space",
|
||||
"disk_free_unknown": "using/troubleshooting#not-enough-free-space",
|
||||
"lima_missing": "backends/lima#requirements",
|
||||
"lima_broken": "backends/lima#requirements",
|
||||
"lima_old": "backends/lima#requirements",
|
||||
"lima_host_unsupported": "backends/lima#requirements",
|
||||
"qemu_missing": "backends/lima#requirements",
|
||||
"lima_missing_fix": "backends/lima#requirements",
|
||||
"lima_broken_fix": "backends/lima#requirements",
|
||||
"lima_old_fix": "backends/lima#requirements",
|
||||
"qemu_missing_fix": "backends/lima#requirements",
|
||||
"lima_arch_unsupported": "backends/lima#requirements",
|
||||
"macos_old": "backends/lima#requirements",
|
||||
"no_kvm": "backends/lima#requirements",
|
||||
"kvm_access": "backends/lima#requirements",
|
||||
"lima_global_config": "backends/lima#devvms-lima-home",
|
||||
"vm_has_networks": "backends/lima#devvms-lima-home",
|
||||
"lima_home_too_long": "backends/lima#limits",
|
||||
"mount_comma": "backends/lima#limits",
|
||||
"disk_shrink": "backends/lima#limits",
|
||||
"image_in_use": "using/images#deleting-images",
|
||||
"image_building": "using/images#deleting-images",
|
||||
"qemu_refused": "internals/lima#confinement",
|
||||
"start_no_ssh": "using/troubleshooting#a-vm-wont-boot",
|
||||
"lima_log_unredacted": "using/troubleshooting#a-command-fails",
|
||||
"no_ubuntu_image": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"no_ubuntu_release": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"origin_no_boot": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"ubuntu_unreachable": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"ubuntu_bad_signature": "using/troubleshooting#a-download-doesnt-check-out",
|
||||
"ubuntu_newest_older": "using/troubleshooting#a-download-doesnt-check-out",
|
||||
"unknown_layer": "using/images#layers",
|
||||
"default_layer_gone": "using/settings#layers-for-new-vms",
|
||||
"default_layer_lacks": "using/settings#layers-for-new-vms",
|
||||
"layer_name_invalid": "using/customizing#your-own-layers",
|
||||
"layer_name_reserved": "using/customizing#your-own-layers",
|
||||
"layer_created": "using/customizing#your-own-layers",
|
||||
"base_features": "using/customizing#choosing-features",
|
||||
"base_features_none": "using/customizing#choosing-features",
|
||||
"unknown_feature": "using/customizing#choosing-features",
|
||||
"script_failed": "using/troubleshooting#a-build-fails",
|
||||
"build_sources_unreachable": "using/troubleshooting#no-package-source-answers",
|
||||
"packages_lists_missing": "using/troubleshooting#a-build-fails",
|
||||
"packages_missing": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"packages_not_newest": "using/troubleshooting#a-build-fails",
|
||||
"packages_refused": "using/troubleshooting#a-build-fails",
|
||||
"packages_stale": "using/troubleshooting#base-gets-old-package-lists",
|
||||
"packages_stale_mirror": "using/settings#an-ubuntu-mirror",
|
||||
"rebuild_replaces": "using/images#rebuilding",
|
||||
"layer_exists": "using/customizing#your-own-layers",
|
||||
"images_stale_note": "using/images#cleaning-up",
|
||||
"images_unused": "using/images#cleaning-up",
|
||||
"folders_not_private": "using/space#devvms-data-folder",
|
||||
"layout_newer": "using/troubleshooting#a-newer-devvm-changed-devvms-folders",
|
||||
"layout_unchecked": "using/troubleshooting#a-file-devvm-cant-read",
|
||||
"vm_state_unreadable": "using/troubleshooting#a-file-devvm-cant-read",
|
||||
"vms_stray": "using/space#what-devvm-doctor-finds-in-vms",
|
||||
"vm_folder_stateless": "using/space#what-devvm-doctor-finds-in-vms",
|
||||
"vms_unreadable": "using/space#what-devvm-doctor-finds-in-vms",
|
||||
"retention_busy": "using/settings#retention",
|
||||
"retention_unreadable": "using/settings#retention",
|
||||
"retention_failed": "using/settings#retention",
|
||||
"retention_bad": "using/settings#retention",
|
||||
"set_in_config": "using/settings#configtoml",
|
||||
"gc_backend_skipped": "using/images#cleaning-up",
|
||||
"gc_orphans_unknown": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"gc_orphan_elsewhere": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"gc_orphan_recent": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"gc_older_than_needs_history": "using/images#cleaning-up",
|
||||
"bad_duration": "getting-started/commands#flags-and-values",
|
||||
"gc_names_need_tools": "using/images#cleaning-up",
|
||||
"gc_tools_making": "using/images#cleaning-up",
|
||||
"unknown_tool": "using/toolchains#adding-and-removing-tools",
|
||||
"images_total": "using/space#devvm-space",
|
||||
"space_backend_unknown": "using/space#devvm-space",
|
||||
"space_stray": "using/space#vms-devvm-has-no-state-for",
|
||||
"space_caches_note": "using/space#limas-caches",
|
||||
"tool_not_locked": "using/images#shared-tools",
|
||||
"vm_outdated": "using/images#outdated-vms",
|
||||
"bad_path": "backends/lima#limits",
|
||||
"vm_name_no_room": "backends/lima#limits",
|
||||
"vm_other_folder": "getting-started/commands#a-folder-made-again",
|
||||
"vm_other_folder_rm": "getting-started/commands#a-folder-made-again",
|
||||
"vm_other_folder_adopt": "getting-started/commands#a-folder-made-again",
|
||||
"rm_unknown_vm": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_vm_folder_there": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_vm_lost": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"vm_moved_here": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"vms_moved_here": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_move_refused": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"move_folder_changed": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_folder_there": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_has_vm": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_clone": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"folder_next_start": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"rm_gone_stopped": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_gone_clone": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_vm_export_failed": "using/coding-agents#history",
|
||||
"space_folder_gone": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"space_folder_not_connected": "getting-started/commands#a-folder-on-a-disk-that-isnt-connected",
|
||||
"rm_vm_not_connected": "getting-started/commands#a-folder-on-a-disk-that-isnt-connected",
|
||||
"vm_unfinished": "using/troubleshooting#a-vm-whose-creation-didnt-finish",
|
||||
"create_running": "using/troubleshooting#a-vm-whose-creation-didnt-finish",
|
||||
"no_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"using_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"rm_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"widen_parent_vm_refused": "getting-started/commands#a-subfolder",
|
||||
"tools_joined": "using/toolchains#adding-and-removing-tools",
|
||||
"size_next_start": "using/ports-size#size",
|
||||
"rm_export_failed": "using/coding-agents#history",
|
||||
"history_not_exported": "using/coding-agents#history",
|
||||
"history_not_imported": "using/coding-agents#importing-history",
|
||||
"history_import_unsafe": "using/coding-agents#importing-history",
|
||||
"history_no_export": "using/coding-agents#importing-history",
|
||||
"history_import_later": "using/coding-agents#importing-history",
|
||||
"git_replaced": "safety/git-protection#not-covered",
|
||||
"git_appeared": "safety/git-protection#when-devvm-reports-git",
|
||||
"git_embedded_new": "safety/git-protection#strict",
|
||||
"git_hooks_unlocked": "safety/git-protection#when-devvm-reports-git",
|
||||
"unsafe_folder": "using/settings#project-folders-devvm-refuses",
|
||||
"unsafe_folder_inside": "using/settings#project-folders-devvm-refuses",
|
||||
"unsafe_folder_used": "using/settings#project-folders-devvm-refuses",
|
||||
"cpus_not_number": "using/ports-size#size-and-ports",
|
||||
"size_not_gib": "using/ports-size#size-and-ports",
|
||||
"too_many_cpus": "using/ports-size#size-and-ports",
|
||||
"too_much_memory": "using/ports-size#size-and-ports",
|
||||
"port_invalid": "using/ports-size#size-and-ports",
|
||||
"devvm_other_first": "getting-started/install#one-devvm",
|
||||
"host_memory_low": "getting-started/install#requirements",
|
||||
"host_cpus_few": "getting-started/install#requirements",
|
||||
"base_fitted": "using/ports-size#size-and-ports",
|
||||
"ports_list_needed": "using/ports-size#ports",
|
||||
"ports_rm_all": "using/ports-size#ports",
|
||||
"ports_taken": "using/troubleshooting#a-listed-port-isnt-forwarded",
|
||||
"ca_not_certificate": "using/settings#a-companys-ca",
|
||||
"ca_not_ca": "using/settings#a-companys-ca",
|
||||
"ca_invalid": "using/settings#a-companys-ca",
|
||||
"ca_link": "using/settings#a-companys-ca",
|
||||
"ca_folder_link": "using/settings#a-companys-ca",
|
||||
"ca_unreadable": "using/settings#a-companys-ca",
|
||||
"ca_folder_unreadable": "using/settings#a-companys-ca",
|
||||
"doctor_proxy_ca": "using/troubleshooting#tls-errors-behind-a-company-proxy",
|
||||
"net_direct_route": "safety/network#when-it-isnt-enforced",
|
||||
"net_unenforced_stop": "using/troubleshooting#a-vm-shows-as-unenforced",
|
||||
"net_unenforced": "using/troubleshooting#a-vm-shows-as-unenforced",
|
||||
"net_off_log": "safety/network#turning-it-on-or-off",
|
||||
"net_off_policy": "safety/network#turning-it-on-or-off",
|
||||
"net_ask_global": "safety/network#turning-it-on-or-off",
|
||||
"json_shows_only": "getting-started/commands#output-for-scripts",
|
||||
"net_flag_ignored": "safety/network#turning-it-on-or-off",
|
||||
"net_on_old_tokens": "safety/network#turning-it-on-or-off",
|
||||
"net_off_next_start": "safety/network#turning-it-on-or-off",
|
||||
"not_a_rule": "safety/network#rules",
|
||||
"proxy_start_failed": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"proxy_port_taken": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"proxy_stop_failed": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"upstream_proxy_scheme": "safety/network#behind-a-company-proxy",
|
||||
"upstream_proxy_invalid": "safety/network#behind-a-company-proxy",
|
||||
"ubuntu_mirror_invalid": "using/settings#an-ubuntu-mirror",
|
||||
"proxy_password_in_config": "safety/network#behind-a-company-proxy",
|
||||
"proxy_password_missing": "safety/network#behind-a-company-proxy",
|
||||
"secret_host_only": "safety/network#behind-a-company-proxy",
|
||||
"upstream_proxy_gone": "using/troubleshooting#behind-a-company-proxy",
|
||||
"proxy_needs_policy": "safety/network#without-network-policy",
|
||||
"net_proxy_down_stopped": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"no_secret": "safety/network#saving-and-binding-secrets",
|
||||
"codex_login_kept": "using/coding-agents#codex-and-opencode-logins",
|
||||
"opencode_login_kept": "using/coding-agents#codex-and-opencode-logins",
|
||||
"opencode_login_withheld": "using/coding-agents#codex-and-opencode-logins",
|
||||
"codex_no_key": "using/coding-agents#codex-and-opencode-logins",
|
||||
"codex_no_chatgpt": "using/coding-agents#codex-and-opencode-logins",
|
||||
"codex_refresh_failed": "using/coding-agents#codex-and-opencode-logins",
|
||||
"opencode_refresh_failed": "using/coding-agents#codex-and-opencode-logins",
|
||||
"login_read_failed": "using/coding-agents#codex-and-opencode-logins",
|
||||
"setid_files": "using/troubleshooting#devvm-names-set-id-files",
|
||||
"setid_root_files": "using/troubleshooting#devvm-names-set-id-files",
|
||||
"home_not_absolute": "using/troubleshooting#home-isnt-an-absolute-path",
|
||||
"net_unenforced_restart": "using/troubleshooting#a-vm-shows-as-unenforced",
|
||||
"adopt_failed": "getting-started/commands#a-folder-made-again",
|
||||
"clone_needs_git": "using/clone#requirements",
|
||||
"uncommitted_not_copied": "using/clone#whats-copied",
|
||||
"unfetched_commits": "using/clone#deleting-the-vm",
|
||||
"branch_names_invalid": "using/clone#deleting-the-vm",
|
||||
"git_protect_clone": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_protect_failed": "safety/git-protection#turning-it-on-or-off",
|
||||
"devcontainer_using": "using/devcontainer",
|
||||
"devcontainer_flag_wins": "using/devcontainer#when-its-read",
|
||||
"devcontainer_ignored": "using/devcontainer#properties",
|
||||
"devcontainer_unknown": "using/devcontainer#properties",
|
||||
"devcontainer_initialize": "using/devcontainer#properties",
|
||||
"devcontainer_feature_options": "using/devcontainer#properties",
|
||||
"devcontainer_ports_ignored": "using/devcontainer#properties",
|
||||
"git_protect_needs_macos_new": "safety/git-protection#linux-hosts",
|
||||
"git_protect_on_needs_macos": "safety/git-protection#linux-hosts",
|
||||
"git_protect_next_stop": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_unlocked": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_protect_flag_ignored": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_locked_strict": "safety/git-protection#strict",
|
||||
"git_config_failed": "safety/git-protection#strict",
|
||||
"git_commondir": "safety/git-protection#not-covered",
|
||||
"git_worktree_stray": "safety/git-protection#not-covered",
|
||||
"git_not_locked": "safety/git-protection#when-devvm-reports-git",
|
||||
"git_lock_raced": "safety/git-protection#when-devvm-reports-git",
|
||||
"git_hooks_path": "safety/git-protection#not-covered",
|
||||
"git_include_inside": "safety/git-protection#not-covered",
|
||||
"git_hook_link_inside": "safety/git-protection#not-covered",
|
||||
"git_gitdir_outside": "safety/git-protection#not-covered",
|
||||
"ssh_remote_hint": "using/ssh#agent-forwarding",
|
||||
"agent_on_risk": "using/ssh#agent-forwarding",
|
||||
"agent_devvm_risk": "using/ssh#devvms-own-agent",
|
||||
"agent_no_keys": "using/ssh#devvms-own-agent",
|
||||
"agent_key_changed": "using/ssh#devvms-own-agent",
|
||||
"agent_key_unpinned": "using/ssh#devvms-own-agent",
|
||||
"agent_key_no_fingerprint": "using/ssh#devvms-own-agent",
|
||||
"agent_key_mounted": "using/ssh#devvms-own-agent",
|
||||
"agent_confirm_needs_askpass": "using/ssh#devvms-own-agent",
|
||||
"ssh_include_yourself": "using/ssh#ssh-access-by-name",
|
||||
"no_code_command": "using/ssh#devvm-host-and-devvm-code",
|
||||
"desktop_no_layer": "using/desktop#adding-the-desktop",
|
||||
"desktop_start_failed": "using/desktop#when-the-desktop-doesnt-open",
|
||||
"desktop_open_failed": "using/desktop#when-the-desktop-doesnt-open",
|
||||
"clone_not_top": "using/clone#requirements",
|
||||
"clone_no_commits": "using/clone#requirements",
|
||||
"clone_detached": "using/clone#requirements",
|
||||
"clone_needs_new_vm": "using/clone#switching-a-vm-that-exists",
|
||||
"clone_show_failed": "using/clone#switching-a-vm-that-exists",
|
||||
"clone_git_elsewhere": "using/clone#requirements",
|
||||
"clone_alternates": "using/clone#requirements",
|
||||
"remotes_taken": "using/clone#the-remote",
|
||||
"fetch_until": "using/clone#the-remote",
|
||||
"no_terminal_fetch": "using/clone#deleting-the-vm",
|
||||
"saved_names_taken": "using/clone#deleting-the-vm",
|
||||
"remote_kept": "using/clone#deleting-the-vm",
|
||||
"no_terminal_delete": "using/clone#deleting-the-vm",
|
||||
"clone_worktrees_unchecked": "using/clone#deleting-the-vm",
|
||||
"tools_need_resolve": "using/images#shared-tools",
|
||||
"mise_checksum": "using/troubleshooting#a-download-doesnt-check-out",
|
||||
"tool_stepped_back": "using/troubleshooting#a-new-tool-release-isnt-there-yet",
|
||||
"tool_no_download": "using/troubleshooting#a-new-tool-release-isnt-there-yet",
|
||||
"tools_check_failed": "using/images#shared-tools",
|
||||
"newer_tools": "using/toolchains#adding-and-removing-tools",
|
||||
"tool_unbuilt": "using/troubleshooting#a-new-tool-release-isnt-there-yet",
|
||||
"tool_needs_glibc": "using/from#shared-tools-and-glibc",
|
||||
"tool_bad_output": "internals/images#building-tools",
|
||||
"tools_need_own_base": "using/from#shared-tools-and-glibc",
|
||||
"tools_wrong_base": "internals/images#building-tools",
|
||||
"custom_layer_remove": "using/images#taking-layers-out-of-a-vm",
|
||||
"agent_dir_comma": "using/coding-agents#mounts",
|
||||
"agent_dirs_added": "using/coding-agents#mounts",
|
||||
"agent_dirs_removed": "using/coding-agents#mounts",
|
||||
"no_claude_token": "using/coding-agents#claude-code-login",
|
||||
"claude_token_invalid": "using/coding-agents#claude-code-login",
|
||||
"no_github_token": "safety/network#saving-and-binding-secrets",
|
||||
"not_setup_token": "using/coding-agents#claude-code-login",
|
||||
"secret_unuse_copied": "safety/network#saving-and-binding-secrets",
|
||||
"keychain_save_failed": "safety/network#saving-and-binding-secrets",
|
||||
"login_copy_failed": "using/coding-agents#copies",
|
||||
"config_redacted": "using/coding-agents#copies",
|
||||
"config_not_copied": "using/coding-agents#copies",
|
||||
"claude_mcp_secrets_copied": "using/coding-agents#copies",
|
||||
"bad_from": "using/from#tags-and-digests",
|
||||
"from_unreachable": "using/from#tags-and-digests",
|
||||
"from_cached_unreachable": "using/from#tags-and-digests",
|
||||
"from_not_found": "using/from#images-only-docker-has",
|
||||
"from_cached_not_found": "using/from#images-only-docker-has",
|
||||
"docker_only": "using/from#images-only-docker-has",
|
||||
"docker_image_changed": "using/from#images-only-docker-has",
|
||||
"convert_failed": "using/from#supported-images",
|
||||
"convert_bad_output": "using/from#supported-images",
|
||||
"from_ignored": "using/from",
|
||||
"devcontainer_invalid": "using/devcontainer#when-its-read",
|
||||
"devcontainer_unreadable": "using/devcontainer#when-its-read",
|
||||
"devcontainer_changed": "using/devcontainer#when-its-read",
|
||||
"devcontainer_new": "using/devcontainer#when-its-read",
|
||||
"devcontainer_bad_value": "using/devcontainer#properties",
|
||||
"devcontainer_build": "using/devcontainer#properties",
|
||||
"devcontainer_feature": "using/devcontainer#properties",
|
||||
"devcontainer_docker_outside": "using/devcontainer#properties",
|
||||
"devcontainer_env_name": "using/devcontainer#properties",
|
||||
"devcontainer_image_not_public": "using/devcontainer#properties",
|
||||
"devcontainer_local_env": "using/devcontainer#variables",
|
||||
"devcontainer_variable": "using/devcontainer#variables",
|
||||
"devcontainer_command_failed": "using/devcontainer#commands",
|
||||
"no_devcontainer_flag_ignored": "using/devcontainer#when-its-read",
|
||||
"no_ssh_agent": "using/ssh#agent-forwarding",
|
||||
"ssh_agent_empty": "using/ssh#agent-forwarding",
|
||||
"load_key_with": "using/ssh#agent-forwarding",
|
||||
"no_vm_ssh_agent": "using/ssh#agent-forwarding",
|
||||
"agent_key_not_found": "using/ssh#devvms-own-agent",
|
||||
"agent_key_not_recorded": "using/ssh#devvms-own-agent",
|
||||
"agent_unload_failed": "using/ssh#devvms-own-agent",
|
||||
"agent_load_failed": "using/ssh#devvms-own-agent",
|
||||
"agent_start_failed": "using/ssh#devvms-own-agent",
|
||||
"mounts_next_start": "using/coding-agents#mounts",
|
||||
"no_feature": "using/customizing#choosing-features",
|
||||
"flag_blank": "getting-started/commands#flags-and-values",
|
||||
"no_input": "getting-started/commands#questions-devvm-asks",
|
||||
"no_input_terminal": "getting-started/commands#questions-devvm-asks",
|
||||
"force_needed": "getting-started/commands#questions-devvm-asks",
|
||||
"arg_blank": "getting-started/commands#flags-and-values",
|
||||
"no_image_named": "using/images#listing-images",
|
||||
"no_image_named_from": "using/images#listing-images",
|
||||
"not_an_image": "using/images#deleting-images",
|
||||
"no_vm": "getting-started/first-vm#making-the-vm",
|
||||
"no_vm_size": "using/ports-size#size",
|
||||
"no_vm_ports": "using/ports-size#ports",
|
||||
"no_vm_git_protect": "safety/git-protection#turning-it-on-or-off",
|
||||
"no_vm_policy": "safety/network#changing-rules",
|
||||
"no_token": "safety/network#saving-and-binding-secrets",
|
||||
"bad_secret_service": "using/settings#environment",
|
||||
"start_failed": "using/troubleshooting#a-command-fails",
|
||||
"stop_failed": "using/troubleshooting#a-command-fails",
|
||||
"delete_failed": "using/troubleshooting#a-command-fails",
|
||||
"vm_create_failed": "using/troubleshooting#a-command-fails",
|
||||
"sync_failed": "using/troubleshooting#a-command-fails",
|
||||
"link_setup_invalid": "using/troubleshooting#a-command-fails",
|
||||
"tools_unmounted": "using/troubleshooting#a-shared-tool-doesnt-mount",
|
||||
"devcontainer_ports_not_forwarded": "using/devcontainer#properties",
|
||||
"size_pending": "using/ports-size#size",
|
||||
"size_flags_ignored": "using/ports-size#size",
|
||||
"ports_flag_ignored": "using/ports-size#ports",
|
||||
"port_not_listed": "using/ports-size#ports",
|
||||
"no_vm_link": "using/links",
|
||||
"link_port_invalid": "using/links#ports",
|
||||
"link_ports_invalid": "using/links#publishing-a-port",
|
||||
"link_unknown_target": "using/links#adding-a-link",
|
||||
"link_ambiguous_target": "using/links#adding-a-link",
|
||||
"link_self": "using/links#adding-a-link",
|
||||
"link_not_published": "using/links#publishing-a-port",
|
||||
"link_policy_mismatch": "using/links#links-and-network-policy",
|
||||
"link_name_invalid": "using/links#names",
|
||||
"link_name_host": "using/links#names",
|
||||
"link_name_taken": "using/links#names",
|
||||
"link_target_named": "using/links#names",
|
||||
"link_trust": "using/links#a-link-joins-the-two-vms-trust",
|
||||
"link_not_found": "using/links#removing-a-link",
|
||||
"link_port_taken": "using/links#when-a-target-stops-or-goes",
|
||||
"link_target_stopped": "using/links#when-a-target-stops-or-goes",
|
||||
"link_target_unusable": "using/links#when-a-target-stops-or-goes",
|
||||
"link_target_unenforced": "using/links#links-and-network-policy",
|
||||
"links_update_failed": "using/links#when-links-change",
|
||||
"unpublished_linked": "using/links#publishing-a-port",
|
||||
"network_off_linked": "using/links#links-and-network-policy",
|
||||
"network_on_linked": "using/links#links-and-network-policy",
|
||||
"port_not_published": "using/links#publishing-a-port",
|
||||
"link_from_group": "using/links#leaving-a-group",
|
||||
"no_vm_group": "using/links#groups",
|
||||
"group_name_invalid": "using/links#joining-a-group",
|
||||
"group_none": "using/links#joining-a-group",
|
||||
"group_other": "using/links#leaving-a-group",
|
||||
"group_named": "using/links#names-in-a-group",
|
||||
"group_trust": "using/links#a-group-joins-the-trust-of-all-its-vms",
|
||||
"group_policy_on": "using/links#groups-and-network-policy",
|
||||
"group_policy_off": "using/links#groups-and-network-policy",
|
||||
"group_policy_mixed": "using/links#groups-and-network-policy",
|
||||
"group_name_taken": "using/links#names-in-a-group",
|
||||
"group_name_host": "using/links#names-in-a-group",
|
||||
"group_link_name_clash": "using/links#names-in-a-group",
|
||||
"group_name_hostname": "using/links#names-in-a-group",
|
||||
"agent_next_start": "using/ssh#agent-forwarding",
|
||||
"ssh_agent_flag_ignored": "using/ssh#agent-forwarding",
|
||||
"clone_seed_failed": "using/clone#whats-copied",
|
||||
"remote_add_failed": "using/clone#the-remote",
|
||||
"clone_check_failed": "using/clone#deleting-the-vm",
|
||||
"clone_check_not_started": "using/clone#deleting-the-vm",
|
||||
"clone_check_skipped": "using/clone#deleting-the-vm",
|
||||
"fetch_failed": "using/clone#deleting-the-vm",
|
||||
"mise_download_failed": "using/images#shared-tools",
|
||||
"tools_resolve_failed": "using/images#shared-tools",
|
||||
"tool_bad_version": "using/toolchains#adding-and-removing-tools",
|
||||
"vm_lacks": "using/toolchains#adding-and-removing-tools",
|
||||
"rule_missing": "safety/network#changing-rules",
|
||||
"policy_not_rule": "safety/network#rules",
|
||||
"policy_broken_deny": "safety/network#rules",
|
||||
"usage_error": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"arg_missing": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"args_too_many": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"args_none": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"arg_not_choice": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"no_subcommand": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_unknown": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_needs_value": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_bad_value": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_bad_switch": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flags_exclusive": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"no_command": "getting-started/commands#devvm-itself",
|
||||
"no_command_like": "getting-started/commands#devvm-itself",
|
||||
"no_command_part": "using/images#what-a-new-vm-gets",
|
||||
"unknown_part": "using/images#what-a-new-vm-gets",
|
||||
"unknown_part_like": "using/images#what-a-new-vm-gets",
|
||||
"part_none_alone": "using/images#what-a-new-vm-gets",
|
||||
"part_other_flag": "using/images#what-a-new-vm-gets",
|
||||
"tool_not_layer": "using/images#layers",
|
||||
"unknown_layer_like": "using/images#layers",
|
||||
"remake_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"remake_clone": "using/clone#switching-a-vm-that-exists",
|
||||
"remake_export_failed": "using/coding-agents#history",
|
||||
"remake_home_failed": "using/images#what-a-vm-made-again-keeps",
|
||||
"remake_restore_failed": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_undo_failed": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_pending": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_running": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_home_lost": "using/images#a-remake-that-stops-halfway",
|
||||
"rename_failed": "using/troubleshooting#a-command-fails",
|
||||
"parts_flags_ignored": "using/toolchains#adding-and-removing-tools",
|
||||
"backend_lacks": "backends#when-a-backend-lacks-something",
|
||||
"backend_unreviewed": "backends#when-a-backend-lacks-something",
|
||||
"backend_unreviewed_used": "contributing/testing#unreviewed-emulations",
|
||||
"backend_unknown_vm": "backends#a-vms-backend",
|
||||
"ports_forward_failed": "using/ports-size#ports",
|
||||
"net_off_backend": "backends#when-a-backend-lacks-something",
|
||||
"net_about": "safety/network#turning-it-on-or-off",
|
||||
"disk_low": "using/troubleshooting#not-enough-free-space",
|
||||
"disk_low_warning": "using/ports-size#free-space",
|
||||
"disk_free_unknown": "using/troubleshooting#not-enough-free-space",
|
||||
"lima_missing": "backends/lima#requirements",
|
||||
"lima_broken": "backends/lima#requirements",
|
||||
"lima_old": "backends/lima#requirements",
|
||||
"lima_host_unsupported": "backends/lima#requirements",
|
||||
"qemu_missing": "backends/lima#requirements",
|
||||
"lima_missing_fix": "backends/lima#requirements",
|
||||
"lima_broken_fix": "backends/lima#requirements",
|
||||
"lima_old_fix": "backends/lima#requirements",
|
||||
"qemu_missing_fix": "backends/lima#requirements",
|
||||
"lima_arch_unsupported": "backends/lima#requirements",
|
||||
"macos_old": "backends/lima#requirements",
|
||||
"no_kvm": "backends/lima#requirements",
|
||||
"kvm_access": "backends/lima#requirements",
|
||||
"lima_global_config": "backends/lima#devvms-lima-home",
|
||||
"vm_has_networks": "backends/lima#devvms-lima-home",
|
||||
"lima_home_too_long": "backends/lima#limits",
|
||||
"mount_comma": "backends/lima#limits",
|
||||
"disk_shrink": "backends/lima#limits",
|
||||
"image_in_use": "using/images#deleting-images",
|
||||
"image_building": "using/images#deleting-images",
|
||||
"qemu_refused": "internals/lima#confinement",
|
||||
"start_no_ssh": "using/troubleshooting#a-vm-wont-boot",
|
||||
"lima_log_unredacted": "using/troubleshooting#a-command-fails",
|
||||
"no_ubuntu_image": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"no_ubuntu_release": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"origin_no_boot": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"ubuntu_unreachable": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"ubuntu_bad_signature": "using/troubleshooting#a-download-doesnt-check-out",
|
||||
"ubuntu_newest_older": "using/troubleshooting#a-download-doesnt-check-out",
|
||||
"unknown_layer": "using/images#layers",
|
||||
"default_layer_gone": "using/settings#layers-for-new-vms",
|
||||
"default_layer_lacks": "using/settings#layers-for-new-vms",
|
||||
"layer_name_invalid": "using/customizing#your-own-layers",
|
||||
"layer_name_reserved": "using/customizing#your-own-layers",
|
||||
"layer_created": "using/customizing#your-own-layers",
|
||||
"base_features": "using/customizing#choosing-features",
|
||||
"base_features_none": "using/customizing#choosing-features",
|
||||
"unknown_feature": "using/customizing#choosing-features",
|
||||
"script_failed": "using/troubleshooting#a-build-fails",
|
||||
"build_sources_unreachable": "using/troubleshooting#no-package-source-answers",
|
||||
"packages_lists_missing": "using/troubleshooting#a-build-fails",
|
||||
"packages_missing": "using/troubleshooting#base-cant-build-on-lima",
|
||||
"packages_not_newest": "using/troubleshooting#a-build-fails",
|
||||
"packages_refused": "using/troubleshooting#a-build-fails",
|
||||
"packages_stale": "using/troubleshooting#base-gets-old-package-lists",
|
||||
"packages_stale_mirror": "using/settings#an-ubuntu-mirror",
|
||||
"rebuild_replaces": "using/images#rebuilding",
|
||||
"layer_exists": "using/customizing#your-own-layers",
|
||||
"images_stale_note": "using/images#cleaning-up",
|
||||
"images_unused": "using/images#cleaning-up",
|
||||
"folders_not_private": "using/space#devvms-data-folder",
|
||||
"layout_newer": "using/troubleshooting#a-newer-devvm-changed-devvms-folders",
|
||||
"layout_unchecked": "using/troubleshooting#a-file-devvm-cant-read",
|
||||
"vm_state_unreadable": "using/troubleshooting#a-file-devvm-cant-read",
|
||||
"vms_stray": "using/space#what-devvm-doctor-finds-in-vms",
|
||||
"vm_folder_stateless": "using/space#what-devvm-doctor-finds-in-vms",
|
||||
"vms_unreadable": "using/space#what-devvm-doctor-finds-in-vms",
|
||||
"retention_busy": "using/settings#retention",
|
||||
"retention_unreadable": "using/settings#retention",
|
||||
"retention_failed": "using/settings#retention",
|
||||
"retention_bad": "using/settings#retention",
|
||||
"set_in_config": "using/settings#configtoml",
|
||||
"gc_backend_skipped": "using/images#cleaning-up",
|
||||
"gc_orphans_unknown": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"gc_orphan_elsewhere": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"gc_orphan_recent": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"gc_older_than_needs_history": "using/images#cleaning-up",
|
||||
"bad_duration": "getting-started/commands#flags-and-values",
|
||||
"gc_names_need_tools": "using/images#cleaning-up",
|
||||
"gc_tools_making": "using/images#cleaning-up",
|
||||
"unknown_tool": "using/toolchains#adding-and-removing-tools",
|
||||
"images_total": "using/space#devvm-space",
|
||||
"space_backend_unknown": "using/space#devvm-space",
|
||||
"space_stray": "using/space#vms-devvm-has-no-state-for",
|
||||
"space_caches_note": "using/space#limas-caches",
|
||||
"tool_not_locked": "using/images#shared-tools",
|
||||
"vm_outdated": "using/images#outdated-vms",
|
||||
"bad_path": "backends/lima#limits",
|
||||
"vm_name_no_room": "backends/lima#limits",
|
||||
"vm_other_folder": "getting-started/commands#a-folder-made-again",
|
||||
"vm_other_folder_rm": "getting-started/commands#a-folder-made-again",
|
||||
"vm_other_folder_adopt": "getting-started/commands#a-folder-made-again",
|
||||
"rm_unknown_vm": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_vm_folder_there": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_vm_lost": "using/space#leftovers-of-a-vm-deleted-outside-devvm",
|
||||
"vm_moved_here": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"vms_moved_here": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_move_refused": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"move_folder_changed": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_folder_there": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_has_vm": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"adopt_clone": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"folder_next_start": "getting-started/commands#a-moved-or-renamed-folder",
|
||||
"rm_gone_stopped": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_gone_clone": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"rm_vm_export_failed": "using/coding-agents#history",
|
||||
"space_folder_gone": "getting-started/commands#a-vm-whose-folder-is-gone",
|
||||
"space_folder_not_connected": "getting-started/commands#a-folder-on-a-disk-that-isnt-connected",
|
||||
"rm_vm_not_connected": "getting-started/commands#a-folder-on-a-disk-that-isnt-connected",
|
||||
"vm_unfinished": "using/troubleshooting#a-vm-whose-creation-didnt-finish",
|
||||
"create_running": "using/troubleshooting#a-vm-whose-creation-didnt-finish",
|
||||
"no_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"using_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"rm_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"widen_parent_vm_refused": "getting-started/commands#a-subfolder",
|
||||
"tools_joined": "using/toolchains#adding-and-removing-tools",
|
||||
"size_next_start": "using/ports-size#size",
|
||||
"rm_export_failed": "using/coding-agents#history",
|
||||
"history_not_exported": "using/coding-agents#history",
|
||||
"history_not_imported": "using/coding-agents#importing-history",
|
||||
"history_import_unsafe": "using/coding-agents#importing-history",
|
||||
"history_no_export": "using/coding-agents#importing-history",
|
||||
"history_import_later": "using/coding-agents#importing-history",
|
||||
"git_replaced": "safety/git-protection#not-covered",
|
||||
"git_appeared": "safety/git-protection#when-devvm-reports-git",
|
||||
"git_embedded_new": "safety/git-protection#strict",
|
||||
"git_hooks_unlocked": "safety/git-protection#when-devvm-reports-git",
|
||||
"unsafe_folder": "using/settings#project-folders-devvm-refuses",
|
||||
"unsafe_folder_inside": "using/settings#project-folders-devvm-refuses",
|
||||
"unsafe_folder_used": "using/settings#project-folders-devvm-refuses",
|
||||
"cpus_not_number": "using/ports-size#size-and-ports",
|
||||
"size_not_gib": "using/ports-size#size-and-ports",
|
||||
"too_many_cpus": "using/ports-size#size-and-ports",
|
||||
"too_much_memory": "using/ports-size#size-and-ports",
|
||||
"port_invalid": "using/ports-size#size-and-ports",
|
||||
"devvm_other_first": "getting-started/install#one-devvm",
|
||||
"host_memory_low": "getting-started/install#requirements",
|
||||
"host_cpus_few": "getting-started/install#requirements",
|
||||
"base_fitted": "using/ports-size#size-and-ports",
|
||||
"ports_list_needed": "using/ports-size#ports",
|
||||
"ports_rm_all": "using/ports-size#ports",
|
||||
"ports_taken": "using/troubleshooting#a-listed-port-isnt-forwarded",
|
||||
"ca_not_certificate": "using/settings#a-companys-ca",
|
||||
"ca_not_ca": "using/settings#a-companys-ca",
|
||||
"ca_invalid": "using/settings#a-companys-ca",
|
||||
"ca_link": "using/settings#a-companys-ca",
|
||||
"ca_folder_link": "using/settings#a-companys-ca",
|
||||
"ca_unreadable": "using/settings#a-companys-ca",
|
||||
"ca_folder_unreadable": "using/settings#a-companys-ca",
|
||||
"doctor_proxy_ca": "using/troubleshooting#tls-errors-behind-a-company-proxy",
|
||||
"net_direct_route": "safety/network#when-it-isnt-enforced",
|
||||
"net_unenforced_stop": "using/troubleshooting#a-vm-shows-as-unenforced",
|
||||
"net_unenforced": "using/troubleshooting#a-vm-shows-as-unenforced",
|
||||
"net_off_log": "safety/network#turning-it-on-or-off",
|
||||
"net_off_policy": "safety/network#turning-it-on-or-off",
|
||||
"net_ask_global": "safety/network#turning-it-on-or-off",
|
||||
"json_shows_only": "getting-started/commands#output-for-scripts",
|
||||
"net_flag_ignored": "safety/network#turning-it-on-or-off",
|
||||
"net_on_old_tokens": "safety/network#turning-it-on-or-off",
|
||||
"net_off_next_start": "safety/network#turning-it-on-or-off",
|
||||
"not_a_rule": "safety/network#rules",
|
||||
"proxy_start_failed": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"proxy_port_taken": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"proxy_stop_failed": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"upstream_proxy_scheme": "safety/network#behind-a-company-proxy",
|
||||
"upstream_proxy_invalid": "safety/network#behind-a-company-proxy",
|
||||
"ubuntu_mirror_invalid": "using/settings#an-ubuntu-mirror",
|
||||
"proxy_password_in_config": "safety/network#behind-a-company-proxy",
|
||||
"proxy_password_missing": "safety/network#behind-a-company-proxy",
|
||||
"secret_host_only": "safety/network#behind-a-company-proxy",
|
||||
"upstream_proxy_gone": "using/troubleshooting#behind-a-company-proxy",
|
||||
"proxy_needs_policy": "safety/network#without-network-policy",
|
||||
"net_proxy_down_stopped": "using/troubleshooting#the-proxy-doesnt-start",
|
||||
"no_secret": "safety/network#saving-and-binding-secrets",
|
||||
"codex_login_kept": "using/coding-agents#codex-and-opencode-logins",
|
||||
"opencode_login_kept": "using/coding-agents#codex-and-opencode-logins",
|
||||
"opencode_login_withheld": "using/coding-agents#codex-and-opencode-logins",
|
||||
"codex_no_key": "using/coding-agents#codex-and-opencode-logins",
|
||||
"codex_no_chatgpt": "using/coding-agents#codex-and-opencode-logins",
|
||||
"codex_refresh_failed": "using/coding-agents#codex-and-opencode-logins",
|
||||
"opencode_refresh_failed": "using/coding-agents#codex-and-opencode-logins",
|
||||
"login_read_failed": "using/coding-agents#codex-and-opencode-logins",
|
||||
"setid_files": "using/troubleshooting#devvm-names-set-id-files",
|
||||
"setid_root_files": "using/troubleshooting#devvm-names-set-id-files",
|
||||
"home_not_absolute": "using/troubleshooting#home-isnt-an-absolute-path",
|
||||
"net_unenforced_restart": "using/troubleshooting#a-vm-shows-as-unenforced",
|
||||
"adopt_failed": "getting-started/commands#a-folder-made-again",
|
||||
"clone_needs_git": "using/clone#requirements",
|
||||
"uncommitted_not_copied": "using/clone#whats-copied",
|
||||
"unfetched_commits": "using/clone#deleting-the-vm",
|
||||
"branch_names_invalid": "using/clone#deleting-the-vm",
|
||||
"git_protect_clone": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_protect_failed": "safety/git-protection#turning-it-on-or-off",
|
||||
"devcontainer_using": "using/devcontainer",
|
||||
"devcontainer_flag_wins": "using/devcontainer#when-its-read",
|
||||
"devcontainer_ignored": "using/devcontainer#properties",
|
||||
"devcontainer_unknown": "using/devcontainer#properties",
|
||||
"devcontainer_initialize": "using/devcontainer#properties",
|
||||
"devcontainer_feature_options": "using/devcontainer#properties",
|
||||
"devcontainer_ports_ignored": "using/devcontainer#properties",
|
||||
"git_protect_needs_macos_new": "safety/git-protection#linux-hosts",
|
||||
"git_protect_on_needs_macos": "safety/git-protection#linux-hosts",
|
||||
"git_protect_next_stop": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_unlocked": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_protect_flag_ignored": "safety/git-protection#turning-it-on-or-off",
|
||||
"git_locked_strict": "safety/git-protection#strict",
|
||||
"git_config_failed": "safety/git-protection#strict",
|
||||
"git_commondir": "safety/git-protection#not-covered",
|
||||
"git_worktree_stray": "safety/git-protection#not-covered",
|
||||
"git_not_locked": "safety/git-protection#when-devvm-reports-git",
|
||||
"git_lock_raced": "safety/git-protection#when-devvm-reports-git",
|
||||
"git_hooks_path": "safety/git-protection#not-covered",
|
||||
"git_include_inside": "safety/git-protection#not-covered",
|
||||
"git_hook_link_inside": "safety/git-protection#not-covered",
|
||||
"git_gitdir_outside": "safety/git-protection#not-covered",
|
||||
"ssh_remote_hint": "using/ssh#agent-forwarding",
|
||||
"agent_on_risk": "using/ssh#agent-forwarding",
|
||||
"agent_devvm_risk": "using/ssh#devvms-own-agent",
|
||||
"agent_no_keys": "using/ssh#devvms-own-agent",
|
||||
"agent_key_changed": "using/ssh#devvms-own-agent",
|
||||
"agent_key_unpinned": "using/ssh#devvms-own-agent",
|
||||
"agent_key_no_fingerprint": "using/ssh#devvms-own-agent",
|
||||
"agent_key_mounted": "using/ssh#devvms-own-agent",
|
||||
"agent_confirm_needs_askpass": "using/ssh#devvms-own-agent",
|
||||
"ssh_include_yourself": "using/ssh#ssh-access-by-name",
|
||||
"no_code_command": "using/ssh#devvm-host-and-devvm-code",
|
||||
"desktop_no_layer": "using/desktop#adding-the-desktop",
|
||||
"desktop_start_failed": "using/desktop#when-the-desktop-doesnt-open",
|
||||
"desktop_open_failed": "using/desktop#when-the-desktop-doesnt-open",
|
||||
"clone_not_top": "using/clone#requirements",
|
||||
"clone_no_commits": "using/clone#requirements",
|
||||
"clone_detached": "using/clone#requirements",
|
||||
"clone_needs_new_vm": "using/clone#switching-a-vm-that-exists",
|
||||
"clone_show_failed": "using/clone#switching-a-vm-that-exists",
|
||||
"clone_git_elsewhere": "using/clone#requirements",
|
||||
"clone_alternates": "using/clone#requirements",
|
||||
"remotes_taken": "using/clone#the-remote",
|
||||
"fetch_until": "using/clone#the-remote",
|
||||
"no_terminal_fetch": "using/clone#deleting-the-vm",
|
||||
"saved_names_taken": "using/clone#deleting-the-vm",
|
||||
"remote_kept": "using/clone#deleting-the-vm",
|
||||
"no_terminal_delete": "using/clone#deleting-the-vm",
|
||||
"clone_worktrees_unchecked": "using/clone#deleting-the-vm",
|
||||
"tools_need_resolve": "using/images#shared-tools",
|
||||
"mise_checksum": "using/troubleshooting#a-download-doesnt-check-out",
|
||||
"tool_stepped_back": "using/troubleshooting#a-new-tool-release-isnt-there-yet",
|
||||
"tool_no_download": "using/troubleshooting#a-new-tool-release-isnt-there-yet",
|
||||
"tools_check_failed": "using/images#shared-tools",
|
||||
"newer_tools": "using/toolchains#adding-and-removing-tools",
|
||||
"tool_unbuilt": "using/troubleshooting#a-new-tool-release-isnt-there-yet",
|
||||
"tool_needs_glibc": "using/from#shared-tools-and-glibc",
|
||||
"tool_bad_output": "internals/images#building-tools",
|
||||
"tools_need_own_base": "using/from#shared-tools-and-glibc",
|
||||
"tools_wrong_base": "internals/images#building-tools",
|
||||
"custom_layer_remove": "using/images#taking-layers-out-of-a-vm",
|
||||
"agent_dir_comma": "using/coding-agents#mounts",
|
||||
"agent_dirs_added": "using/coding-agents#mounts",
|
||||
"agent_dirs_removed": "using/coding-agents#mounts",
|
||||
"no_claude_token": "using/coding-agents#claude-code-login",
|
||||
"claude_token_invalid": "using/coding-agents#claude-code-login",
|
||||
"no_github_token": "safety/network#saving-and-binding-secrets",
|
||||
"not_setup_token": "using/coding-agents#claude-code-login",
|
||||
"secret_unuse_copied": "safety/network#saving-and-binding-secrets",
|
||||
"keychain_save_failed": "safety/network#saving-and-binding-secrets",
|
||||
"login_copy_failed": "using/coding-agents#copies",
|
||||
"config_redacted": "using/coding-agents#copies",
|
||||
"config_not_copied": "using/coding-agents#copies",
|
||||
"claude_mcp_secrets_copied": "using/coding-agents#copies",
|
||||
"bad_from": "using/from#tags-and-digests",
|
||||
"from_unreachable": "using/from#tags-and-digests",
|
||||
"from_cached_unreachable": "using/from#tags-and-digests",
|
||||
"from_not_found": "using/from#images-only-docker-has",
|
||||
"from_cached_not_found": "using/from#images-only-docker-has",
|
||||
"docker_only": "using/from#images-only-docker-has",
|
||||
"docker_image_changed": "using/from#images-only-docker-has",
|
||||
"convert_failed": "using/from#supported-images",
|
||||
"convert_bad_output": "using/from#supported-images",
|
||||
"from_ignored": "using/from",
|
||||
"devcontainer_invalid": "using/devcontainer#when-its-read",
|
||||
"devcontainer_unreadable": "using/devcontainer#when-its-read",
|
||||
"devcontainer_changed": "using/devcontainer#updating-a-vm-from-the-file",
|
||||
"devcontainer_new": "using/devcontainer#updating-a-vm-from-the-file",
|
||||
"devcontainer_bad_value": "using/devcontainer#properties",
|
||||
"devcontainer_build": "using/devcontainer#properties",
|
||||
"devcontainer_feature": "using/devcontainer#properties",
|
||||
"devcontainer_docker_outside": "using/devcontainer#properties",
|
||||
"devcontainer_env_name": "using/devcontainer#properties",
|
||||
"devcontainer_image_not_public": "using/devcontainer#properties",
|
||||
"devcontainer_local_env": "using/devcontainer#variables",
|
||||
"devcontainer_variable": "using/devcontainer#variables",
|
||||
"devcontainer_command_failed": "using/devcontainer#commands",
|
||||
"no_devcontainer_flag_ignored": "using/devcontainer#when-its-read",
|
||||
"no_ssh_agent": "using/ssh#agent-forwarding",
|
||||
"ssh_agent_empty": "using/ssh#agent-forwarding",
|
||||
"load_key_with": "using/ssh#agent-forwarding",
|
||||
"no_vm_ssh_agent": "using/ssh#agent-forwarding",
|
||||
"agent_key_not_found": "using/ssh#devvms-own-agent",
|
||||
"agent_key_not_recorded": "using/ssh#devvms-own-agent",
|
||||
"agent_unload_failed": "using/ssh#devvms-own-agent",
|
||||
"agent_load_failed": "using/ssh#devvms-own-agent",
|
||||
"agent_start_failed": "using/ssh#devvms-own-agent",
|
||||
"mounts_next_start": "using/coding-agents#mounts",
|
||||
"no_feature": "using/customizing#choosing-features",
|
||||
"flag_blank": "getting-started/commands#flags-and-values",
|
||||
"no_input": "getting-started/commands#questions-devvm-asks",
|
||||
"no_input_terminal": "getting-started/commands#questions-devvm-asks",
|
||||
"force_needed": "getting-started/commands#questions-devvm-asks",
|
||||
"arg_blank": "getting-started/commands#flags-and-values",
|
||||
"no_image_named": "using/images#listing-images",
|
||||
"no_image_named_from": "using/images#listing-images",
|
||||
"not_an_image": "using/images#deleting-images",
|
||||
"no_vm": "getting-started/first-vm#making-the-vm",
|
||||
"no_vm_size": "using/ports-size#size",
|
||||
"no_vm_ports": "using/ports-size#ports",
|
||||
"no_vm_git_protect": "safety/git-protection#turning-it-on-or-off",
|
||||
"no_vm_policy": "safety/network#changing-rules",
|
||||
"no_token": "safety/network#saving-and-binding-secrets",
|
||||
"bad_secret_service": "using/settings#environment",
|
||||
"start_failed": "using/troubleshooting#a-command-fails",
|
||||
"stop_failed": "using/troubleshooting#a-command-fails",
|
||||
"delete_failed": "using/troubleshooting#a-command-fails",
|
||||
"vm_create_failed": "using/troubleshooting#a-command-fails",
|
||||
"sync_failed": "using/troubleshooting#a-command-fails",
|
||||
"link_setup_invalid": "using/troubleshooting#a-command-fails",
|
||||
"tools_unmounted": "using/troubleshooting#a-shared-tool-doesnt-mount",
|
||||
"size_pending": "using/ports-size#size",
|
||||
"size_flags_ignored": "using/ports-size#size",
|
||||
"ports_flag_ignored": "using/ports-size#ports",
|
||||
"port_not_listed": "using/ports-size#ports",
|
||||
"no_vm_link": "using/links",
|
||||
"link_port_invalid": "using/links#ports",
|
||||
"link_ports_invalid": "using/links#publishing-a-port",
|
||||
"link_unknown_target": "using/links#adding-a-link",
|
||||
"link_ambiguous_target": "using/links#adding-a-link",
|
||||
"link_self": "using/links#adding-a-link",
|
||||
"link_not_published": "using/links#publishing-a-port",
|
||||
"link_policy_mismatch": "using/links#links-and-network-policy",
|
||||
"link_name_invalid": "using/links#names",
|
||||
"link_name_host": "using/links#names",
|
||||
"link_name_taken": "using/links#names",
|
||||
"link_target_named": "using/links#names",
|
||||
"link_trust": "using/links#a-link-joins-the-two-vms-trust",
|
||||
"link_not_found": "using/links#removing-a-link",
|
||||
"link_port_taken": "using/links#when-a-target-stops-or-goes",
|
||||
"link_target_stopped": "using/links#when-a-target-stops-or-goes",
|
||||
"link_target_unusable": "using/links#when-a-target-stops-or-goes",
|
||||
"link_target_unenforced": "using/links#links-and-network-policy",
|
||||
"links_update_failed": "using/links#when-links-change",
|
||||
"unpublished_linked": "using/links#publishing-a-port",
|
||||
"network_off_linked": "using/links#links-and-network-policy",
|
||||
"network_on_linked": "using/links#links-and-network-policy",
|
||||
"port_not_published": "using/links#publishing-a-port",
|
||||
"link_from_group": "using/links#leaving-a-group",
|
||||
"no_vm_group": "using/links#groups",
|
||||
"group_name_invalid": "using/links#joining-a-group",
|
||||
"group_none": "using/links#joining-a-group",
|
||||
"group_other": "using/links#leaving-a-group",
|
||||
"group_named": "using/links#names-in-a-group",
|
||||
"group_trust": "using/links#a-group-joins-the-trust-of-all-its-vms",
|
||||
"group_policy_on": "using/links#groups-and-network-policy",
|
||||
"group_policy_off": "using/links#groups-and-network-policy",
|
||||
"group_policy_mixed": "using/links#groups-and-network-policy",
|
||||
"group_name_taken": "using/links#names-in-a-group",
|
||||
"group_name_host": "using/links#names-in-a-group",
|
||||
"group_link_name_clash": "using/links#names-in-a-group",
|
||||
"group_name_hostname": "using/links#names-in-a-group",
|
||||
"agent_next_start": "using/ssh#agent-forwarding",
|
||||
"ssh_agent_flag_ignored": "using/ssh#agent-forwarding",
|
||||
"clone_seed_failed": "using/clone#whats-copied",
|
||||
"remote_add_failed": "using/clone#the-remote",
|
||||
"clone_check_failed": "using/clone#deleting-the-vm",
|
||||
"clone_check_not_started": "using/clone#deleting-the-vm",
|
||||
"clone_check_skipped": "using/clone#deleting-the-vm",
|
||||
"fetch_failed": "using/clone#deleting-the-vm",
|
||||
"mise_download_failed": "using/images#shared-tools",
|
||||
"tools_resolve_failed": "using/images#shared-tools",
|
||||
"tool_bad_version": "using/toolchains#adding-and-removing-tools",
|
||||
"vm_lacks": "using/toolchains#adding-and-removing-tools",
|
||||
"rule_missing": "safety/network#changing-rules",
|
||||
"policy_not_rule": "safety/network#rules",
|
||||
"policy_broken_deny": "safety/network#rules",
|
||||
"usage_error": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"arg_missing": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"args_too_many": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"args_none": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"arg_not_choice": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"no_subcommand": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_unknown": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_needs_value": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_bad_value": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flag_bad_switch": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"flags_exclusive": "using/troubleshooting#a-command-is-refused-before-it-runs",
|
||||
"no_command": "getting-started/commands#devvm-itself",
|
||||
"no_command_like": "getting-started/commands#devvm-itself",
|
||||
"no_command_part": "using/images#what-a-new-vm-gets",
|
||||
"unknown_part": "using/images#what-a-new-vm-gets",
|
||||
"unknown_part_like": "using/images#what-a-new-vm-gets",
|
||||
"part_none_alone": "using/images#what-a-new-vm-gets",
|
||||
"part_other_flag": "using/images#what-a-new-vm-gets",
|
||||
"tool_not_layer": "using/images#layers",
|
||||
"unknown_layer_like": "using/images#layers",
|
||||
"remake_parent_vm": "getting-started/commands#a-subfolder",
|
||||
"remake_clone": "using/clone#switching-a-vm-that-exists",
|
||||
"remake_export_failed": "using/coding-agents#history",
|
||||
"remake_home_failed": "using/images#what-a-vm-made-again-keeps",
|
||||
"remake_restore_failed": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_undo_failed": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_pending": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_running": "using/images#a-remake-that-stops-halfway",
|
||||
"remake_home_lost": "using/images#a-remake-that-stops-halfway",
|
||||
"rename_failed": "using/troubleshooting#a-command-fails",
|
||||
"parts_flags_ignored": "using/toolchains#adding-and-removing-tools",
|
||||
}
|
||||
|
||||
// IssuesURL is devvm's issue tracker, which the root's help ends with.
|
||||
|
||||
+711
-705
File diff suppressed because it is too large.
Load diff
+181
-24
@@ -7,15 +7,20 @@ import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/w3cj/devvm/internal/backend"
|
||||
"github.com/w3cj/devvm/internal/devcontainer"
|
||||
"github.com/w3cj/devvm/internal/from"
|
||||
"github.com/w3cj/devvm/internal/image"
|
||||
"github.com/w3cj/devvm/internal/msg"
|
||||
"github.com/w3cj/devvm/internal/platform"
|
||||
"github.com/w3cj/devvm/internal/ports"
|
||||
"github.com/w3cj/devvm/internal/settings"
|
||||
"github.com/w3cj/devvm/internal/shell"
|
||||
"github.com/w3cj/devvm/internal/state"
|
||||
"github.com/w3cj/devvm/internal/tools"
|
||||
)
|
||||
|
||||
// devcontainerUnreadable is the sum of a file that can't be read now.
|
||||
@@ -80,53 +85,106 @@ func (e devcontainers) prepare(ctx context.Context, o Options, vm, dir string) (
|
||||
case o.FromSet:
|
||||
e.Warn(msg.DevcontainerFlagWins(file, "from", "image"))
|
||||
default:
|
||||
if err := from.Check(p.Image); err != nil {
|
||||
if fromRef, err = e.pin(ctx, file, p.Image); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
pinned, err := e.PublicImage(ctx, p.Image)
|
||||
if errors.Is(err, from.ErrNotFound) {
|
||||
return "", nil, msg.DevcontainerImageNotPublic(file, p.Image).Because(err)
|
||||
} else if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
fromRef = pinned
|
||||
}
|
||||
if p.Ports != "" && o.Ports != "" {
|
||||
// newPorts leaves the file's out, and they're recorded as the
|
||||
// file's, so devvm update adds only those it lists anew.
|
||||
e.Warn(msg.DevcontainerFlagWins(file, "ports", "forwardPorts"))
|
||||
p.Ports = ""
|
||||
}
|
||||
return fromRef, &p, nil
|
||||
}
|
||||
|
||||
// pin pins ref, the image file names, to the digest its registry gives
|
||||
// anyone, refusing one it doesn't.
|
||||
func (e devcontainers) pin(ctx context.Context, file, ref string) (string, error) {
|
||||
if err := from.Check(ref); err != nil {
|
||||
return "", err
|
||||
}
|
||||
pinned, err := e.PublicImage(ctx, ref)
|
||||
if errors.Is(err, from.ErrNotFound) {
|
||||
return "", msg.DevcontainerImageNotPublic(file, ref).Because(err)
|
||||
}
|
||||
return pinned, err
|
||||
}
|
||||
|
||||
// record sets what a new VM is made from in its state, before it's
|
||||
// written: the file (dc, its plan) and what it maps to of the VM's own
|
||||
// (its variables, its commands), or none, off with --no-devcontainer.
|
||||
func (e devcontainers) record(st *state.VM, off bool, dc *devcontainer.Plan) error {
|
||||
d := devcontainerInVM{Off: off}
|
||||
if p := dc; p != nil && !off {
|
||||
// written: the file (dc, its plan), what it maps to of the VM's own (its
|
||||
// variables, its commands), and what of the VM is the file's (gave: its
|
||||
// parts it got from the file alone; portsGave: the ports the file added;
|
||||
// its base's image) and what the user's (--from), or none, off with
|
||||
// --no-devcontainer.
|
||||
func (e devcontainers) record(st *state.VM, o Options, dc *devcontainer.Plan, gave, portsGave []string) error {
|
||||
d := devcontainerInVM{Off: o.NoDevcontainer}
|
||||
if !o.NoDevcontainer {
|
||||
d.FromFlag = o.FromSet
|
||||
}
|
||||
if p := dc; p != nil && !o.NoDevcontainer {
|
||||
d.File, d.Sum, d.Env, d.Create, d.Start = p.File, p.Sum, p.Env, p.Create, p.Start
|
||||
d.Parts, d.Gave = p.Layers, gave
|
||||
d.Ports, d.PortsGave = portList(p.Ports), portsGave
|
||||
if !o.FromSet {
|
||||
d.Image = p.Image
|
||||
}
|
||||
}
|
||||
return state.SetSection(st, devcontainerSection, d)
|
||||
}
|
||||
|
||||
// check warns, once a launch, when the folder's devcontainer.json isn't
|
||||
// the one the VM was made from (changed, gone, or new): nothing in it
|
||||
// changes an existing VM.
|
||||
func (e devcontainers) check(st *state.VM, dir string) {
|
||||
was := sectionOf[devcontainerInVM](st, devcontainerSection)
|
||||
if was.Off {
|
||||
return
|
||||
// fileParts is what a new VM made for the folder dir gets from its
|
||||
// devcontainer.json (dc) alone of got, its parts: the toolchains and
|
||||
// layers the file's features map to, unless the user's --tools or
|
||||
// --layers chose that part's list, devvm setup's layers (def's) have
|
||||
// it, or the folder's other files call for it.
|
||||
func fileParts(o Options, dir string, dc *devcontainer.Plan, def settings.Defaults, got Parts) []string {
|
||||
if dc == nil {
|
||||
return nil
|
||||
}
|
||||
file, data, err := e.find(dir)
|
||||
sum := ""
|
||||
var others []string
|
||||
for _, f := range detectFiles(dir) {
|
||||
others = append(others, f.Name)
|
||||
}
|
||||
var gave []string
|
||||
for _, p := range dc.Layers {
|
||||
tool := image.IsTool(p)
|
||||
switch {
|
||||
case tool && (o.Toolchains != nil || !slices.Contains(got.Toolchains, p) || slices.Contains(others, p)):
|
||||
case !tool && (o.Layers != nil || !slices.Contains(got.Layers, p) || slices.Contains(def.Layers.Names, p)):
|
||||
default:
|
||||
gave = append(gave, p)
|
||||
}
|
||||
}
|
||||
return gave
|
||||
}
|
||||
|
||||
// now is the folder's devcontainer.json as it is now, for a VM made
|
||||
// from was: its path ("" for none), its contents and its SHA-256
|
||||
// (devcontainerUnreadable for one that can't be read), and whether it's
|
||||
// the one the VM was made from.
|
||||
func (e devcontainers) now(was devcontainerInVM, dir string) (file string, data []byte, sum string, same bool, err error) {
|
||||
file, data, err = e.find(dir)
|
||||
switch {
|
||||
case err != nil:
|
||||
sum = devcontainerUnreadable
|
||||
case file != "":
|
||||
sum = devcontainer.Sum(data)
|
||||
}
|
||||
return file, data, sum, file == was.File && sum == was.Sum, err
|
||||
}
|
||||
|
||||
// check warns, once a launch, when the folder's devcontainer.json isn't
|
||||
// the one the VM was made from (changed, gone, or new): nothing in it
|
||||
// changes an existing VM until devvm update makes it again from the
|
||||
// file (reread).
|
||||
func (e devcontainers) check(st *state.VM, dir string) {
|
||||
was := sectionOf[devcontainerInVM](st, devcontainerSection)
|
||||
if was.Off {
|
||||
return
|
||||
}
|
||||
file, _, _, same, _ := e.now(was, dir)
|
||||
switch {
|
||||
case file == was.File && sum == was.Sum:
|
||||
case same:
|
||||
case was.File == "":
|
||||
e.Warn(msg.DevcontainerNew(file, st.Name()))
|
||||
default:
|
||||
@@ -134,6 +192,105 @@ func (e devcontainers) check(st *state.VM, dir string) {
|
||||
}
|
||||
}
|
||||
|
||||
// reread reads the folder's devcontainer.json again for devvm update,
|
||||
// when it isn't the one t's VM was made from (changed, gone, or new), and
|
||||
// returns what the VM is made again with: its image's name and what
|
||||
// rereadInVM holds (its tools' files are found once that image is
|
||||
// built). What the file gave the VM is replaced by what it says now
|
||||
// (devcontainer.Reread for its parts, filePorts for its ports), and what
|
||||
// the user chose is kept: --from over its image, and the VM's own ports.
|
||||
// A file whose image is gone leaves the VM's base starting
|
||||
// from defaultFrom ($DEVVM_FROM's). nil when the file is the one the VM
|
||||
// was made from, or the VM was made with --no-devcontainer; an
|
||||
// unreadable file, or one Parse refuses, fails.
|
||||
func (e devcontainers) reread(ctx context.Context, t *target, defaultFrom string) (string, *rereadInVM, error) {
|
||||
st, vm := t.st, t.f.Name
|
||||
was := sectionOf[devcontainerInVM](st, devcontainerSection)
|
||||
if was.Off {
|
||||
return "", nil, nil
|
||||
}
|
||||
file, data, _, same, err := e.now(was, t.f.Dir)
|
||||
switch {
|
||||
case err != nil:
|
||||
return "", nil, msg.DevcontainerUnreadable(file).Because(err)
|
||||
case same:
|
||||
return "", nil, nil
|
||||
}
|
||||
var p devcontainer.Plan
|
||||
if file == "" {
|
||||
e.Info(msg.DevcontainerGone(was.File, vm))
|
||||
} else {
|
||||
if p, err = devcontainer.Parse(file, data, t.f.Dir); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
e.Info(msg.DevcontainerReread(file, vm))
|
||||
for _, m := range p.Notes {
|
||||
e.Warn(m)
|
||||
}
|
||||
}
|
||||
r := &rereadInVM{From: st.From}
|
||||
d := devcontainerInVM{File: p.File, Sum: p.Sum, Env: p.Env, Create: p.Create, Start: p.Start, FromFlag: was.FromFlag, Image: was.Image, Parts: p.Layers}
|
||||
switch {
|
||||
case was.FromFlag:
|
||||
if p.Image != "" {
|
||||
e.Warn(msg.DevcontainerFlagWins(file, "from", "image"))
|
||||
}
|
||||
case p.Image == was.Image:
|
||||
case p.Image == "":
|
||||
r.From, d.Image = defaultFrom, ""
|
||||
default:
|
||||
if r.From, err = e.pin(ctx, file, p.Image); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
d.Image = p.Image
|
||||
}
|
||||
cur := sectionOf[ports.Ports](st, ports.Section).Forward
|
||||
if r.Forward, d.PortsGave, err = filePorts(cur, was.Ports, was.PortsGave, p.Ports); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
d.Ports = portList(p.Ports)
|
||||
img, names, gave := rereadParts(st, was, p.Layers)
|
||||
d.Gave = gave
|
||||
r.Tools.Names, r.Devcontainer = names, d
|
||||
return img, r, nil
|
||||
}
|
||||
|
||||
// portList is a Plan's ports list (3000,5173) as its ports, each on its
|
||||
// own; none for "".
|
||||
func portList(list string) []string {
|
||||
if list == "" {
|
||||
return nil
|
||||
}
|
||||
return strings.Split(list, ",")
|
||||
}
|
||||
|
||||
// rereadParts is st's VM's image and shared tools once what was, its
|
||||
// devcontainer section, gave it of now, what the file's features map to
|
||||
// now, is replaced (devcontainer.Reread), and what the VM then has from
|
||||
// the file alone.
|
||||
func rereadParts(st *state.VM, was devcontainerInVM, now []string) (string, []string, []string) {
|
||||
img, names := image.Name(st.Image), slices.Clone(tools.Names(st))
|
||||
add, drop, gave := devcontainer.Reread(was.Parts, was.Gave, slices.Concat(img.Layers(), names), now)
|
||||
var addLayers, dropLayers []string
|
||||
for _, p := range add {
|
||||
if image.IsTool(p) {
|
||||
names = append(names, p)
|
||||
} else {
|
||||
addLayers = append(addLayers, p)
|
||||
}
|
||||
}
|
||||
for _, p := range drop {
|
||||
if image.IsTool(p) {
|
||||
names = slices.DeleteFunc(names, func(n string) bool { return n == p })
|
||||
} else {
|
||||
dropLayers = append(dropLayers, p)
|
||||
}
|
||||
}
|
||||
img, _ = removedImage(img, dropLayers)
|
||||
img, _ = addedImage(img, addLayers)
|
||||
return img.String(), image.SortTools(names), gave
|
||||
}
|
||||
|
||||
// run runs a VM's devcontainer.json commands, once it's set up: those
|
||||
// that run once (onCreateCommand, updateContentCommand,
|
||||
// postCreateCommand) at its first, then postStartCommand once each start,
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestUpDevcontainer(t *testing.T) {
|
||||
}
|
||||
st := existingVM(t, e, Options{NoNetworkPolicy: true})
|
||||
for k, want := range map[string]string{
|
||||
keyFrom: "node@sha256:" + strings.Repeat("a", 64), KeyPorts: "5173",
|
||||
keyFrom: "node@sha256:" + strings.Repeat("a", 64), KeyPorts: "5173,3000",
|
||||
KeyDevcontainerCreate: "", KeyDevcontainerEnv: `[{"name":"A","value":"'web'"}]`,
|
||||
} {
|
||||
if got := get(st, k); got != want {
|
||||
@@ -94,9 +94,12 @@ func TestUpDevcontainer(t *testing.T) {
|
||||
if env := string(s.files[s.index("env")].data); !strings.HasPrefix(env, "export A='web'\n") {
|
||||
t.Errorf("env = %q", env)
|
||||
}
|
||||
// Its ports beyond the user's are said, not added.
|
||||
if want := []string{"devcontainer_ports_not_forwarded file=.devcontainer.json ports=3000"}; !slices.Equal(warned.Names(), want) {
|
||||
t.Errorf("warned %q, want %q", warned.Names(), want)
|
||||
// Its ports are added to the user's, recorded as the file's.
|
||||
if d := sectionOf[devcontainerInVM](st, devcontainerSection); !slices.Equal(d.Ports, []string{"3000"}) || !slices.Equal(d.PortsGave, []string{"3000"}) {
|
||||
t.Errorf("file's ports %q, gave %q", d.Ports, d.PortsGave)
|
||||
}
|
||||
if len(warned.Names()) > 0 {
|
||||
t.Errorf("warned %q", warned.Names())
|
||||
}
|
||||
warned.Reset()
|
||||
|
||||
@@ -176,7 +179,7 @@ func TestUpDevcontainerRefused(t *testing.T) {
|
||||
// the user's are said, not added. The new VM keeps the file's From and
|
||||
// plan; the options stay as they were asked for.
|
||||
func TestPlanDevcontainerFrom(t *testing.T) {
|
||||
e, _, warned := devcontainerTestEnv(t, `{"image": "node:24", "forwardPorts": [3000]}`)
|
||||
e, _, _ := devcontainerTestEnv(t, `{"image": "node:24", "forwardPorts": [3000]}`)
|
||||
if _, err := settings.Save(e.Dirs, settings.Values{Ports: settings.Of("5173")}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -196,11 +199,8 @@ func TestPlanDevcontainerFrom(t *testing.T) {
|
||||
if n.dc == nil || n.dc.Ports != "3000" {
|
||||
t.Errorf("devcontainer plan = %+v", n.dc)
|
||||
}
|
||||
if n.size.Memory != "4" || n.spec.Size.MemoryGiB != 4 || n.ports != "5173" {
|
||||
t.Errorf("size %+v (spec %+v), ports %q", n.size, n.spec.Size, n.ports)
|
||||
}
|
||||
if want := "devcontainer_ports_not_forwarded file=.devcontainer.json ports=3000"; !slices.Contains(warned.Names(), want) {
|
||||
t.Errorf("warned %q, want %q", warned.Names(), want)
|
||||
if n.size.Memory != "4" || n.spec.Size.MemoryGiB != 4 || n.ports != "5173,3000" || !slices.Equal(n.dcPorts, []string{"3000"}) {
|
||||
t.Errorf("size %+v (spec %+v), ports %q, the file's %q", n.size, n.spec.Size, n.ports, n.dcPorts)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/w3cj/devvm/internal/backend"
|
||||
"github.com/w3cj/devvm/internal/devcontainer"
|
||||
"github.com/w3cj/devvm/internal/msg"
|
||||
"github.com/w3cj/devvm/internal/ports"
|
||||
"github.com/w3cj/devvm/internal/settings"
|
||||
@@ -58,6 +59,46 @@ func RemovePorts(old, list string) (string, error) {
|
||||
return dropPorts(old, l, msg.PortNotListed)
|
||||
}
|
||||
|
||||
// filePorts returns cur, a VM's ports value, with a devcontainer.json's
|
||||
// ports as devvm ports add and rm would change it (AddPorts,
|
||||
// RemovePorts): was is the file's ports when it was last read, gave
|
||||
// those of them the file added to the VM, and now its ports list now
|
||||
// (3000,5173; "" for none). Like the file's parts (devcontainer.Reread),
|
||||
// the file's ports it no longer lists go, the ones it lists anew are
|
||||
// added, and the user's stay: one the user removed stays removed, and one
|
||||
// cur forwards already, all of them included, is the user's. gaveNow is
|
||||
// what the file then gave the VM. A port that's part of a range of cur's
|
||||
// stays, as the user's.
|
||||
func filePorts(cur string, was, gave []string, now string) (string, []string, error) {
|
||||
fwd, err := ports.Forwarding(cur)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
listed := portList(now)
|
||||
var has []string
|
||||
for _, p := range slices.Concat(gave, listed) {
|
||||
if n, err := strconv.Atoi(p); err == nil && fwd.Has(n) {
|
||||
has = append(has, p)
|
||||
}
|
||||
}
|
||||
add, drop, gaveNow := devcontainer.Reread(was, gave, has, listed)
|
||||
list := orAll(cur)
|
||||
for _, p := range drop {
|
||||
if list == settings.PortsAll {
|
||||
break
|
||||
}
|
||||
if l, err := RemovePorts(list, p); err == nil {
|
||||
list = l
|
||||
}
|
||||
}
|
||||
if len(add) > 0 {
|
||||
if list, err = AddPorts(list, strings.Join(add, ",")); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
}
|
||||
return list, gaveNow, nil
|
||||
}
|
||||
|
||||
// dropPorts returns a parsed list of ports and ranges, old, without those
|
||||
// of l, a parsed list, each as listed in old (else notListed): none once
|
||||
// nothing is left.
|
||||
|
||||
+195
-32
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
@@ -32,6 +33,10 @@ type RemakeOptions struct {
|
||||
// NoCloneCheck (--no-clone-check, devvm clone off's): the clone isn't
|
||||
// checked for work the repo lacks first, which is lost.
|
||||
NoCloneCheck bool
|
||||
// DefaultFrom is what devvm update starts a VM's base from once its
|
||||
// devcontainer.json no longer names the image it started from:
|
||||
// $DEVVM_FROM's, "" for Ubuntu's cloud image.
|
||||
DefaultFrom string
|
||||
}
|
||||
|
||||
// The clone modes a remake makes a VM in (remakeInVM.Clone), as devvm
|
||||
@@ -63,6 +68,33 @@ type remakeInVM struct {
|
||||
// recorded, so the new machine is the VM, and only deleting the old
|
||||
// one is left.
|
||||
Done bool `json:"done,omitempty"`
|
||||
// Reread is what devvm update read again of the folder's
|
||||
// devcontainer.json (devcontainers.reread), which its new machine is
|
||||
// made with; nil keeps the VM's. Its tools' files are set once its
|
||||
// image is built (remaking.build).
|
||||
Reread *rereadInVM `json:"reread,omitempty"`
|
||||
// Was is what the VM had of Reread's when its new machine was made,
|
||||
// which putBack gives it back.
|
||||
Was *rereadInVM `json:"was,omitempty"`
|
||||
}
|
||||
|
||||
// rereadInVM is what a remake of a VM changes when devvm update reads
|
||||
// its devcontainer.json again: the from its base starts from, its shared
|
||||
// tools, the ports it forwards (a ports value, as devvm ports sets it)
|
||||
// and its devcontainer section.
|
||||
type rereadInVM struct {
|
||||
From string `json:"from,omitempty"`
|
||||
Tools tools.InVM `json:"tools"`
|
||||
Forward string `json:"forward,omitempty"`
|
||||
Devcontainer devcontainerInVM `json:"devcontainer"`
|
||||
}
|
||||
|
||||
// fromOf is the from p makes t's VM again from: Reread's, else the VM's.
|
||||
func fromOf(t *target, p remakeInVM) string {
|
||||
if p.Reread != nil {
|
||||
return p.Reread.From
|
||||
}
|
||||
return t.st.From
|
||||
}
|
||||
|
||||
// remakePending reports whether a remake of the VM didn't finish.
|
||||
@@ -139,26 +171,26 @@ func plan(img, command string, o RemakeOptions) remakeInVM {
|
||||
// First it moves the VM to any newer shared tools (Tools.update), which
|
||||
// needs no remake, as they're mounted. Then, when its own image or one
|
||||
// it's built on changed since the VM was made (outdated:
|
||||
// Builds.Outdated, the warning a launch gives), it says which changed
|
||||
// and makes the VM again from that image as it builds now, after the
|
||||
// user agrees (agreed). Without --force or a terminal, an outdated VM is
|
||||
// refused before anything changes. A VM with the newest tools that isn't
|
||||
// outdated is said to be current, and nothing changes. command is the
|
||||
// command as typed. A remake of it that didn't finish is finished first.
|
||||
// Builds.Outdated, the warning a launch gives), it says which changed,
|
||||
// and when the folder's devcontainer.json isn't the one the VM was made
|
||||
// from (devcontainers.reread, the warning a launch gives), it reads the
|
||||
// file again; either way, it makes the VM again from its image as it
|
||||
// builds now, with what the file says now, after the user agrees
|
||||
// (agreed). Without --force or a terminal, such a VM is refused before
|
||||
// anything changes. A VM with the newest tools that's neither is said to
|
||||
// be current, and nothing changes. command is the command as typed. A
|
||||
// remake of it that didn't finish is finished first.
|
||||
func (e Lifecycle) Update(ctx context.Context, command string, o RemakeOptions) error {
|
||||
t, resumed, release, err := e.toRemake(ctx, command, false)
|
||||
if err != nil || t == nil {
|
||||
return err
|
||||
}
|
||||
defer release()
|
||||
vm, st := t.f.Name, t.st
|
||||
changed, err := (build.Builds{Env: e.Builder(t.b, st.From)}).Outdated(st.Chain)
|
||||
p, remake, err := e.updatePlan(ctx, t, command, o)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p := plan(st.Image, command, o)
|
||||
if len(changed) > 0 {
|
||||
e.Info(msg.VMChanged(strings.Join(changed, ", "), vm))
|
||||
if remake {
|
||||
if err := e.canRemake(t, p, o); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -168,17 +200,40 @@ func (e Lifecycle) Update(ctx context.Context, command string, o RemakeOptions)
|
||||
return err
|
||||
}
|
||||
switch {
|
||||
case len(changed) > 0 && e.agreed(t, p, o):
|
||||
case remake && e.agreed(t, p, o):
|
||||
return e.remakeNow(ctx, t, p)
|
||||
case newer || resumed:
|
||||
// Its newer tools take effect as its shell opens, kept or not.
|
||||
return e.launcher.open(ctx, Options{}, t)
|
||||
case len(changed) == 0:
|
||||
e.Info(msg.VMCurrent(st.Image, vm))
|
||||
case !remake:
|
||||
e.Info(msg.VMCurrent(t.st.Image, t.f.Name))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// updatePlan is the remake devvm update makes of t's VM, and whether it
|
||||
// makes one: when its image, or one it's built on, changed (said), or its
|
||||
// devcontainer.json did (reread).
|
||||
func (e Lifecycle) updatePlan(ctx context.Context, t *target, command string, o RemakeOptions) (remakeInVM, bool, error) {
|
||||
st := t.st
|
||||
changed, err := (build.Builds{Env: e.Builder(t.b, st.From)}).Outdated(st.Chain)
|
||||
if err != nil {
|
||||
return remakeInVM{}, false, err
|
||||
}
|
||||
if len(changed) > 0 {
|
||||
e.Info(msg.VMChanged(strings.Join(changed, ", "), t.f.Name))
|
||||
}
|
||||
p := plan(st.Image, command, o)
|
||||
img, r, err := e.devcontainers.reread(ctx, t, o.DefaultFrom)
|
||||
if err != nil {
|
||||
return remakeInVM{}, false, err
|
||||
}
|
||||
if r != nil {
|
||||
p.Image, p.Reread = img, r
|
||||
}
|
||||
return p, len(changed) > 0 || r != nil, nil
|
||||
}
|
||||
|
||||
// addedImage is the image img makes with layers added on top, in the
|
||||
// order given (inOrder), and those of layers img has already.
|
||||
func addedImage(img image.Name, layers []string) (image.Name, []string) {
|
||||
@@ -288,7 +343,7 @@ func (e remaking) hold(ctx context.Context, t *target) (release func(), err erro
|
||||
return nil, err
|
||||
}
|
||||
t.st = st
|
||||
if sectionOf[remakeInVM](st, remakeSection) != was {
|
||||
if !reflect.DeepEqual(sectionOf[remakeInVM](st, remakeSection), was) {
|
||||
if err := t.refresh(ctx); err != nil {
|
||||
unlock()
|
||||
return nil, err
|
||||
@@ -362,7 +417,7 @@ type remaking struct{ *Env }
|
||||
// too), or the disk lacks room for a VM.
|
||||
func (e remaking) check(t *target, p remakeInVM) error {
|
||||
vm, b, img := t.f.Name, t.b, image.Name(p.Image)
|
||||
if err := (build.Names{Env: e.Builder(b, t.st.From)}).Check(img); err != nil {
|
||||
if err := (build.Names{Env: e.Builder(b, fromOf(t, p))}).Check(img); err != nil {
|
||||
return err
|
||||
}
|
||||
spec := e.spec(t, p)
|
||||
@@ -370,6 +425,9 @@ func (e remaking) check(t *target, p remakeInVM) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if p.Reread != nil {
|
||||
cur.Forward = p.Reread.Forward
|
||||
}
|
||||
forward, err := ports.Forwarding(cur.Forward)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -414,7 +472,12 @@ func wantsClone(st *state.VM, p remakeInVM) bool {
|
||||
// it has, the old one is deleted.
|
||||
func (e remaking) remake(ctx context.Context, t *target, p remakeInVM) error {
|
||||
vm := t.f.Name
|
||||
chain, err := e.build(ctx, t, p.Image)
|
||||
unmaking, err := e.holdTools(ctx, p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer unmaking()
|
||||
chain, err := e.build(ctx, t, &p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -447,10 +510,12 @@ func (e remaking) remake(ctx context.Context, t *target, p remakeInVM) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// build builds img (a remake's, as its record has it) for t's VM, as a
|
||||
// new VM's is built, and returns its build chain.
|
||||
func (e remaking) build(ctx context.Context, t *target, recorded string) (chainOf, error) {
|
||||
b, img := e.Builder(t.b, t.st.From), image.Name(recorded)
|
||||
// build builds p's image (as its record has it) for t's VM, from p's
|
||||
// from, as a new VM's is built, and returns its build chain. A reread
|
||||
// devcontainer.json's tools (p.Reread) are then built for that image's
|
||||
// base, as a new VM's are, and their files set in p.
|
||||
func (e remaking) build(ctx context.Context, t *target, p *remakeInVM) (chainOf, error) {
|
||||
b, img := e.Builder(t.b, fromOf(t, *p)), image.Name(p.Image)
|
||||
if err := (build.Builds{Env: b}).Build(ctx, img); err != nil {
|
||||
return chainOf{}, err
|
||||
}
|
||||
@@ -458,9 +523,41 @@ func (e remaking) build(ctx context.Context, t *target, recorded string) (chainO
|
||||
if err != nil {
|
||||
return chainOf{}, err
|
||||
}
|
||||
if p.Reread != nil {
|
||||
if p.Reread.Tools.Made, err = e.buildTools(ctx, b, p.Reread.Tools.Names); err != nil {
|
||||
return chainOf{}, err
|
||||
}
|
||||
}
|
||||
return chainOf{key: c.Key(), chain: c.String()}, nil
|
||||
}
|
||||
|
||||
// buildTools builds the shared tools names for a VM of b's base, built,
|
||||
// as a new VM's are, and returns what it gets of them.
|
||||
func (e remaking) buildTools(ctx context.Context, b *build.Env, names []string) (tools.Made, error) {
|
||||
tg, err := b.ToolTarget()
|
||||
if err != nil {
|
||||
return tools.Made{}, err
|
||||
}
|
||||
files, err := (tools.Versions{Env: e.Tools}).Files(ctx, names, tg)
|
||||
if err != nil {
|
||||
return tools.Made{}, err
|
||||
}
|
||||
if err := e.launcher.buildTools(ctx, b, tg, files); err != nil {
|
||||
return tools.Made{}, err
|
||||
}
|
||||
return tools.Made{Files: files, Libc: tg.Libc, Glibc: tg.Glibc}, nil
|
||||
}
|
||||
|
||||
// holdTools holds the lock VMs being made hold while p, a remake that
|
||||
// changes the VM's tools (Reread), makes it, so gc keeps their images
|
||||
// until its state lists them.
|
||||
func (e remaking) holdTools(ctx context.Context, p remakeInVM) (func(), error) {
|
||||
if p.Reread == nil {
|
||||
return func() {}, nil
|
||||
}
|
||||
return tools.Making{Dirs: e.Dirs, Reporter: e.Reporter}.Hold(ctx)
|
||||
}
|
||||
|
||||
// chainOf is an image's build chain, as a VM is made from it (its key)
|
||||
// and its state records it.
|
||||
type chainOf struct{ key, chain string }
|
||||
@@ -491,20 +588,18 @@ func (e remaking) finish(ctx context.Context, t *target, p remakeInVM, c chainOf
|
||||
return err
|
||||
}
|
||||
t.exists = true
|
||||
// The new machine is the one by its name now, in its clone mode, and
|
||||
// its devcontainer.json's commands run again on its new disk.
|
||||
// The new machine is the one by its name now, in its clone mode, with
|
||||
// what p read again, and its devcontainer.json's commands run again
|
||||
// on its new disk.
|
||||
mode := ""
|
||||
if p.Clone == CloneOff {
|
||||
mode = e.Protector(t.f.Dir).NewMode(false)
|
||||
}
|
||||
err := st.Update(ctx, func(st *state.VM) error {
|
||||
if err := edit(st, remakeSection, func(r *remakeInVM) error { r.Made = true; return nil }); err != nil {
|
||||
if err := madeWith(st, p); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := switchedTo(st, p.Clone, mode); err != nil {
|
||||
return err
|
||||
}
|
||||
return edit(st, devcontainerSection, func(d *devcontainerInVM) error { d.Made = devcontainerMade{}; return nil })
|
||||
return switchedTo(st, p.Clone, mode)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -538,6 +633,63 @@ func (e remaking) finish(ctx context.Context, t *target, p remakeInVM, c chainOf
|
||||
return e.dropOld(ctx, t, p)
|
||||
}
|
||||
|
||||
// madeWith records in st, inside st.Update, that its remake p made its
|
||||
// new machine (Made): what the VM had of what p may read again
|
||||
// (rereadOf) kept in Was the first time, for putBack, then p's reread
|
||||
// devcontainer.json in its place (setReread), and its commands run again.
|
||||
func madeWith(st *state.VM, p remakeInVM) error {
|
||||
r, err := state.Section[remakeInVM](st, remakeSection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !r.Made {
|
||||
was, err := rereadOf(st)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Made, r.Was = true, &was
|
||||
if err := state.SetSection(st, remakeSection, r); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if p.Reread != nil {
|
||||
return setReread(st, *p.Reread)
|
||||
}
|
||||
return edit(st, devcontainerSection, func(d *devcontainerInVM) error { d.Made = devcontainerMade{}; return nil })
|
||||
}
|
||||
|
||||
// rereadOf is what st's VM has of what devvm update reads again of its
|
||||
// devcontainer.json: its from, shared tools and devcontainer section.
|
||||
func rereadOf(st *state.VM) (rereadInVM, error) {
|
||||
tl, err := tools.Of(st)
|
||||
if err != nil {
|
||||
return rereadInVM{}, err
|
||||
}
|
||||
d, err := state.Section[devcontainerInVM](st, devcontainerSection)
|
||||
if err != nil {
|
||||
return rereadInVM{}, err
|
||||
}
|
||||
p, err := ports.Of(st)
|
||||
if err != nil {
|
||||
return rereadInVM{}, err
|
||||
}
|
||||
return rereadInVM{From: st.From, Tools: tl, Forward: p.Forward, Devcontainer: d}, nil
|
||||
}
|
||||
|
||||
// setReread gives st's VM r's from, shared tools, forwarded ports (as
|
||||
// devvm ports sets them: ports.SetForward) and devcontainer section, in
|
||||
// st alone: inside st.Update.
|
||||
func setReread(st *state.VM, r rereadInVM) error {
|
||||
st.From = r.From
|
||||
if err := tools.Set(st, r.Tools); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ports.SetForward(st, r.Forward); err != nil {
|
||||
return err
|
||||
}
|
||||
return state.SetSection(st, devcontainerSection, r.Devcontainer)
|
||||
}
|
||||
|
||||
// dropOld ends a remake of t's VM whose new machine is done (p.Done):
|
||||
// it deletes the old machine, set aside, then what the old one's clone
|
||||
// mode left on the host (leftBehind), then ends the remake (clear).
|
||||
@@ -598,7 +750,8 @@ func (e remaking) putBack(ctx context.Context, t *target) error {
|
||||
return err
|
||||
}
|
||||
t.exists = true
|
||||
// The machine by its name is the old one again, in its clone mode.
|
||||
// The machine by its name is the old one again, in its clone mode,
|
||||
// with what it had of what the remake read again.
|
||||
r := sectionOf[remakeInVM](t.st, remakeSection)
|
||||
if r.Made && r.Clone == CloneOff {
|
||||
e.unmountFolder(ctx, t)
|
||||
@@ -609,7 +762,12 @@ func (e remaking) putBack(ctx context.Context, t *target) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return edit(st, remakeSection, func(r *remakeInVM) error { r.Made = false; return nil })
|
||||
if r.Made && r.Was != nil {
|
||||
if err := setReread(st, *r.Was); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return edit(st, remakeSection, func(r *remakeInVM) error { r.Made, r.Was = false, nil; return nil })
|
||||
})
|
||||
}
|
||||
|
||||
@@ -657,7 +815,7 @@ func (e remaking) finishPending(ctx context.Context, t *target) error {
|
||||
if err := e.check(t, p); err != nil {
|
||||
return err
|
||||
}
|
||||
p.Made = false
|
||||
p.Made, p.Was = false, nil
|
||||
return e.remake(ctx, t, p)
|
||||
}
|
||||
return e.makeNew(ctx, t, p)
|
||||
@@ -681,7 +839,12 @@ func (e remaking) makeNew(ctx context.Context, t *target, p remakeInVM) error {
|
||||
e.Warn(msg.RemakeHomeLost(vm))
|
||||
p.Home = false
|
||||
}
|
||||
c, err := e.build(ctx, t, p.Image)
|
||||
unmaking, err := e.holdTools(ctx, p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer unmaking()
|
||||
c, err := e.build(ctx, t, &p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
package vm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/w3cj/devvm/internal/devcontainer"
|
||||
"github.com/w3cj/devvm/internal/msg"
|
||||
"github.com/w3cj/devvm/internal/settings"
|
||||
"github.com/w3cj/devvm/internal/state"
|
||||
"github.com/w3cj/devvm/internal/tools"
|
||||
)
|
||||
|
||||
// A reread devcontainer.json's parts replace what the file gave the VM,
|
||||
// layers out of its image and toolchains out of its tools, and leave the
|
||||
// user's as they are.
|
||||
func TestRereadParts(t *testing.T) {
|
||||
e, _, _ := upEnv(t, allNative())
|
||||
for _, c := range []struct {
|
||||
name, img string
|
||||
names []string
|
||||
was devcontainerInVM
|
||||
now []string
|
||||
wantImg string
|
||||
wantNames, wantGv []string
|
||||
}{
|
||||
{
|
||||
name: "the file's replaced", img: "docker+desktop", names: []string{"node", "claude"},
|
||||
was: devcontainerInVM{Parts: []string{"docker", "node"}, Gave: []string{"docker", "node"}}, now: []string{"go"},
|
||||
wantImg: "desktop", wantNames: []string{"go", "claude"}, wantGv: []string{"go"},
|
||||
},
|
||||
{
|
||||
name: "the user's kept", img: "docker", names: []string{"node"},
|
||||
was: devcontainerInVM{Parts: []string{"docker", "node"}}, now: nil,
|
||||
wantImg: "docker", wantNames: []string{"node"},
|
||||
},
|
||||
{
|
||||
name: "a layer added on top", img: "desktop", names: nil,
|
||||
now: []string{"docker"},
|
||||
wantImg: "desktop+docker", wantGv: []string{"docker"},
|
||||
},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
st := vmState(t, e.Dirs, "devvm-x-0123456789abcd", func(st *state.VM) error {
|
||||
st.Image = c.img
|
||||
return tools.Set(st, tools.InVM{Names: c.names})
|
||||
})
|
||||
img, names, gave := rereadParts(st, c.was, c.now)
|
||||
if img != c.wantImg || !slices.Equal(names, c.wantNames) || !slices.Equal(gave, c.wantGv) {
|
||||
t.Errorf("rereadParts = %s, %q, %q; want %s, %q, %q", img, names, gave, c.wantImg, c.wantNames, c.wantGv)
|
||||
}
|
||||
if got := tools.Names(st); !slices.Equal(got, c.names) {
|
||||
t.Errorf("its state's tools changed: %q", got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A devcontainer.json's ports join the VM's as devvm ports add adds
|
||||
// them, and read again they replace only the file's: the user's own
|
||||
// stay, and one the user removed stays removed.
|
||||
func TestFilePorts(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name, cur string
|
||||
was, gave []string
|
||||
now string
|
||||
want string
|
||||
wantGave []string
|
||||
}{
|
||||
{name: "new, with every port", cur: "", now: "3000", want: "all"},
|
||||
{name: "new, with none", cur: "none", now: "3000,5173", want: "3000,5173", wantGave: []string{"3000", "5173"}},
|
||||
{name: "new, one the user has", cur: "5173", now: "3000,5173", want: "5173,3000", wantGave: []string{"3000"}},
|
||||
{name: "a range of the user's", cur: "3000-3010", now: "3005", want: "3000-3010"},
|
||||
{name: "none in the file", cur: "8080", want: "8080"},
|
||||
{
|
||||
name: "the file's replaced, the user's kept", cur: "3000,8080", was: []string{"3000"}, gave: []string{"3000"},
|
||||
now: "4000", want: "8080,4000", wantGave: []string{"4000"},
|
||||
},
|
||||
{
|
||||
name: "removed by the user stays removed", cur: "8080", was: []string{"3000", "4000"}, gave: []string{"3000", "4000"},
|
||||
now: "3000,4000,5000", want: "8080,5000", wantGave: []string{"5000"},
|
||||
},
|
||||
{name: "the file gone, the last one", cur: "3000", was: []string{"3000"}, gave: []string{"3000"}, want: "none"},
|
||||
{name: "every port since", cur: "all", was: []string{"3000"}, gave: []string{"3000"}, want: "all"},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
got, gave, err := filePorts(c.cur, c.was, c.gave, c.now)
|
||||
if err != nil || got != c.want || !slices.Equal(gave, c.wantGave) {
|
||||
t.Errorf("filePorts = %q, %q, %v; want %q, %q", got, gave, err, c.want, c.wantGave)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// What a new VM gets from its devcontainer.json alone: not a part whose
|
||||
// flag chose its list, nor one devvm setup's layers or the folder's
|
||||
// other files call for, nor one it didn't get.
|
||||
func TestFileParts(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "package.json"), []byte("{}"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dc := &devcontainer.Plan{Layers: []string{"docker", "node", "go", "rust"}}
|
||||
got := Parts{Toolchains: []string{"node", "go"}, Layers: []string{"docker"}}
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
o Options
|
||||
def settings.Defaults
|
||||
want []string
|
||||
}{
|
||||
{name: "defaults", want: []string{"docker", "go"}},
|
||||
{name: "--tools", o: Options{Toolchains: &[]string{"go"}}, want: []string{"docker"}},
|
||||
{name: "--layers", o: Options{Layers: &[]string{"docker"}}, want: []string{"go"}},
|
||||
{name: "setup's layer", def: settings.Defaults{Layers: settings.List{Names: []string{"docker"}}}, want: []string{"go"}},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
if gave := fileParts(c.o, dir, dc, c.def, got); !slices.Equal(gave, c.want) {
|
||||
t.Errorf("fileParts = %q, want %q", gave, c.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
if gave := fileParts(Options{}, dir, nil, settings.Defaults{}, got); gave != nil {
|
||||
t.Errorf("without a file: %q", gave)
|
||||
}
|
||||
}
|
||||
|
||||
// devvm update reads a changed devcontainer.json again: a failed remake
|
||||
// puts the old machine back with its from, tools and devcontainer
|
||||
// section, and one that finishes gives the VM what the file says now.
|
||||
func TestUpdateDevcontainer(t *testing.T) {
|
||||
e, f, _ := devcontainerTestEnv(t, `{"image": "node:24", "features": {"ghcr.io/devcontainers/features/docker-in-docker:2": {}}, "postCreateCommand": "echo one"}`)
|
||||
st := existingVM(t, e, Options{NoNetworkPolicy: true})
|
||||
vm := st.Name()
|
||||
before := readState(t, e.Dirs, vm)
|
||||
if before.Image != "docker" || !slices.Equal(sectionOf[devcontainerInVM](before, devcontainerSection).Gave, []string{"docker"}) {
|
||||
t.Fatalf("made %s, %+v", before.Image, sectionOf[devcontainerInVM](before, devcontainerSection))
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(e.Dir, ".devcontainer.json"), []byte(`{"image": "node:22", "postCreateCommand": "echo two"}`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pinned := func(ref string) string { return ref + "@sha256:" + strings.Repeat("a", 64) }
|
||||
e.PublicImage = func(_ context.Context, ref string) (string, error) { return pinned(ref), nil }
|
||||
var said []string
|
||||
fake(e).OnInfo = func(m msg.M) { said = append(said, m.Names()) }
|
||||
var cleanups []func(context.Context)
|
||||
fake(e).OnCleanup = func(c func(context.Context)) func() {
|
||||
i := len(cleanups)
|
||||
cleanups = append(cleanups, c)
|
||||
return func() { cleanups[i] = nil }
|
||||
}
|
||||
lc := Lifecycle{e}
|
||||
|
||||
// Its new machine fails to start: put back as it was.
|
||||
f.Errs = map[string]error{"Start": errors.New("no boot")}
|
||||
o := RemakeOptions{Force: true, CleanHome: true}
|
||||
if err := lc.Update(t.Context(), "devvm update", o); err == nil || err.Error() != "no boot" {
|
||||
t.Fatalf("Update: %v", msg.NamesOf(err))
|
||||
}
|
||||
if !slices.Contains(said, "devcontainer_reread file=.devcontainer.json vm="+vm) {
|
||||
t.Errorf("said %q", said)
|
||||
}
|
||||
for _, c := range slices.Backward(cleanups) {
|
||||
if c != nil {
|
||||
c(t.Context())
|
||||
}
|
||||
}
|
||||
f.Errs = nil
|
||||
after := readState(t, e.Dirs, vm)
|
||||
for _, k := range []string{keyFrom, KeyDevcontainer, KeyDevcontainerCreate, keyToolNames, KeyTools} {
|
||||
if get(after, k) != get(before, k) {
|
||||
t.Errorf("undone: %s = %q, was %q", k, get(after, k), get(before, k))
|
||||
}
|
||||
}
|
||||
if d := sectionOf[devcontainerInVM](after, devcontainerSection); !d.Made.Created || remakePending(after) {
|
||||
t.Errorf("undone: made %+v, pending %v", d.Made, remakePending(after))
|
||||
}
|
||||
|
||||
// Made again: the file's image, without its docker layer, its new
|
||||
// command run on the new disk.
|
||||
cleanups = nil
|
||||
if err := lc.Update(t.Context(), "devvm update", o); err != nil {
|
||||
t.Fatal(msg.NamesOf(err))
|
||||
}
|
||||
after = readState(t, e.Dirs, vm)
|
||||
d := sectionOf[devcontainerInVM](after, devcontainerSection)
|
||||
if after.Image != "base" || after.From != pinned("node:22") || d.Image != "node:22" || len(d.Gave) != 0 || remakePending(after) {
|
||||
t.Errorf("remade: %s from %s, %+v", after.Image, after.From, d)
|
||||
}
|
||||
if cmds, _ := commandsRun(f); cmds[len(cmds)-1] != "sh -c echo two" {
|
||||
t.Errorf("ran %q", cmds)
|
||||
}
|
||||
if r := sectionOf[remakeInVM](after, remakeSection); r.Reread != nil || r.Was != nil {
|
||||
t.Errorf("remake left %+v", r)
|
||||
}
|
||||
}
|
||||
+27
-8
@@ -41,15 +41,34 @@ type cloneMade struct {
|
||||
|
||||
// devcontainerInVM is a VM's devcontainer section: the devcontainer.json
|
||||
// it was made from, what that maps to of the VM's own (its variables, its
|
||||
// commands), and which of its commands ran.
|
||||
// commands), what of the VM came from the file and what from the user,
|
||||
// which devvm update reads the file again by (devcontainers.reread), and
|
||||
// which of its commands ran.
|
||||
type devcontainerInVM struct {
|
||||
Off bool `json:"off,omitempty"` // made with --no-devcontainer
|
||||
File string `json:"file,omitempty"` // the file, in the project folder; "" for none
|
||||
Sum string `json:"sum,omitempty"` // its SHA-256 then
|
||||
Env []devcontainer.Var `json:"env,omitempty"`
|
||||
Create []devcontainer.Command `json:"create,omitempty"` // run once, at its first launch
|
||||
Start []devcontainer.Command `json:"start,omitempty"` // run once each start
|
||||
Made devcontainerMade `json:"made,omitzero"`
|
||||
Off bool `json:"off,omitempty"` // made with --no-devcontainer
|
||||
File string `json:"file,omitempty"` // the file, in the project folder; "" for none
|
||||
Sum string `json:"sum,omitempty"` // its SHA-256 then
|
||||
// Image is the file's image, as it names it, when the VM's base
|
||||
// starts from it (pinned: the VM's From); "" when the file has none,
|
||||
// or --from won.
|
||||
Image string `json:"image,omitempty"`
|
||||
// FromFlag: the VM was made with --from, which wins over the file's
|
||||
// image.
|
||||
FromFlag bool `json:"from_flag,omitempty"`
|
||||
// Parts are the toolchains and layers the file's features mapped to;
|
||||
// Gave those of them the VM got from the file alone, not from the
|
||||
// user's flags, devvm setup's layers or the folder's other files.
|
||||
Parts []string `json:"parts,omitempty"`
|
||||
Gave []string `json:"gave,omitempty"`
|
||||
// Ports are the file's forwardPorts when it was last read; PortsGave
|
||||
// those of them it added to the VM's ports (filePorts), not the
|
||||
// user's own.
|
||||
Ports []string `json:"ports,omitempty"`
|
||||
PortsGave []string `json:"ports_gave,omitempty"`
|
||||
Env []devcontainer.Var `json:"env,omitempty"`
|
||||
Create []devcontainer.Command `json:"create,omitempty"` // run once, at its first launch
|
||||
Start []devcontainer.Command `json:"start,omitempty"` // run once each start
|
||||
Made devcontainerMade `json:"made,omitzero"`
|
||||
}
|
||||
|
||||
// devcontainerMade is which of a VM's devcontainer.json commands ran.
|
||||
|
||||
+19
-26
@@ -182,9 +182,12 @@ type newVM struct {
|
||||
from string
|
||||
// dc is what the folder's devcontainer.json says it gets
|
||||
// (devcontainers.prepare); nil without one.
|
||||
dc *devcontainer.Plan
|
||||
spec backend.VMSpec
|
||||
builder *build.Env
|
||||
dc *devcontainer.Plan
|
||||
// dcGave is what it gets of its parts from the devcontainer.json
|
||||
// alone (fileParts), dcPorts of its ports (newPorts).
|
||||
dcGave, dcPorts []string
|
||||
spec backend.VMSpec
|
||||
builder *build.Env
|
||||
// history is the export of agents' history it gets once it's started,
|
||||
// as the user said yes to (offerHistory); "" for none.
|
||||
history string
|
||||
@@ -263,7 +266,7 @@ func (e creation) create(ctx context.Context, o Options, f project.Folder, b bac
|
||||
if err := n.record(st, tg, files); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := e.devcontainers.record(st, o.NoDevcontainer, n.dc); err != nil {
|
||||
if err := e.devcontainers.record(st, o, n.dc, n.dcGave, n.dcPorts); err != nil {
|
||||
return err
|
||||
}
|
||||
// Its alias, chosen now for good, as its name was, under the claims
|
||||
@@ -419,7 +422,7 @@ func (e creation) plan(ctx context.Context, o Options, f project.Folder, b backe
|
||||
if err := n.size.Check(host, backend.BaseDiskGiB, vm); err != nil {
|
||||
return newVM{}, err
|
||||
}
|
||||
if n.ports, err = e.newPorts(o.Ports, def, n.dc); err != nil {
|
||||
if n.ports, n.dcPorts, err = newPorts(o.Ports, def, n.dc); err != nil {
|
||||
return newVM{}, err
|
||||
}
|
||||
forward, err := ports.Forwarding(n.ports)
|
||||
@@ -432,6 +435,7 @@ func (e creation) plan(ctx context.Context, o Options, f project.Folder, b backe
|
||||
return newVM{}, err
|
||||
}
|
||||
n.img, n.tools = parts.image(), parts.tools()
|
||||
n.dcGave = fileParts(o, f.Dir, n.dc, def, parts)
|
||||
n.spec = e.machineSpec(b, f, n.tools, o.SSHAgent, n.size, o.Clone)
|
||||
n.net = e.chooseNet(o, b, vm, def.Network.Value)
|
||||
if o.SSHAgent {
|
||||
@@ -460,30 +464,19 @@ func (e creation) plan(ctx context.Context, o Options, f project.Folder, b backe
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// newPorts returns the ports a new VM forwards: given's (--ports, parsed),
|
||||
// else def's. The user's ports stay a limit its devcontainer.json (dc)
|
||||
// can't widen: the file's ports beyond them are said, not added.
|
||||
func (e creation) newPorts(given string, def settings.Defaults, dc *devcontainer.Plan) (string, error) {
|
||||
list := ""
|
||||
// newPorts returns the ports a new VM forwards: given's (--ports,
|
||||
// parsed), which win over its devcontainer.json's (dc), else def's with
|
||||
// the file's added, as devvm ports add adds them (filePorts), and the
|
||||
// file's ports it added (gave).
|
||||
func newPorts(given string, def settings.Defaults, dc *devcontainer.Plan) (list string, gave []string, err error) {
|
||||
if given != "" {
|
||||
var err error
|
||||
if list, err = settings.ParsePorts(given); err != nil {
|
||||
return "", err
|
||||
}
|
||||
list, err = settings.ParsePorts(given)
|
||||
return list, nil, err
|
||||
}
|
||||
if list == "" {
|
||||
list = def.Ports.Value
|
||||
if dc == nil || dc.Ports == "" {
|
||||
return def.Ports.Value, nil, nil
|
||||
}
|
||||
if dc != nil && dc.Ports != "" {
|
||||
wider, err := AddPorts(list, dc.Ports)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if wider != list {
|
||||
e.Warn(msg.DevcontainerPortsNotForwarded(dc.File, dc.Ports))
|
||||
}
|
||||
}
|
||||
return list, nil
|
||||
return filePorts(def.Ports.Value, nil, nil, dc.Ports)
|
||||
}
|
||||
|
||||
// chooseNet returns whether a new VM gets network policy: the flags', else
|
||||
|
||||
+10
-6
@@ -2362,10 +2362,6 @@ other = "The initializeCommand in {{.file}} never runs, because it would run on
|
||||
description = "features is a space-separated list of feature IDs"
|
||||
other = "{{.file}} gives options to {{.features}}, and devvm ignores them."
|
||||
|
||||
[devcontainer_ports_not_forwarded]
|
||||
description = "ports is a ports list (3000,5173)"
|
||||
other = "Your ports setting limits what {{.file}} can forward, so devvm doesn't forward all of forwardPorts {{.ports}}. Run devvm ports add {{.ports}} to forward them."
|
||||
|
||||
[devcontainer_ports_ignored]
|
||||
description = "ports is a space-separated list of forwardPorts entries"
|
||||
other = "The forwardPorts {{.ports}} in {{.file}} have no effect, because a VM's ports reach only this machine's localhost."
|
||||
@@ -2405,10 +2401,18 @@ other = "Reading {{.file}} failed. Fix it, or run devvm --no-devcontainer."
|
||||
other = "The container image {{.from}} in {{.file}} isn't public in its registry, and devvm uses only public images from a project's file. Run devvm --from {{.from}} to use it anyway."
|
||||
|
||||
[devcontainer_changed]
|
||||
other = "{{.vm}} was made from another version of {{.file}}, and the file never changes an existing VM. To make the VM again, run devvm rm, then devvm."
|
||||
other = "{{.vm}} was made from another version of {{.file}}, and the file changes an existing VM only when devvm makes it again. To make the VM again as the file says now, run devvm update."
|
||||
|
||||
[devcontainer_new]
|
||||
other = "{{.vm}} was made without {{.file}}, and the file never changes an existing VM. To make the VM again, run devvm rm, then devvm."
|
||||
other = "{{.vm}} was made without {{.file}}, and the file changes an existing VM only when devvm makes it again. To make the VM again as the file says, run devvm update."
|
||||
|
||||
[devcontainer_reread]
|
||||
description = "file is the devcontainer.json's path in the project folder"
|
||||
other = "devvm makes {{.vm}} again as {{.file}} says now."
|
||||
|
||||
[devcontainer_gone]
|
||||
description = "file is the devcontainer.json's path in the project folder, as the VM was made from it"
|
||||
other = "{{.file}} is gone, so devvm makes {{.vm}} again without it."
|
||||
|
||||
[devcontainer_command_failed]
|
||||
description = "command is a devcontainer.json property, with a named command's name after it"
|
||||
|
||||
Vendored
+119
-6
@@ -2,8 +2,9 @@
|
||||
# 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. Nothing is
|
||||
# written to the project folder, and nothing in the file runs on the host.
|
||||
# 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
|
||||
@@ -51,7 +52,8 @@ 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 listed; what's ignored is said, initializeCommand never
|
||||
# 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
|
||||
@@ -63,7 +65,6 @@ 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_ports_not_forwarded file=\.devcontainer/devcontainer\.json ports=3000,5173$'
|
||||
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}$'
|
||||
@@ -86,7 +87,9 @@ 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=none$'
|
||||
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$'
|
||||
@@ -178,9 +181,111 @@ 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: force_needed command=devvm update$'
|
||||
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"}}
|
||||
{"digests": {"node:24": "node@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "node:22": "node@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}}
|
||||
-- extra.sh --
|
||||
#!/bin/bash
|
||||
echo extra
|
||||
@@ -227,3 +332,11 @@ echo extra
|
||||
}
|
||||
-- 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",
|
||||
}
|
||||
+18
-9
@@ -13,7 +13,7 @@
|
||||
# again, restart, devvm size, devvm ports (a running VM's at once, never a listed port a
|
||||
# program here has, a bad list a usage error), a mistyped command refused with a suggestion,
|
||||
# devvm git-protect and rm, a VM from a devcontainer.json (its ports, variables, commands
|
||||
# once and at each start, a changed file, an image on this machine's registry refused), an agent VM's folders and history (devvm history export, rm's export, a new VM's offer, devvm history import and its refusal), and SSH agent forwarding
|
||||
# once and at each start, a changed file, devvm update reading it again, an image on this machine's registry refused), an agent VM's folders and history (devvm history export, rm's export, a new VM's offer, devvm history import and its refusal), and SSH agent forwarding
|
||||
# (a throwaway agent's, and devvm's own with a throwaway key); clone makes a --clone
|
||||
# VM of a throwaway repo and checks its clone (pushed past an insteadOf), the remote, fetching, and rm's checks
|
||||
# for unfetched commits and uncommitted changes and the work it keeps, then a git worktree's clone; gc deletes a stale
|
||||
@@ -2213,9 +2213,10 @@ check "rm deletes only this VM, with its state and ssh config entry, and unlocks
|
||||
[[ -z \$(ls '$XDG_DATA_HOME/devvm/exports' 2>/dev/null) ]]"
|
||||
|
||||
section "a devcontainer.json"
|
||||
# Its forwardPorts beyond the user's ports said, not forwarded (the default is none for this VM), its
|
||||
# Its forwardPorts added to the user's ports (none for this VM) and reaching this machine, its
|
||||
# variables in the shell and its commands, its postCreateCommand once, its postStartCommand at each
|
||||
# start; nothing written to the folder, and a changed file only warned about.
|
||||
# start; nothing written to the folder, a changed file only warned about, then devvm update makes
|
||||
# the VM again as it says, its home kept and the file's new port forwarded in place of its old one.
|
||||
dc=$(newproj dc); mkdir -p "$dc/.devcontainer"
|
||||
printf '%s\n' '{' ' // e2e' ' "name": "dc",' " \"forwardPorts\": [$P47180]," \
|
||||
' "containerEnv": {"E2E_DC": "dc-${containerWorkspaceFolderBasename}"},' \
|
||||
@@ -2228,17 +2229,16 @@ launch "$dc" 'echo "dc-env=$E2E_DC"' --no-network-policy
|
||||
check "devvm makes the VM as its devcontainer.json says, and says so" bash -c "[[ -n '$vm' && \$(status_of '$vm') == Running ]] &&
|
||||
grep -qF \"\$(m devcontainer_using file=.devcontainer/devcontainer.json vm=$vm)\" '$work/last.log' &&
|
||||
vm_state '$(vmdir "$vm")' | grep -Eqx 'devcontainer\.sum=[0-9a-f]{64}' &&
|
||||
vm_state '$(vmdir "$vm")' | grep -qx 'devcontainer.file=.devcontainer/devcontainer.json' && vm_state '$(vmdir "$vm")' | grep -qx ports.forward=none"
|
||||
check "its forwardPorts don't widen your ports: said, not added" \
|
||||
grep -qF "$(m devcontainer_ports_not_forwarded file=.devcontainer/devcontainer.json ports=$P47180)" "$work/last.log"
|
||||
vm_state '$(vmdir "$vm")' | grep -qx 'devcontainer.file=.devcontainer/devcontainer.json' && vm_state '$(vmdir "$vm")' | grep -qx ports.forward=$P47180"
|
||||
check "its forwardPorts join your ports, as the file's" bash -c "vm_state '$(vmdir "$vm")' | grep -qx 'devcontainer.ports_gave=$P47180'"
|
||||
check "its shell has the file's variables" grep -qx dc-env=dc-dc "$work/last.log"
|
||||
check "postCreateCommand ran once, in the VM, in the folder, with them" in_vm "$vm" "[[ \$(cat ~/dc-created) == 'dc-dc $dc' ]]"
|
||||
check "postStartCommand ran at its start" in_vm "$vm" '[[ $(cat ~/dc-started) == started ]]'
|
||||
check "nothing was written to the project folder" bash -c "[[ \$(ls -A '$dc') == .devcontainer && \$(ls -A '$dc/.devcontainer') == devcontainer.json ]] &&
|
||||
cmp -s '$dc/.devcontainer/devcontainer.json' '$work/dc.json'"
|
||||
in_vm "$vm" "setsid -f python3 -m http.server -b 0.0.0.0 $P47180 </dev/null >/dev/null 2>&1; setsid -f python3 -m http.server -b 0.0.0.0 $P47181 </dev/null >/dev/null 2>&1" >/dev/null 2>&1
|
||||
check "... and don't reach this machine" bash -c \
|
||||
'sleep 5; ! nc -z 127.0.0.1 $P47180 && ! nc -z 127.0.0.1 $P47181'
|
||||
check "... its forwardPorts reach this machine's localhost, and other ports don't" bash -c \
|
||||
'for _ in $(seq 20); do nc -z 127.0.0.1 $P47180 && break; sleep 1; done; nc -z 127.0.0.1 $P47180 && ! nc -z 127.0.0.1 $P47181'
|
||||
check "launched again, running: nothing runs again" bash -c "cd '$dc' && printf 'exit\n' | '$D' >'$work/last.log' 2>&1 &&
|
||||
limactl shell --workdir / $vm bash -c '[[ \$(wc -l < ~/dc-created) == 1 && \$(wc -l < ~/dc-started) == 1 ]]' </dev/null"
|
||||
check "restarted: postStartCommand runs again, postCreateCommand doesn't" bash -c "cd '$dc' && printf 'exit\n' | '$D' restart >'$work/last.log' 2>&1 &&
|
||||
@@ -2246,7 +2246,16 @@ check "restarted: postStartCommand runs again, postCreateCommand doesn't" bash -
|
||||
printf '%s\n' "{\"forwardPorts\": [$P47182], \"postCreateCommand\": \"touch ~/dc-changed\"}" >"$dc/.devcontainer/devcontainer.json"
|
||||
check "a changed file is warned about, and changes nothing" bash -c "cd '$dc' && printf 'exit\n' | '$D' >'$work/last.log' 2>&1 &&
|
||||
grep -qF \"\$(m devcontainer_changed file=.devcontainer/devcontainer.json vm=$vm | head -1)\" '$work/last.log' &&
|
||||
vm_state '$(vmdir "$vm")' | grep -qx ports.forward=none && limactl shell --workdir / $vm bash -c '[[ ! -e ~/dc-changed ]]' </dev/null"
|
||||
vm_state '$(vmdir "$vm")' | grep -qx ports.forward=$P47180 && limactl shell --workdir / $vm bash -c '[[ ! -e ~/dc-changed ]]' </dev/null"
|
||||
check "devvm update makes it again as the changed file says, keeping its home" bash -c "cd '$dc' && printf 'echo \"dc-env=\$E2E_DC.\"; exit\n' | '$D' update --force >'$work/last.log' 2>&1 &&
|
||||
grep -qF \"\$(m devcontainer_reread file=.devcontainer/devcontainer.json vm=$vm)\" '$work/last.log' &&
|
||||
grep -qx dc-env=. '$work/last.log' && vm_state '$(vmdir "$vm")' | grep -qx ports.forward=$P47182 &&
|
||||
limactl shell --workdir / $vm bash -c '[[ -e ~/dc-changed && \$(cat ~/dc-created) == \"dc-dc $dc\" ]]' </dev/null"
|
||||
in_vm "$vm" "setsid -f python3 -m http.server -b 0.0.0.0 $P47180 </dev/null >/dev/null 2>&1; setsid -f python3 -m http.server -b 0.0.0.0 $P47182 </dev/null >/dev/null 2>&1" >/dev/null 2>&1
|
||||
check "... the file's new port reaches this machine, and its old one no longer does" bash -c \
|
||||
'for _ in $(seq 20); do nc -z 127.0.0.1 $P47182 && break; sleep 1; done; nc -z 127.0.0.1 $P47182 && ! nc -z 127.0.0.1 $P47180'
|
||||
check "... and a launch no longer warns about the file" bash -c "cd '$dc' && printf 'exit\n' | '$D' >'$work/last.log' 2>&1 &&
|
||||
! grep -qF \"\$(m devcontainer_changed file=.devcontainer/devcontainer.json vm=$vm | head -1)\" '$work/last.log'"
|
||||
check "rm deletes it" bash -c "cd '$dc' && '$D' rm --force --no-export </dev/null >'$work/last.log' 2>&1 && ! limactl list -q | grep -qx $vm"
|
||||
printf '%s\n' '{"image": "localhost:5000/app:1"}' > "$dc/.devcontainer/devcontainer.json"
|
||||
check "an image on this machine's registry is refused, nothing made" bash -c "cd '$dc' && ! '$D' --no-network-policy </dev/null >'$work/last.log' 2>&1 &&
|
||||
|
||||
Reference in new issue
Block a user