MCPcopy Create free account
hub / github.com/nhost/nhost / DownloadAsset

Method DownloadAsset

cli/software/sofware.go:115–132  ·  view source on GitHub ↗
(ctx context.Context, url string, dst io.Writer)

Source from the content-addressed store, hash-verified

113}
114
115func (mgr *Manager) DownloadAsset(ctx context.Context, url string, dst io.Writer) error {
116 req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
117 if err != nil {
118 return fmt.Errorf("failed to create request: %w", err)
119 }
120
121 resp, err := mgr.client.Do(req)
122 if err != nil {
123 return fmt.Errorf("failed to download release: %w", err)
124 }
125 defer resp.Body.Close()
126
127 if err := extractTarGz(resp.Body, dst); err != nil {
128 return fmt.Errorf("failed to extract tarball: %w", err)
129 }
130
131 return nil
132}
133
134func extractTarGz(gzipStream io.Reader, dst io.Writer) error {
135 uncompressedStream, err := gzip.NewReader(gzipStream)

Callers 1

commandUpgradeFunction · 0.95

Calls 4

extractTarGzFunction · 0.85
ErrorfMethod · 0.80
DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected