Skip to content

feat(cli): support opening devcontainers in vscode #17189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 3, 2025

Conversation

DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Apr 1, 2025

Closes #16427

Adds the option -c,--container to open vscode that allows opening VSCode into a running devcontainer.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for opening development containers in VS Code via the CLI. Key changes include:

  • Updating the CLI documentation to include a new flag (-c, --container) for specifying the container name.
  • Adding tests to cover various scenarios for opening VS Code in dev container mode.
  • Updating the CLI command implementation to handle container-based logic and URL link generation for dev containers.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
docs/reference/cli/open_vscode.md Added documentation for the new container flag.
cli/open_test.go Introduced new tests for dev container support and behavior.
cli/open.go Implemented container flag handling and URL building tailored for dev containers.
Files not reviewed (1)
  • cli/testdata/coder_open_vscode_--help.golden: Language not supported
Comments suppressed due to low confidence (1)

cli/open.go:145

  • Consider including the specified container name in the error message (e.g., 'no container found matching ') for improved clarity.
if (!foundContainer) {

@DanielleMaywood DanielleMaywood force-pushed the dm-open-devcontainer-cli branch from fe73989 to e8479f6 Compare April 2, 2025 08:22
@DanielleMaywood DanielleMaywood force-pushed the dm-open-devcontainer-cli branch from e8479f6 to 9cc49f8 Compare April 3, 2025 08:07
@DanielleMaywood DanielleMaywood marked this pull request as ready for review April 3, 2025 08:08
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests!

cli/open.go Outdated
Comment on lines 131 to 133
if !ok {
return xerrors.New("container missing `devcontainer.local_folder` label")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't happen in theory, but no harm to check.

- Invert an if-condition to reduce how nested the code was.
- Hide `-c` flag for now
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change and tests!

@DanielleMaywood DanielleMaywood merged commit aa3d71d into main Apr 3, 2025
34 checks passed
@DanielleMaywood DanielleMaywood deleted the dm-open-devcontainer-cli branch April 3, 2025 09:21
@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: support coder open vscode <workspace> -c devcontainer
3 participants