verifyGitHubReleaseIsComplete downloads checksum file to verify that the release is complete.
(ctx context.Context, releaseName string)
| 135 | |
| 136 | // verifyGitHubReleaseIsComplete downloads checksum file to verify that the release is complete. |
| 137 | func verifyGitHubReleaseIsComplete(ctx context.Context, releaseName string) error { |
| 138 | ctx, cancel := context.WithTimeout(ctx, githubTimeout) |
| 139 | defer cancel() |
| 140 | |
| 141 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf(checksumsURLFormat, repo.BuildGitHubRepo, releaseName), http.NoBody) |
| 142 | if err != nil { |
| 143 | return errors.Wrap(err, "unable to download releases checksum") |
| 144 | } |
| 145 | |
| 146 | resp, err := http.DefaultClient.Do(req) |
| 147 | if err != nil { |
| 148 | return errors.Wrap(err, "unable to download releases checksum") |
| 149 | } |
| 150 | |
| 151 | defer resp.Body.Close() //nolint:errcheck |
| 152 | |
| 153 | if resp.StatusCode != http.StatusOK { |
| 154 | return errors.Errorf("invalid status code from GitHub: %v", resp.StatusCode) |
| 155 | } |
| 156 | |
| 157 | return nil |
| 158 | } |
| 159 | |
| 160 | func (c *App) maybeCheckForUpdates(ctx context.Context) (string, error) { |
| 161 | if v := os.Getenv(c.EnvName(checkForUpdatesEnvar)); v != "" { |
no test coverage detected