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

Method ResolvePath

codersdk/workspacesdk/agentconn.go:940–960  ·  view source on GitHub ↗

ResolvePath resolves the existing portion of an absolute path through any symlinks and preserves missing trailing components.

(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

938// ResolvePath resolves the existing portion of an absolute path through any
939// symlinks and preserves missing trailing components.
940func (c *agentConn) ResolvePath(ctx context.Context, path string) (string, error) {
941 ctx, span := tracing.StartSpan(ctx)
942 defer span.End()
943
944 res, err := c.apiRequest(ctx, http.MethodGet, agentAPIPath("/api/v0/resolve-path", neturl.Values{
945 "path": []string{path},
946 }), nil)
947 if err != nil {
948 return "", xerrors.Errorf("do request: %w", err)
949 }
950 defer res.Body.Close()
951 if res.StatusCode != http.StatusOK {
952 return "", codersdk.ReadBodyAsError(res)
953 }
954
955 var m ResolvePathResponse
956 if err := json.NewDecoder(res.Body).Decode(&m); err != nil {
957 return "", xerrors.Errorf("decode response body: %w", err)
958 }
959 return m.ResolvedPath, nil
960}
961
962// ReadFileLines reads a file with line-based offset and limit, returning
963// line-numbered content with safety limits.

Callers

nothing calls this directly

Calls 6

apiRequestMethod · 0.95
StartSpanFunction · 0.92
ReadBodyAsErrorFunction · 0.92
agentAPIPathFunction · 0.85
CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected