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

Method LS

codersdk/workspacesdk/agentconn.go:911–931  ·  view source on GitHub ↗

LS lists a directory.

(ctx context.Context, path string, req LSRequest)

Source from the content-addressed store, hash-verified

909
910// LS lists a directory.
911func (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.
934type ResolvePathResponse struct {

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