Skip to content

feat(agent/agentcontainers): add Exec method to devcontainers CLI #18244

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 2 commits into from
Jun 6, 2025

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jun 5, 2025

@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-2 branch from dda97d9 to 2984d4e Compare June 5, 2025 12:50
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-3 branch from d49f84e to 011a8aa Compare June 5, 2025 12:51
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-2 branch 2 times, most recently from ae52380 to 5cf4ae7 Compare June 5, 2025 13:58
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-3 branch from 011a8aa to 63f93bc Compare June 5, 2025 13:59
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-2 branch from 5cf4ae7 to 2dc395d Compare June 6, 2025 08:44
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-3 branch from 63f93bc to 0deaab8 Compare June 6, 2025 08:44
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-2 branch from 2dc395d to ea0125d Compare June 6, 2025 09:25
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-3 branch from 0deaab8 to 8796ba3 Compare June 6, 2025 09:30
@mafredri mafredri marked this pull request as ready for review June 6, 2025 09:39
Comment on lines 45 to 84
// WithContainerID sets the container ID to target a specific container.
// Can only be used with the Exec command.
func WithContainerID(id string) DevcontainerCLIOptions {
return func(o *devcontainerCLIUpConfig) {
if o.command != "exec" {
panic("developer error: WithContainerID can only be used with the Exec command")
}
o.args = append(o.args, "--container-id", id)
}
}

// WithRemoteEnv sets environment variables for the Exec command.
// Can only be used with the Exec command.
func WithRemoteEnv(env ...string) DevcontainerCLIOptions {
return func(o *devcontainerCLIUpConfig) {
if o.command != "exec" {
panic("developer error: WithRemoteEnv can only be used with the Exec command")
}
for _, e := range env {
o.args = append(o.args, "--remote-env", e)
}
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Given that these two options can only be used with devcontainer exec, I think it makes more sense to keep them as a different type. I like the idea of having the uniform signature of ...DevcontainerCLIOptions but this is offset by potential run-time errors instead of compile-time errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, agreed, I'll change it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in adbfd45

Base automatically changed from mafredri/feat-agent-devcontainer-injection-2 to main June 6, 2025 10:33
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-3 branch from 8796ba3 to adbfd45 Compare June 6, 2025 11:20
@mafredri mafredri merged commit 709f374 into main Jun 6, 2025
34 checks passed
@mafredri mafredri deleted the mafredri/feat-agent-devcontainer-injection-3 branch June 6, 2025 11:39
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 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.

3 participants