feat(cmd): add --additional-features flag for transparent feature injection#626
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a new CLI flag Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as "CLI (build/up)"
participant Cmd as "BuildCmd/UpCmd"
participant Runner as "Runner.substitute"
participant Config as "parsedConfig"
User->>CLI: invoke build/up with --additional-features JSON
CLI->>Cmd: set AdditionalFeatures field
Cmd->>Runner: call substitute with CLI options
Runner->>Config: load base devcontainer config
alt AdditionalFeatures not empty
Runner->>Runner: parse JSON into map
Runner->>Config: ensure Features map initialized
Runner->>Config: merge parsed features into parsedConfig.Features
Runner->>CLI: log merged feature count/keys
end
Runner->>Config: continue substitution with merged config
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/devcontainer/config.go`:
- Around line 209-213: The current r.Log.Infof call logs the entire
additionalFeatures map which may leak sensitive values; update the logging in
pkg/devcontainer/config.go to avoid printing the raw payload by removing the
full map from the message and either log only the count
(len(additionalFeatures)) or a sanitized list of keys (not values). Locate the
r.Log.Infof invocation referencing additionalFeatures and change it to emit a
message like "Merged %d additional feature(s)" with len(additionalFeatures) (or
a scrubbed set of keys), ensuring additionalFeatures' values are never included
in logs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 60261294-919e-4577-868c-a513200e515f
📒 Files selected for processing (5)
cmd/build.gocmd/up.gopkg/devcontainer/config.gopkg/devcontainer/config_test.gopkg/provider/workspace.go
bd6730a to
1f6d9ab
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/devcontainer/config_test.go (1)
195-199: Consider asserting original feature options are preserved.The merge test verifies both feature keys exist, but doesn't confirm the original feature's options (
{"version": "20"}) remain intact after the merge. This would strengthen coverage against accidental mutation.💡 Proposed enhancement
s.NoError(err) s.Len(result.Config.Features, 2) s.Contains(result.Config.Features, "ghcr.io/devcontainers/features/node:1") s.Contains(result.Config.Features, "ghcr.io/devcontainers/features/git:1") + nodeOpts, ok := result.Config.Features["ghcr.io/devcontainers/features/node:1"].(map[string]any) + s.True(ok) + s.Equal("20", nodeOpts["version"])🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/devcontainer/config_test.go` around lines 195 - 199, Add an assertion to the test that verifies the original feature options are preserved after the merge: check the merged config's feature entry for the node feature (accessing result.Config.Features or the structure that holds per-feature options) and assert its options still include the original {"version":"20"} value (or equality to the original options object). Locate the test that currently asserts s.Len(result.Config.Features, 2) / s.Contains(...) and add a precise assertion against the node feature's options to ensure they weren't mutated during merge.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/devcontainer/config_test.go`:
- Around line 218-220: The current test does a non-fatal type assertion into
nodeOpts from result.Config.Features["ghcr.io/devcontainers/features/node:1"]
and then uses s.True(ok) which won't stop execution on failure, causing a nil
map panic when accessing nodeOpts["version"]; change the assertion to a fatal
check using s.Require().True(ok) (or otherwise short-circuit the test) before
accessing nodeOpts, referencing the variables and map lookup used in the snippet
(result.Config.Features and nodeOpts) so the test halts if the type assertion
fails.
---
Nitpick comments:
In `@pkg/devcontainer/config_test.go`:
- Around line 195-199: Add an assertion to the test that verifies the original
feature options are preserved after the merge: check the merged config's feature
entry for the node feature (accessing result.Config.Features or the structure
that holds per-feature options) and assert its options still include the
original {"version":"20"} value (or equality to the original options object).
Locate the test that currently asserts s.Len(result.Config.Features, 2) /
s.Contains(...) and add a precise assertion against the node feature's options
to ensure they weren't mutated during merge.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b0616a26-4f25-41bf-80b1-2f48f382ab3b
📒 Files selected for processing (1)
pkg/devcontainer/config_test.go
|
Sorry about the force push. My agent got cute. |
…ection Add `--additional-features` CLI flag to `devpod up` and `devpod build` that accepts a JSON object matching the devcontainer.json `features` schema. Features supplied via the flag are merged into the resolved devcontainer config during variable substitution, with CLI values taking precedence over config-file values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoid leaking potentially sensitive feature option values into logs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1d7f772 to
b69b1c7
Compare
The devcontainer CLI supports
--additional-featuresto inject features at build time without modifying project files. DevPod doesn't expose this, so users who want a consistent set of tools across workspaces must either modify each project's devcontainer.json or rely on--dotfiles, which runs post-build and misses Docker layer caching.This adds
--additional-featuresto theupandbuildcommands. The flag accepts a JSON object matching the devcontainer.json "features" schema, which is serialized through the workspace-info tunnel and merged into the resolved config on the agent side before feature resolution.Example:
Summary by CodeRabbit
New Features
Tests