MCPcopy Index your code
hub / github.com/coder/coder / ResolveWorkspaceHome

Function ResolveWorkspaceHome

coderd/x/chatd/chattool/planpath.go:21–43  ·  view source on GitHub ↗

ResolveWorkspaceHome returns the workspace user's home directory.

(
	ctx context.Context,
	conn workspacesdk.AgentConn,
)

Source from the content-addressed store, hash-verified

19
20// ResolveWorkspaceHome returns the workspace user's home directory.
21func ResolveWorkspaceHome(
22 ctx context.Context,
23 conn workspacesdk.AgentConn,
24) (string, error) {
25 if conn == nil {
26 return "", xerrors.New("workspace connection is required")
27 }
28
29 resp, err := conn.LS(ctx, "", workspacesdk.LSRequest{
30 Path: []string{},
31 Relativity: workspacesdk.LSRelativityHome,
32 })
33 if err != nil {
34 return "", xerrors.Errorf("resolve workspace home: %w", err)
35 }
36
37 home := strings.TrimSpace(resp.AbsolutePathString)
38 if home == "" {
39 return "", xerrors.New("workspace home path is empty")
40 }
41
42 return home, nil
43}
44
45// PlanPathForChat returns the per-chat plan file path rooted in the
46// workspace home directory.

Callers 2

runChatMethod · 0.92
TestResolveWorkspaceHomeFunction · 0.92

Calls 3

NewMethod · 0.65
LSMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestResolveWorkspaceHomeFunction · 0.74