(ctx context.Context, httpClient *http.Client, host string, path safeurl.SafeURL)
| 270 | } |
| 271 | |
| 272 | func fetchReleasePath(ctx context.Context, httpClient *http.Client, host string, path safeurl.SafeURL) (*Release, error) { |
| 273 | // TODO(api-client-rollout) |
| 274 | // This line of code is part of a mechanical roll out of the api client. |
| 275 | // As a follow up, consider whether the api client can be injected to this call site, rather than constructed |
| 276 | resp, err := api.NewClientFromHTTP(httpClient).RequestWithContext(ctx, host, http.MethodGet, path.String(), nil) |
| 277 | if err != nil { |
| 278 | if isNotFound(err) { |
| 279 | return nil, ErrReleaseNotFound |
| 280 | } |
| 281 | return nil, err |
| 282 | } |
| 283 | defer resp.Body.Close() |
| 284 | |
| 285 | var release Release |
| 286 | if err := json.NewDecoder(resp.Body).Decode(&release); err != nil { |
| 287 | return nil, err |
| 288 | } |
| 289 | |
| 290 | return &release, nil |
| 291 | } |
| 292 | |
| 293 | // isNotFound reports whether err is an API error carrying a 404 status. The release lookups |
| 294 | // treat a missing release as a sentinel rather than an error, and the api client reports the |
no test coverage detected