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

Commit3467d3a

Browse files
committed
Add helper for getting workspace by normalized name
1 parent3571405 commit3467d3a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎codersdk/toolsdk/toolsdk.go‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,8 +1861,7 @@ var DeleteTask = Tool[DeleteTaskArgs, codersdk.Response]{
18611861
}
18621862
owner=task.OwnerName
18631863
}else {
1864-
workspaceName:=NormalizeWorkspaceInput(args.TaskID)
1865-
ws,err:=namedWorkspace(ctx,deps.coderClient,workspaceName)
1864+
ws,err:=normalizedNamedWorkspace(ctx,deps.coderClient,args.TaskID)
18661865
iferr!=nil {
18671866
return codersdk.Response{},xerrors.Errorf("get task workspace %q: %w",args.TaskID,err)
18681867
}
@@ -1962,8 +1961,7 @@ var GetTaskStatus = Tool[GetTaskStatusArgs, GetTaskStatusResponse]{
19621961

19631962
id,err:=uuid.Parse(args.TaskID)
19641963
iferr!=nil {
1965-
workspaceName:=NormalizeWorkspaceInput(args.TaskID)
1966-
ws,err:=namedWorkspace(ctx,deps.coderClient,workspaceName)
1964+
ws,err:=normalizedNamedWorkspace(ctx,deps.coderClient,args.TaskID)
19671965
iferr!=nil {
19681966
returnGetTaskStatusResponse{},xerrors.Errorf("get task workspace %q: %w",args.TaskID,err)
19691967
}
@@ -1982,6 +1980,13 @@ var GetTaskStatus = Tool[GetTaskStatusArgs, GetTaskStatusResponse]{
19821980
},
19831981
}
19841982

1983+
// normalizedNamedWorkspace normalizes the workspace name before getting the
1984+
// workspace by name.
1985+
funcnormalizedNamedWorkspace(ctx context.Context,client*codersdk.Client,namestring) (codersdk.Workspace,error) {
1986+
// Maybe namedWorkspace should itself call NormalizeWorkspaceInput?
1987+
returnnamedWorkspace(ctx,client,NormalizeWorkspaceInput(name))
1988+
}
1989+
19851990
// NormalizeWorkspaceInput converts workspace name input to standard format.
19861991
// Handles the following input formats:
19871992
// - workspace → workspace

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp