Repository navigation
Migrate devcontainer commands to flag handler - #2595
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2595 +/- ##
==========================================
+ Coverage 80.75% 80.81% +0.05%
==========================================
Files 1537 1537
Lines 145972 146003 +31
==========================================
+ Hits 117881 117991 +110
+ Misses 21490 21410 -80
- Partials 6601 6602 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughMigrates devcontainer subcommands to parsed flag configs, adds retry handling for custom command steps, introduces a reusable Colima setup action used by CI, and adds a Go formatting note to the contributor guide. ChangesParser infrastructure and devcontainer commands
Retry execution and Colima setup
Repository formatting guidance
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
🧹 Nitpick comments (1)
cmd/devcontainer/parse_test.go (1)
29-627: ⚡ Quick winConsider renaming
viperSettingstoflagSettingsin test tables.The test struct fields are still named
viperSettingsbut the implementation no longer uses Viper. Renaming toflagSettingswould better reflect the current ParsedConfig-based approach and improve code clarity.Example rename for one test
func TestParseAttachOptions(t *testing.T) { tests := []struct { name string - viperSettings map[string]interface{} + flagSettings map[string]interface{} expectedOptions *AttachOptions }{ { name: "default values", - viperSettings: map[string]interface{}{ + flagSettings: map[string]interface{}{ "instance": "default", "pty": false, }, // ... for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - opts := parseTestHelper(t, tt.viperSettings, parseAttachOptions) + opts := parseTestHelper(t, tt.flagSettings, parseAttachOptions)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/devcontainer/parse_test.go` around lines 29 - 627, Rename the test table field viperSettings to flagSettings across the TestParse* tables to reflect the ParsedConfig/flag-based approach: update the struct field name in each test slice (e.g., in TestParseAttachOptions, TestParseExecOptions, TestParseLogsOptions, TestParseRebuildOptions, TestParseRemoveOptions, TestParseStartOptions, TestParseStopOptions, TestParseShellOptions) and all references when calling parseTestHelper so the tests use tt.flagSettings instead of tt.viperSettings; keep the rest of the test logic and the parseTestHelper/parse* function calls unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/devcontainer/parse_test.go`:
- Around line 29-627: Rename the test table field viperSettings to flagSettings
across the TestParse* tables to reflect the ParsedConfig/flag-based approach:
update the struct field name in each test slice (e.g., in
TestParseAttachOptions, TestParseExecOptions, TestParseLogsOptions,
TestParseRebuildOptions, TestParseRemoveOptions, TestParseStartOptions,
TestParseStopOptions, TestParseShellOptions) and all references when calling
parseTestHelper so the tests use tt.flagSettings instead of tt.viperSettings;
keep the rest of the test logic and the parseTestHelper/parse* function calls
unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c29c44c4-d98e-4bc6-bbcf-26a6a8fe48a3
📒 Files selected for processing (12)
cmd/devcontainer/attach.gocmd/devcontainer/config.gocmd/devcontainer/exec.gocmd/devcontainer/helpers.gocmd/devcontainer/logs.gocmd/devcontainer/parse_test.gocmd/devcontainer/parser_test.gocmd/devcontainer/rebuild.gocmd/devcontainer/remove.gocmd/devcontainer/shell.gocmd/devcontainer/start.gocmd/devcontainer/stop.go
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/actions/setup-colima/action.yml:
- Around line 55-75: The Colima startup retry logic in setup-colima exceeds the
macOS step timeout because the two long colima start attempts plus
install/delete timeouts can consume the full budget before the second retry
runs. Update the retry budget in the action by either reducing the timeout
values in the run_with_timeout calls or increasing the step’s timeout-minutes,
keeping the behavior in the setup-colima action and the colima start retry loop
consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3a241e16-8f1c-4949-a110-5494989c32b4
📒 Files selected for processing (4)
.github/actions/setup-colima/action.yml.github/workflows/test.ymlcmd/cmd_utils.gocmd/custom_command_integration_test.go
There was a problem hiding this comment.
🧹 Nitpick comments (2)
cmd/custom_command_integration_test.go (1)
431-439: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate helper-command builders.
customCommandAttemptHelperCommandand the retry-mode counterpart differ only by the-test.run=target name. Consider a shared builder parameterized by the helper test name to avoid drift between the two.♻️ Proposed refactor
-func customCommandAttemptHelperCommand(t *testing.T, path string) string { - t.Helper() - - exe, err := os.Executable() - require.NoError(t, err) - encodedPath := base64.RawURLEncoding.EncodeToString([]byte(path)) - return fmt.Sprintf("%q -test.run=TestCustomCommandIntegrationAttemptHelper -- %s", exe, encodedPath) -} +func customCommandAttemptHelperCommand(t *testing.T, path string) string { + t.Helper() + return customCommandHelperCommand(t, "TestCustomCommandIntegrationAttemptHelper", path) +} + +func customCommandHelperCommand(t *testing.T, testName, path string) string { + t.Helper() + + exe, err := os.Executable() + require.NoError(t, err) + encodedPath := base64.RawURLEncoding.EncodeToString([]byte(path)) + return fmt.Sprintf("%q -test.run=%s -- %s", exe, testName, encodedPath) +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/custom_command_integration_test.go` around lines 431 - 439, The helper-command builders are duplicated and only differ by the `-test.run` target name. Refactor `customCommandAttemptHelperCommand` and the retry-mode builder into a shared helper that accepts the helper test name as a parameter, while keeping the existing `os.Executable`, base64 encoding, and command formatting logic in one place to prevent drift.cmd/devcontainer/parser_test.go (1)
348-349: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
require.ErrorIs/assert.ErrorIsover manualerrors.Is+assert.True.Testify's
ErrorIshelper gives clearer failure output than wrappingerrors.Isinassert.True.♻️ Proposed refactor
- err := tt.command.RunE(tt.command, tt.args) - require.Error(t, err) - assert.True(t, errors.Is(err, tt.wantErr), "got %v, want %v", err, tt.wantErr) + err := tt.command.RunE(tt.command, tt.args) + require.Error(t, err) + assert.ErrorIs(t, err, tt.wantErr)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/devcontainer/parser_test.go` around lines 348 - 349, The parser_test assertion is using manual errors.Is inside assert.True, which should be replaced with Testify’s ErrorIs helper for clearer failures. Update the check in the relevant test case to use require.ErrorIs or assert.ErrorIs on err and tt.wantErr, keeping the surrounding require.Error call only if still needed for setup. Use the existing test symbols like tt.wantErr and err in parser_test to locate and refactor the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@cmd/custom_command_integration_test.go`:
- Around line 431-439: The helper-command builders are duplicated and only
differ by the `-test.run` target name. Refactor
`customCommandAttemptHelperCommand` and the retry-mode builder into a shared
helper that accepts the helper test name as a parameter, while keeping the
existing `os.Executable`, base64 encoding, and command formatting logic in one
place to prevent drift.
In `@cmd/devcontainer/parser_test.go`:
- Around line 348-349: The parser_test assertion is using manual errors.Is
inside assert.True, which should be replaced with Testify’s ErrorIs helper for
clearer failures. Update the check in the relevant test case to use
require.ErrorIs or assert.ErrorIs on err and tt.wantErr, keeping the surrounding
require.Error call only if still needed for setup. Use the existing test symbols
like tt.wantErr and err in parser_test to locate and refactor the assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1b6ca6b6-0206-47ef-ad3c-41c8d7cad64d
📒 Files selected for processing (3)
.github/workflows/test.ymlcmd/custom_command_integration_test.gocmd/devcontainer/parser_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/test.yml
|
💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏 |
…flag-handler-usage # Conflicts: # .github/workflows/test.yml # cmd/cmd_utils.go # cmd/custom_command_integration_test.go
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cmd/custom_command_integration_test.go (1)
488-589: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdd a retry-exhaustion case. These tests cover success-after-retry and no-retry, but not the path where all attempts are exhausted and the shell step fails. A small table-driven setup could keep the retry scenarios together.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/custom_command_integration_test.go` around lines 488 - 589, Add a retry-exhaustion integration test for the shell-step retry flow in TestCustomCommandIntegration_RetriesShellStep and related custom command helpers. The current coverage only checks success after retries and the no-retry path, so add a case where the helper command keeps failing until MaxAttempts is reached and assert the step surfaces failure and stops retrying. Consider folding the retry scenarios into a small table-driven test around processCustomCommands/customCmd.Run so the retry-exhausted behavior lives alongside the existing retry cases.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@cmd/custom_command_integration_test.go`:
- Around line 488-589: Add a retry-exhaustion integration test for the
shell-step retry flow in TestCustomCommandIntegration_RetriesShellStep and
related custom command helpers. The current coverage only checks success after
retries and the no-retry path, so add a case where the helper command keeps
failing until MaxAttempts is reached and assert the step surfaces failure and
stops retrying. Consider folding the retry scenarios into a small table-driven
test around processCustomCommands/customCmd.Run so the retry-exhausted behavior
lives alongside the existing retry cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3bd74fe1-39ac-46de-ad87-5814599ccbf8
📒 Files selected for processing (4)
.github/workflows/test.ymlCLAUDE.mdcmd/cmd_utils.gocmd/custom_command_integration_test.go
✅ Files skipped from review due to trivial changes (1)
- CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (2)
- .github/workflows/test.yml
- cmd/cmd_utils.go
|
💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏 |
…flag-handler-usage # Conflicts: # .github/workflows/test.yml
|
💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏 |
…flag-handler-usage # Conflicts: # docs/prd/flag-handling/unified-flag-parsing.md
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.223.0-rc.4. |
what
flags.StandardFlagParser.flags.NewPositionalArgsBuilder.devcontainer execto preferexec <name> -- <command> [args...]while preserving the legacy no-separator form.exec --validation.why
args[0]/args[1:]handling bypassing positional and separated-arg parsing.--are preserved fordevcontainer exec.references
-- <args>passthrough to ansible-playbook #2594.