| 106 | } |
| 107 | |
| 108 | func (node *HTTPNode) ReadContext(ctx context.Context) ([]byte, error) { |
| 109 | url, err := RemoteExists(ctx, *node.url, node.client) |
| 110 | if err != nil { |
| 111 | return nil, err |
| 112 | } |
| 113 | req, err := http.NewRequestWithContext(ctx, "GET", url.String(), nil) |
| 114 | if err != nil { |
| 115 | return nil, errors.TaskfileFetchFailedError{URI: node.Location()} |
| 116 | } |
| 117 | |
| 118 | resp, err := node.client.Do(req.WithContext(ctx)) |
| 119 | if err != nil { |
| 120 | if ctx.Err() != nil { |
| 121 | return nil, err |
| 122 | } |
| 123 | return nil, errors.TaskfileFetchFailedError{URI: node.Location()} |
| 124 | } |
| 125 | defer resp.Body.Close() |
| 126 | if resp.StatusCode != http.StatusOK { |
| 127 | return nil, errors.TaskfileFetchFailedError{ |
| 128 | URI: node.Location(), |
| 129 | HTTPStatusCode: resp.StatusCode, |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // Read the entire response body |
| 134 | b, err := io.ReadAll(resp.Body) |
| 135 | if err != nil { |
| 136 | return nil, err |
| 137 | } |
| 138 | |
| 139 | return b, nil |
| 140 | } |
| 141 | |
| 142 | func (node *HTTPNode) ResolveEntrypoint(entrypoint string) (string, error) { |
| 143 | ref, err := url.Parse(entrypoint) |