Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
859 changes: 434 additions & 425 deletions agent/proto/agent.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions agent/proto/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ message WorkspaceAgentDevcontainer {
bytes id = 1;
string workspace_folder = 2;
string config_path = 3;
string name = 4;
}

message GetManifestRequest {}
Expand Down
1 change: 1 addition & 0 deletions coderd/agentapi/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func dbAgentDevcontainersToProto(devcontainers []database.WorkspaceAgentDevconta
for i, dc := range devcontainers {
ret[i] = &agentproto.WorkspaceAgentDevcontainer{
Id: dc.ID[:],
Name: dc.Name,
WorkspaceFolder: dc.WorkspaceFolder,
ConfigPath: dc.ConfigPath,
}
Expand Down
4 changes: 4 additions & 0 deletions coderd/agentapi/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ func TestGetManifest(t *testing.T) {
devcontainers = []database.WorkspaceAgentDevcontainer{
{
ID: uuid.New(),
Name: "cool",
WorkspaceAgentID: agent.ID,
WorkspaceFolder: "/cool/folder",
},
{
ID: uuid.New(),
Name: "another",
WorkspaceAgentID: agent.ID,
WorkspaceFolder: "/another/cool/folder",
ConfigPath: "/another/cool/folder/.devcontainer/devcontainer.json",
Expand Down Expand Up @@ -283,10 +285,12 @@ func TestGetManifest(t *testing.T) {
protoDevcontainers = []*agentproto.WorkspaceAgentDevcontainer{
{
Id: devcontainers[0].ID[:],
Name: devcontainers[0].Name,
WorkspaceFolder: devcontainers[0].WorkspaceFolder,
},
{
Id: devcontainers[1].ID[:],
Name: devcontainers[1].Name,
WorkspaceFolder: devcontainers[1].WorkspaceFolder,
ConfigPath: devcontainers[1].ConfigPath,
},
Expand Down
1 change: 1 addition & 0 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ func WorkspaceAgentDevcontainer(t testing.TB, db database.Store, orig database.W
WorkspaceAgentID: takeFirst(orig.WorkspaceAgentID, uuid.New()),
CreatedAt: takeFirst(orig.CreatedAt, dbtime.Now()),
ID: []uuid.UUID{takeFirst(orig.ID, uuid.New())},
Name: []string{takeFirst(orig.Name, testutil.GetRandomName(t))},
WorkspaceFolder: []string{takeFirst(orig.WorkspaceFolder, "/workspace")},
ConfigPath: []string{takeFirst(orig.ConfigPath, "")},
})
Expand Down
1 change: 1 addition & 0 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -9171,6 +9171,7 @@ func (q *FakeQuerier) InsertWorkspaceAgentDevcontainers(_ context.Context, arg d
WorkspaceAgentID: arg.WorkspaceAgentID,
CreatedAt: arg.CreatedAt,
ID: id,
Name: arg.Name[i],
WorkspaceFolder: arg.WorkspaceFolder[i],
ConfigPath: arg.ConfigPath[i],
})
Expand Down
5 changes: 4 additions & 1 deletion coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE workspace_agent_devcontainers DROP COLUMN name;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE workspace_agent_devcontainers ADD COLUMN name TEXT NOT NULL DEFAULT '';
ALTER TABLE workspace_agent_devcontainers ALTER COLUMN name DROP DEFAULT;

COMMENT ON COLUMN workspace_agent_devcontainers.name IS 'The name of the Dev Container.';
2 changes: 2 additions & 0 deletions coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion coderd/database/queries/workspaceagentdevcontainers.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
-- name: InsertWorkspaceAgentDevcontainers :many
INSERT INTO
workspace_agent_devcontainers (workspace_agent_id, created_at, id, workspace_folder, config_path)
workspace_agent_devcontainers (workspace_agent_id, created_at, id, name, workspace_folder, config_path)
SELECT
@workspace_agent_id::uuid AS workspace_agent_id,
@created_at::timestamptz AS created_at,
unnest(@id::uuid[]) AS id,
unnest(@name::text[]) AS name,
unnest(@workspace_folder::text[]) AS workspace_folder,
unnest(@config_path::text[]) AS config_path
RETURNING workspace_agent_devcontainers.*;
Expand Down
21 changes: 12 additions & 9 deletions coderd/provisionerdserver/provisionerdserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2110,22 +2110,25 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.

if devcontainers := prAgent.GetDevcontainers(); len(devcontainers) > 0 {
var (
devContainerIDs = make([]uuid.UUID, 0, len(devcontainers))
devContainerWorkspaceFolders = make([]string, 0, len(devcontainers))
devContainerConfigPaths = make([]string, 0, len(devcontainers))
devcontainerIDs = make([]uuid.UUID, 0, len(devcontainers))
devcontainerNames = make([]string, 0, len(devcontainers))
devcontainerWorkspaceFolders = make([]string, 0, len(devcontainers))
devcontainerConfigPaths = make([]string, 0, len(devcontainers))
)
for _, dc := range devcontainers {
devContainerIDs = append(devContainerIDs, uuid.New())
devContainerWorkspaceFolders = append(devContainerWorkspaceFolders, dc.WorkspaceFolder)
devContainerConfigPaths = append(devContainerConfigPaths, dc.ConfigPath)
devcontainerIDs = append(devcontainerIDs, uuid.New())
devcontainerNames = append(devcontainerNames, dc.Name)
devcontainerWorkspaceFolders = append(devcontainerWorkspaceFolders, dc.WorkspaceFolder)
devcontainerConfigPaths = append(devcontainerConfigPaths, dc.ConfigPath)
}

_, err = db.InsertWorkspaceAgentDevcontainers(ctx, database.InsertWorkspaceAgentDevcontainersParams{
WorkspaceAgentID: agentID,
CreatedAt: dbtime.Now(),
ID: devContainerIDs,
WorkspaceFolder: devContainerWorkspaceFolders,
ConfigPath: devContainerConfigPaths,
ID: devcontainerIDs,
Name: devcontainerNames,
WorkspaceFolder: devcontainerWorkspaceFolders,
ConfigPath: devcontainerConfigPaths,
})
if err != nil {
return xerrors.Errorf("insert agent devcontainer: %w", err)
Expand Down
7 changes: 5 additions & 2 deletions coderd/provisionerdserver/provisionerdserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2204,8 +2204,8 @@ func TestInsertWorkspaceResource(t *testing.T) {
Agents: []*sdkproto.Agent{{
Name: "dev",
Devcontainers: []*sdkproto.Devcontainer{
{WorkspaceFolder: "/workspace1"},
{WorkspaceFolder: "/workspace2", ConfigPath: "/workspace2/.devcontainer/devcontainer.json"},
{Name: "foo", WorkspaceFolder: "/workspace1"},
{Name: "bar", WorkspaceFolder: "/workspace2", ConfigPath: "/workspace2/.devcontainer/devcontainer.json"},
},
}},
})
Expand All @@ -2220,7 +2220,10 @@ func TestInsertWorkspaceResource(t *testing.T) {
devcontainers, err := db.GetWorkspaceAgentDevcontainersByAgentID(ctx, agent.ID)
require.NoError(t, err)
require.Len(t, devcontainers, 2)
require.Equal(t, "foo", devcontainers[0].Name)
require.Equal(t, "/workspace1", devcontainers[0].WorkspaceFolder)
require.Equal(t, "", devcontainers[0].ConfigPath)
require.Equal(t, "bar", devcontainers[1].Name)
require.Equal(t, "/workspace2", devcontainers[1].WorkspaceFolder)
require.Equal(t, "/workspace2/.devcontainer/devcontainer.json", devcontainers[1].ConfigPath)
})
Expand Down
2 changes: 2 additions & 0 deletions codersdk/agentsdk/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ func DevcontainerFromProto(pdc *proto.WorkspaceAgentDevcontainer) (codersdk.Work
}
return codersdk.WorkspaceAgentDevcontainer{
ID: id,
Name: pdc.Name,
WorkspaceFolder: pdc.WorkspaceFolder,
ConfigPath: pdc.ConfigPath,
}, nil
Expand All @@ -466,6 +467,7 @@ func ProtoFromDevcontainers(dcs []codersdk.WorkspaceAgentDevcontainer) []*proto.
func ProtoFromDevcontainer(dc codersdk.WorkspaceAgentDevcontainer) *proto.WorkspaceAgentDevcontainer {
return &proto.WorkspaceAgentDevcontainer{
Id: dc.ID[:],
Name: dc.Name,
WorkspaceFolder: dc.WorkspaceFolder,
ConfigPath: dc.ConfigPath,
}
Expand Down
1 change: 1 addition & 0 deletions codersdk/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ func (c *Client) WorkspaceAgentListeningPorts(ctx context.Context, agentID uuid.
// configuration in a workspace that is visible to the workspace agent.
type WorkspaceAgentDevcontainer struct {
ID uuid.UUID `json:"id" format:"uuid"`
Name string `json:"name"`
WorkspaceFolder string `json:"workspace_folder"`
ConfigPath string `json:"config_path,omitempty"`
}
Expand Down
1 change: 1 addition & 0 deletions provisioner/terraform/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
continue
}
agent.Devcontainers = append(agent.Devcontainers, &proto.Devcontainer{
Name: resource.Name,
WorkspaceFolder: attrs.WorkspaceFolder,
ConfigPath: attrs.ConfigPath,
})
Expand Down
4 changes: 3 additions & 1 deletion provisioner/terraform/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,9 +845,11 @@ func TestConvertResources(t *testing.T) {
ResourcesMonitoring: &proto.ResourcesMonitoring{},
Devcontainers: []*proto.Devcontainer{
{
Name: "dev1",
WorkspaceFolder: "/workspace1",
},
{
Name: "dev2",
WorkspaceFolder: "/workspace2",
ConfigPath: "/workspace2/.devcontainer/devcontainer.json",
},
Expand Down Expand Up @@ -1404,7 +1406,7 @@ func sortResources(resources []*proto.Resource) {
return agent.Scripts[i].DisplayName < agent.Scripts[j].DisplayName
})
sort.Slice(agent.Devcontainers, func(i, j int) bool {
return agent.Devcontainers[i].WorkspaceFolder < agent.Devcontainers[j].WorkspaceFolder
return agent.Devcontainers[i].Name < agent.Devcontainers[j].Name
})
}
sort.Slice(resource.Agents, func(i, j int) bool {
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy