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

Commitf86a119

Browse files
committed
chore: move getServerURL under Deps
1 parentec57659 commitf86a119

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

‎codersdk/toolsdk/chatgpt.go‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ import (
1414
"github.com/coder/coder/v2/codersdk"
1515
)
1616

17-
funcgetServerURL(depsDeps)string {
18-
serverURLCopy:=*deps.coderClient.URL
19-
serverURLCopy.Path=""
20-
serverURLCopy.RawQuery=""
21-
returnserverURLCopy.String()
22-
}
23-
2417
typeObjectTypestring
2518

2619
const (
@@ -56,7 +49,7 @@ func createObjectID(objectType ObjectType, id string) ObjectID {
5649
}
5750

5851
funcsearchTemplates(ctx context.Context,depsDeps,querystring) ([]SearchResultItem,error) {
59-
serverURL:=getServerURL(deps)
52+
serverURL:=deps.getServerURL()
6053
templates,err:=deps.coderClient.Templates(ctx, codersdk.TemplateFilter{
6154
SearchQuery:query,
6255
})
@@ -76,7 +69,7 @@ func searchTemplates(ctx context.Context, deps Deps, query string) ([]SearchResu
7669
}
7770

7871
funcsearchWorkspaces(ctx context.Context,depsDeps,querystring) ([]SearchResultItem,error) {
79-
serverURL:=getServerURL(deps)
72+
serverURL:=deps.getServerURL()
8073
workspaces,err:=deps.coderClient.Workspaces(ctx, codersdk.WorkspaceFilter{
8174
FilterQuery:query,
8275
})
@@ -351,7 +344,7 @@ func fetchWorkspace(ctx context.Context, deps Deps, workspaceID string) (FetchRe
351344
ID:workspace.ID.String(),
352345
Title:workspace.Name,
353346
Text:string(workspaceJSON),
354-
URL:fmt.Sprintf("%s/%s/%s",getServerURL(deps),workspace.OwnerName,workspace.Name),
347+
URL:fmt.Sprintf("%s/%s/%s",deps.getServerURL(),workspace.OwnerName,workspace.Name),
355348
},nil
356349
}
357350

@@ -372,7 +365,7 @@ func fetchTemplate(ctx context.Context, deps Deps, templateID string) (FetchResu
372365
ID:template.ID.String(),
373366
Title:template.DisplayName,
374367
Text:string(templateJSON),
375-
URL:fmt.Sprintf("%s/templates/%s/%s",getServerURL(deps),template.OrganizationName,template.Name),
368+
URL:fmt.Sprintf("%s/templates/%s/%s",deps.getServerURL(),template.OrganizationName,template.Name),
376369
},nil
377370
}
378371

‎codersdk/toolsdk/toolsdk.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ type Deps struct {
5858
reportfunc(ReportTaskArgs)error
5959
}
6060

61+
func (dDeps)getServerURL()string {
62+
serverURLCopy:=*d.coderClient.URL
63+
serverURLCopy.Path=""
64+
serverURLCopy.RawQuery=""
65+
returnserverURLCopy.String()
66+
}
67+
6168
funcWithTaskReporter(fnfunc(ReportTaskArgs)error)func(*Deps) {
6269
returnfunc(d*Deps) {
6370
d.report=fn

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp