Skip to content

Commit

Permalink
Merge pull request #4182 from fluxcd/clean-http-client
Browse files Browse the repository at this point in the history
manifestgen/install: use clean default HTTP client
  • Loading branch information
hiddeco authored Aug 22, 2023
2 parents 8801031 + 00c6ac8 commit 4fa93ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ require (
github.com/gonvenience/ytbx v1.4.4
github.com/google/go-cmp v0.5.9
github.com/google/go-containerregistry v0.15.2
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/homeport/dyff v1.5.8
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/manifoldco/promptui v0.9.0
Expand Down Expand Up @@ -146,7 +147,6 @@ require (
github.com/gorilla/mux v1.8.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
Expand Down
5 changes: 3 additions & 2 deletions pkg/manifestgen/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"time"

securejoin "github.com/cyphar/filepath-securejoin"
"github.com/hashicorp/go-cleanhttp"

"github.com/fluxcd/flux2/v2/pkg/manifestgen"
)
Expand Down Expand Up @@ -91,7 +92,7 @@ func Generate(options Options, manifestsBase string) (*manifestgen.Manifest, err
// GetLatestVersion calls the GitHub API and returns the latest released version.
func GetLatestVersion() (string, error) {
ghURL := "https://api.github.com/repos/fluxcd/flux2/releases/latest"
c := http.DefaultClient
c := cleanhttp.DefaultClient()
c.Timeout = 15 * time.Second

res, err := c.Get(ghURL)
Expand Down Expand Up @@ -121,7 +122,7 @@ func ExistingVersion(version string) (bool, error) {
}

ghURL := fmt.Sprintf("https://api.github.com/repos/fluxcd/flux2/releases/tags/%s", version)
c := http.DefaultClient
c := cleanhttp.DefaultClient()
c.Timeout = 15 * time.Second

res, err := c.Get(ghURL)
Expand Down
4 changes: 3 additions & 1 deletion pkg/manifestgen/install/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"path/filepath"
"strings"

"github.com/hashicorp/go-cleanhttp"

"github.com/fluxcd/pkg/kustomize/filesys"
"github.com/fluxcd/pkg/tar"

Expand All @@ -44,7 +46,7 @@ func fetch(ctx context.Context, url, version, dir string) error {
}

// download
resp, err := http.DefaultClient.Do(req.WithContext(ctx))
resp, err := cleanhttp.DefaultClient().Do(req.WithContext(ctx))
if err != nil {
return fmt.Errorf("failed to download manifests.tar.gz from %s, error: %w", ghURL, err)
}
Expand Down

0 comments on commit 4fa93ec

Please sign in to comment.