LS lists a directory.
(ctx context.Context, path string, req LSRequest)
| 909 | |
| 910 | // LS lists a directory. |
| 911 | func (c *agentConn) LS(ctx context.Context, path string, req LSRequest) (LSResponse, error) { |
| 912 | ctx, span := tracing.StartSpan(ctx) |
| 913 | defer span.End() |
| 914 | |
| 915 | res, err := c.apiRequest(ctx, http.MethodPost, agentAPIPath("/api/v0/list-directory", neturl.Values{ |
| 916 | "path": []string{path}, |
| 917 | }), req) |
| 918 | if err != nil { |
| 919 | return LSResponse{}, xerrors.Errorf("do request: %w", err) |
| 920 | } |
| 921 | defer res.Body.Close() |
| 922 | if res.StatusCode != http.StatusOK { |
| 923 | return LSResponse{}, codersdk.ReadBodyAsError(res) |
| 924 | } |
| 925 | |
| 926 | var m LSResponse |
| 927 | if err := json.NewDecoder(res.Body).Decode(&m); err != nil { |
| 928 | return LSResponse{}, xerrors.Errorf("decode response body: %w", err) |
| 929 | } |
| 930 | return m, nil |
| 931 | } |
| 932 | |
| 933 | // ResolvePathResponse is the response from the agent's path-resolution endpoint. |
| 934 | type ResolvePathResponse struct { |
nothing calls this directly
no test coverage detected