MCPcopy Create free account
hub / github.com/cli/cli / fetchReleasePath

Function fetchReleasePath

pkg/cmd/release/shared/fetch.go:272–291  ·  view source on GitHub ↗
(ctx context.Context, httpClient *http.Client, host string, path safeurl.SafeURL)

Source from the content-addressed store, hash-verified

270}
271
272func 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

Callers 3

FetchReleaseFunction · 0.85
FetchLatestReleaseFunction · 0.85
fetchDraftReleaseFunction · 0.85

Calls 5

NewClientFromHTTPFunction · 0.92
RequestWithContextMethod · 0.80
isNotFoundFunction · 0.70
StringMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected