10000 feat(agent/agentcontainers): add devcontainers list endpoint by mafredri · Pull Request #17389 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat(agent/agentcontainers): add devcontainers list endpoint #17389

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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
< 8000 span class="Skeleton d-inline-block" style="width:12px; height:12px;">
fix comments
  • Loading branch information
mafredri committed Apr 14, 2025
commit a34e202b1ccd4caa4deb2b8acceb5ce5fb7aa692
7 changes: 3 additions & 4 deletions agent/agentcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func WithDevcontainerCLI(dccli DevcontainerCLI) Option {
}
}

// WithDevcontainers sets the known devcontainers and scripts for the
// API. This allows allows the API to be aware of devcontainers defined
// in the workspace agent manifest.
// WithDevcontainers sets the known devcontainers for the API. This
// allows the API to be aware of devcontainers defined in the workspace
// agent manifest.
func WithDevcontainers(devcontainers []codersdk.WorkspaceAgentDevcontainer) Option {
return func(api *API) {
if len(devcontainers) > 0 {
Expand Down Expand Up @@ -195,7 +195,6 @@ func (api *API) getContainers(ctx context.Context) (codersdk.WorkspaceAgentListC
}

// If not in our known list, add as a runtime detected entry.
// Parse name from folder
name := path.Base(workspaceFolder)
if _, ok := api.devcontainerNames[name]; ok {
// Try to find a unique name by appending a number.
Expand Down
6 changes: 2 additions & 4 deletions agent/agentcontainers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestAPI(t *testing.T) {
ID: knownDevcontainerID2,
Name: "known-devcontainer-2",
WorkspaceFolder: "/workspace/known2",
// No config path intentionally
// No config path intentionally.
},
}

Expand Down Expand Up @@ -293,7 +293,6 @@ func TestAPI(t *testing.T) {
wantStatus: http.StatusOK,
wantCount: 3, // 2 known + 1 runtime
verify: func(t *testing.T, devcontainers []codersdk.WorkspaceAgentDevcontainer) {
// Find and verify devcontainers by workspace folder
known1 := mustFindDevcontainerByPath(t, devcontainers, "/workspace/known1")
known2 := mustFindDevcontainerByPath(t, devcontainers, "/workspace/known2")
runtime1 := mustFindDevcontainerByPath(t, devcontainers, "/workspace/runtime1")
Expand Down Expand Up @@ -373,7 +372,6 @@ func TestAPI(t *testing.T) {
wantStatus: http.StatusOK,
wantCount: 2,
verify: func(t *testing.T, devcontainers []codersdk.WorkspaceAgentDevcontainer) {
// Find devcontainer with ID matching knownDevcontainerID2
var dc2 *codersdk.WorkspaceAgentDevcontainer
for i := range devcontainers {
if devcontainers[i].ID == knownDevcontainerID2 {
Expand Down Expand Up @@ -484,7 +482,7 @@ func TestAPI(t *testing.T) {
// Verify the number of devcontainers in the response.
assert.Len(t, response.Devcontainers, tt.wantCount, "wrong number of devcontainers")

// Run custom verification if provided
// Run custom verification if provided.
if tt.verify != nil && len(response.Devcontainers) > 0 {
tt.verify(t, response.Devcontainers)
}
Expand Down
Loading
0