Skip to content

Commit

Permalink
minor go cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayk committed Jan 6, 2025
1 parent b52ef50 commit 70c6674
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pkg/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,12 @@ func (c *RLHTTPClient) GetArtifactSHA256(ctx context.Context, artifactURI string
}

defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("%d when getting %s", resp.StatusCode, artifactURI)
}

body, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("reading body: %w", err)
}

h256 := sha256.New()
h256.Write(body)
if _, err := io.Copy(h256, resp.Body); err != nil {
return "", fmt.Errorf("hashing %s: %w", artifactURI, err)
}
return fmt.Sprintf("%x", h256.Sum(nil)), nil
}

0 comments on commit 70c6674

Please sign in to comment.