Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
notarize: use a retryable HTTP client for downloading logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Nov 6, 2019
1 parent 26e74e3 commit a5f0eae
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/gon/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (i *item) notarize(ctx context.Context, opts *processOptions) error {
opts.Prefix, len(log.Issues))
for idx, issue := range log.Issues {
color.New(color.FgRed).Fprintf(os.Stdout,
" %s Issue #%d (%s) for path %q: %s\n",
" %sIssue #%d (%s) for path %q: %s\n",
opts.Prefix, idx+1, issue.Severity, issue.Path, issue.Message)

// Append the error so we can return it
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/go-hclog v0.9.3-0.20191025211905-234833755cb2
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/go-retryablehttp v0.6.3
github.com/hashicorp/hcl/v2 v2.0.0
github.com/sebdah/goldie v1.0.0
github.com/stretchr/testify v1.3.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ github.com/hashicorp/go-hclog v0.9.3-0.20191025211905-234833755cb2/go.mod h1:whp
github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-retryablehttp v0.6.3 h1:tuulM+WnToeqa05z83YLmKabZxrySOmJAd4mJ+s2Nfg=
github.com/hashicorp/go-retryablehttp v0.6.3/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl/v2 v2.0.0 h1:efQznTz+ydmQXq3BOnRa3AXzvCeTq1P4dKj/z5GLlY8=
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
Expand Down
8 changes: 7 additions & 1 deletion notarize/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"

"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/go-retryablehttp"
)

// Log is the structure that is available when downloading the log file
Expand Down Expand Up @@ -61,7 +62,12 @@ func ParseLog(r io.Reader) (*Log, error) {
// If you want more fine-grained control over the download, download it
// using your own client and use ParseLog.
func DownloadLog(path string) (*Log, error) {
resp, err := cleanhttp.DefaultClient().Get(path)
// Build our HTTP client
client := retryablehttp.NewClient()
client.HTTPClient = cleanhttp.DefaultClient()

// Get it!
resp, err := client.Get(path)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a5f0eae

Please sign in to comment.