feat(workspace): multi-root support via a ws command - #2
Merged
Conversation
The container already mounted /workspace as a named volume rather than a bind mount of a single folder, which makes every repository cloned under it a sub-folder of the workspace file - the layout VS Code requires for a multi-root workspace. What was missing was the workspace file itself and a way to manage it. `ws` clones repositories into /workspace and maintains the folders array in /workspace/devops.code-workspace. postCreateCommand runs `ws init` so a fresh container comes up multi-root-capable with no setup. Also rewrites the README opening around the multi-root capability, which is the thing that distinguishes this image from a stock devcontainer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds multi-root workspace support: one container, several repositories open in one VS Code window.
wscommand at/usr/local/bin/ws-init,add,rm,listpostCreateCommandrunsws init, so a fresh container is multi-root-capable with no setupwsentry invalidate-tools.shand a CHANGELOG noteWhy this works here
/workspacewas already a named volume rather than a bind mount of one folder, so anything cloned under it is a sub-folder of the workspace file. That is exactly what VS Code requires: a multi-root workspace may only reference "relative paths to sub-folders of the folder the.code-workspacefile is in". Parent-relative paths (../other-repo) do not open, which is why the usual sibling-folders-on-the-host layout fails.So the architecture was already right - the workspace file and a way to manage it were the missing pieces.
The sales point
A DevOps change is rarely one repository: the Terraform module, the environment consuming it, the Ansible role, the pipeline shipping it. Today that is four windows and four containers. This makes it one Source Control panel across every repo, one search, one toolchain.
Known limitation, documented in the README
All roots share the one container - VS Code cannot run a container per folder in a single window, and that is an open upstream feature request. Suits a team on one toolchain; does not suit polyglot repos needing different runtimes.
Verification
shellcheck .devcontainer/files/workspace/ws- cleanmarkdownlint-cli@0.38.0(the pinned pre-commit version) on README and CHANGELOG - cleandevcontainer.jsonparses after comment stripping;postCreateCommandverifiedwsexercised end to end outside the container:initon empty and populated roots,addvia URL clone and existing directory, idempotent re-add,rm,list, and the error paths (add before init, rm of a non-root)Not yet run inside a built image - CI builds both architectures and runs
validate-tools.sh, which now coversws.