Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba898b9

Browse files
committed
rm copypasta
1 parent9127d62 commitba898b9

File tree

1 file changed

+7
-29
lines changed

1 file changed

+7
-29
lines changed

‎mcp/tools/tools_coder.go

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,9 @@ func handleCoderWorkspaceExec(client *codersdk.Client) mcpserver.ToolHandlerFunc
214214

215215
// Attempt to fetch the workspace. We may get a UUID or a name, so try to
216216
// handle both.
217-
varws codersdk.Workspace
218-
ifwsid,err:=uuid.Parse(wsArg);err==nil {
219-
ws,err=client.Workspace(ctx,wsid)
220-
iferr!=nil {
221-
returnnil,xerrors.Errorf("failed to fetch workspace: %w",err)
222-
}
223-
}else {
224-
owner,workspaceName,err:=splitNamedWorkspace(wsArg)
225-
iferr!=nil {
226-
returnnil,xerrors.Errorf("failed to split workspace name: %w",err)
227-
}
228-
ws,err=client.WorkspaceByOwnerAndName(ctx,owner,workspaceName, codersdk.WorkspaceOptions{})
229-
iferr!=nil {
230-
returnnil,xerrors.Errorf("failed to fetch workspace: %w",err)
231-
}
217+
ws,err:=getWorkspaceByIDOrOwnerName(ctx,client,wsArg)
218+
iferr!=nil {
219+
returnnil,xerrors.Errorf("failed to fetch workspace: %w",err)
232220
}
233221

234222
// Ensure the workspace is started.
@@ -277,19 +265,9 @@ func handleCoderWorkspaceExec(client *codersdk.Client) mcpserver.ToolHandlerFunc
277265
}
278266
}
279267

280-
// COPYPASTA: from cli/root.go
281-
funcsplitNamedWorkspace(identifierstring) (ownerstring,workspaceNamestring,errerror) {
282-
parts:=strings.Split(identifier,"/")
283-
284-
switchlen(parts) {
285-
case1:
286-
owner=codersdk.Me
287-
workspaceName=parts[0]
288-
case2:
289-
owner=parts[0]
290-
workspaceName=parts[1]
291-
default:
292-
return"","",xerrors.Errorf("invalid workspace name: %q should be in the format <workspace> or <owner>/<workspace>",identifier)
268+
funcgetWorkspaceByIDOrOwnerName(ctx context.Context,client*codersdk.Client,identifierstring) (codersdk.Workspace,error) {
269+
ifwsid,err:=uuid.Parse(identifier);err==nil {
270+
returnclient.Workspace(ctx,wsid)
293271
}
294-
returnowner,workspaceName,nil
272+
returnclient.WorkspaceByOwnerAndName(ctx,codersdk.Me,identifier, codersdk.WorkspaceOptions{})
295273
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp