mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-18 21:51:49 +00:00
Merge pull request #4182 from fluxcd/clean-http-client
manifestgen/install: use clean default HTTP client
This commit is contained in:
commit
4fa93ec4d6
3 changed files with 7 additions and 4 deletions
2
go.mod
2
go.mod
|
|
@ -38,6 +38,7 @@ require (
|
||||||
github.com/gonvenience/ytbx v1.4.4
|
github.com/gonvenience/ytbx v1.4.4
|
||||||
github.com/google/go-cmp v0.5.9
|
github.com/google/go-cmp v0.5.9
|
||||||
github.com/google/go-containerregistry v0.15.2
|
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/homeport/dyff v1.5.8
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0
|
github.com/lucasb-eyer/go-colorful v1.2.0
|
||||||
github.com/manifoldco/promptui v0.9.0
|
github.com/manifoldco/promptui v0.9.0
|
||||||
|
|
@ -146,7 +147,6 @@ require (
|
||||||
github.com/gorilla/mux v1.8.0 // indirect
|
github.com/gorilla/mux v1.8.0 // indirect
|
||||||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
|
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
|
||||||
github.com/hashicorp/errwrap v1.1.0 // 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-multierror v1.1.1 // indirect
|
||||||
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
|
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
|
||||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
securejoin "github.com/cyphar/filepath-securejoin"
|
securejoin "github.com/cyphar/filepath-securejoin"
|
||||||
|
"github.com/hashicorp/go-cleanhttp"
|
||||||
|
|
||||||
"github.com/fluxcd/flux2/v2/pkg/manifestgen"
|
"github.com/fluxcd/flux2/v2/pkg/manifestgen"
|
||||||
)
|
)
|
||||||
|
|
@ -91,7 +92,7 @@ func Generate(options Options, manifestsBase string) (*manifestgen.Manifest, err
|
||||||
// GetLatestVersion calls the GitHub API and returns the latest released version.
|
// GetLatestVersion calls the GitHub API and returns the latest released version.
|
||||||
func GetLatestVersion() (string, error) {
|
func GetLatestVersion() (string, error) {
|
||||||
ghURL := "https://api.github.com/repos/fluxcd/flux2/releases/latest"
|
ghURL := "https://api.github.com/repos/fluxcd/flux2/releases/latest"
|
||||||
c := http.DefaultClient
|
c := cleanhttp.DefaultClient()
|
||||||
c.Timeout = 15 * time.Second
|
c.Timeout = 15 * time.Second
|
||||||
|
|
||||||
res, err := c.Get(ghURL)
|
res, err := c.Get(ghURL)
|
||||||
|
|
@ -121,7 +122,7 @@ func ExistingVersion(version string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ghURL := fmt.Sprintf("https://api.github.com/repos/fluxcd/flux2/releases/tags/%s", version)
|
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
|
c.Timeout = 15 * time.Second
|
||||||
|
|
||||||
res, err := c.Get(ghURL)
|
res, err := c.Get(ghURL)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/go-cleanhttp"
|
||||||
|
|
||||||
"github.com/fluxcd/pkg/kustomize/filesys"
|
"github.com/fluxcd/pkg/kustomize/filesys"
|
||||||
"github.com/fluxcd/pkg/tar"
|
"github.com/fluxcd/pkg/tar"
|
||||||
|
|
||||||
|
|
@ -44,7 +46,7 @@ func fetch(ctx context.Context, url, version, dir string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// download
|
// download
|
||||||
resp, err := http.DefaultClient.Do(req.WithContext(ctx))
|
resp, err := cleanhttp.DefaultClient().Do(req.WithContext(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to download manifests.tar.gz from %s, error: %w", ghURL, err)
|
return fmt.Errorf("failed to download manifests.tar.gz from %s, error: %w", ghURL, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue