Add support for the extends keyword - #1306
Draft
Sam Frost (SamuelFrost) wants to merge 1 commit into
Draft
Sam Frost (SamuelFrost) wants to merge 1 commit into
Sam Frost (SamuelFrost) wants to merge 1 commit into
Conversation
Allow one devcontainer.json to inherit another using the existing image metadata merge logic, rebasing the approach from spec#22 and CLI#311 onto current main.
|
Sam Frost (@SamuelFrost) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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.
(note for reviewers: this is vibe coded based off the existing PR and issues. I have not reviewed it yet beyond minimal local testing-- hence the draft status)
Summary
Implements configuration inheritance from spec#22: a
devcontainer.jsoncan inherit another JSON or JSONC file in the same repository viaextends.This reapplies PR #311 on current
main. That branch could not be rebased as a delta. The merge path follows the review on #311: use the image metadata merge logic, notdeepmerge.Companion spec PR: devcontainers/spec#772
Does not bump the package version. That belongs in a later release PR.
Changes
extends?: stringon thedevcontainer.jsonconfig types.extendswhen reading configuration: relative paths only, recursive, with cycle detection. Absolute paths and URLs are rejected.forwardPorts/capAddunion,hostRequirementsmax, last-wins for scalars,init/privilegedtrue if any value is true). Stripextendsfrom the result.CHANGELOG.mdwithout cutting a version.Technical choices
#311 used
deepmerge. Christof Marti, Josh Spicer, and Chuck Lantz asked to reuse image metadata merge so extending a file matches combining a prebuilt image’s metadata with a projectdevcontainer.json.mergeDevContainerConfigsinimageMetadata.tsis that shared path.Relative-path-only matches the spec issue (same repository). Recursive
extendsis included with cycle detection; #311 left nested references unresolved.Validation
src/test/configContainer.test.ts: 6 passing (read a basic file, resolveextends, nestedextends, cyclic reference, missing file, merge overlap).yarn type-checkyarn lintdevcontainer upwas not run as part of this change.read-configurationagainst a file that extends another produces the merged config and omitsextends.Follow-up
After maintainers are on board,
CONTRIBUTING.mdasks for a docs PR to the devcontainer.json reference in vscode-docs.Implements spec#22. Supersedes #311.