Skip to content

Commit 0ae2616

Browse files
chore: rename WithUserName and WithWorkspaceName to WithManifestInfo
1 parent 336997b commit 0ae2616

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

agent/agentcontainers/api.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type API struct {
6464
subAgentURL string
6565
subAgentEnv []string
6666

67-
userName string
67+
ownerName string
6868
workspaceName string
6969

7070
mu sync.RWMutex
@@ -156,17 +156,12 @@ func WithSubAgentEnv(env ...string) Option {
156156
}
157157
}
158158

159-
// WithWorkspaceName sets the workspace name for the sub-agent.
160-
func WithWorkspaceName(name string) Option {
159+
// WithManifestInfo sets the owner name, and workspace name
160+
// for the sub-agent.
161+
func WithManifestInfo(owner, workspace string) Option {
161162
return func(api *API) {
162-
api.workspaceName = name
163-
}
164-
}
165-
166-
// WithUserName sets the user name for the sub-agent.
167-
func WithUserName(name string) Option {
168-
return func(api *API) {
169-
api.userName = name
163+
api.ownerName = owner
164+
api.workspaceName = workspace
170165
}
171166
}
172167

@@ -1149,7 +1144,7 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c
11491144
if config, err := api.dccli.ReadConfig(ctx, dc.WorkspaceFolder, dc.ConfigPath,
11501145
[]string{
11511146
fmt.Sprintf("CODER_WORKSPACE_AGENT_NAME=%s", dc.Name),
1152-
fmt.Sprintf("CODER_WORKSPACE_OWNER_NAME=%s", api.userName),
1147+
fmt.Sprintf("CODER_WORKSPACE_OWNER_NAME=%s", api.ownerName),
11531148
fmt.Sprintf("CODER_WORKSPACE_NAME=%s", api.workspaceName),
11541149
fmt.Sprintf("CODER_URL=%s", api.subAgentURL),
11551150
},

agent/agentcontainers/api_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,7 @@ func TestAPI(t *testing.T) {
12941294
agentcontainers.WithSubAgentClient(fakeSAC),
12951295
agentcontainers.WithSubAgentURL("test-subagent-url"),
12961296
agentcontainers.WithDevcontainerCLI(fakeDCCLI),
1297-
agentcontainers.WithUserName("test-user"),
1298-
agentcontainers.WithWorkspaceName("test-workspace"),
1297+
agentcontainers.WithManifestInfo("test-user", "test-workspace"),
12991298
)
13001299
apiClose := func() {
13011300
closeOnce.Do(func() {

agent/api.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ func (a *agent) apiHandler(aAPI proto.DRPCAgentClient26) (http.Handler, func() e
5151
manifest := a.manifest.Load()
5252
if manifest != nil {
5353
containerAPIOpts = append(containerAPIOpts,
54-
agentcontainers.WithUserName(manifest.OwnerName),
55-
agentcontainers.WithWorkspaceName(manifest.WorkspaceName),
54+
agentcontainers.WithManifestInfo(manifest.OwnerName, manifest.WorkspaceName),
5655
)
5756

5857
if len(manifest.Devcontainers) > 0 {

0 commit comments

Comments
 (0)