ResolvePath resolves the existing portion of an absolute path through any symlinks and preserves missing trailing components.
(ctx context.Context, path string)
| 938 | // ResolvePath resolves the existing portion of an absolute path through any |
| 939 | // symlinks and preserves missing trailing components. |
| 940 | func (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. |
nothing calls this directly
no test coverage detected