Skip to content

Commit

Permalink
refactor: Using request shortcut for creating a request
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Dec 27, 2021
1 parent 8fbe531 commit 74bb9a2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
Expand All @@ -176,7 +175,6 @@ github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5W
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
Expand Down Expand Up @@ -415,7 +413,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (a App) LatestVersions(repository string, patterns []string) (map[string]se
url := fmt.Sprintf("%s/v2/%s/tags/list", registry, repository)

for len(url) != 0 {
req := request.New().Get(url)
req := request.Get(url)

if len(auth) != 0 {
req = req.Header("Authorization", auth)
Expand Down Expand Up @@ -126,7 +126,7 @@ func (a App) login(ctx context.Context, repository string) (string, error) {
values.Add("username", a.username)
values.Add("password", a.password)

resp, err := request.New().Post(authURL).Form(ctx, values)
resp, err := request.Post(authURL).Form(ctx, values)
if err != nil {
return "", fmt.Errorf("unable to authenticate to `%s`: %s", authURL, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func New() App {

// FetchIndex of given URL for given charts patterns
func (a App) FetchIndex(url string, chartsPatterns map[string][]string) (map[string]map[string]semver.Version, error) {
resp, err := request.New().Get(fmt.Sprintf("%s/%s", url, indexName)).Send(context.Background(), nil)
resp, err := request.Get(fmt.Sprintf("%s/%s", url, indexName)).Send(context.Background(), nil)
if err != nil {
return nil, fmt.Errorf("unable to request repository: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/npm/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (a App) LatestVersions(name string, patterns []string) (map[string]semver.V
return nil, fmt.Errorf("unable to prepare pattern matching: %s", err)
}

resp, err := request.New().Get(fmt.Sprintf("%s/%s", registryURL, name)).Header("Accept", "application/vnd.npm.install-v1+json").Send(ctx, nil)
resp, err := request.Get(fmt.Sprintf("%s/%s", registryURL, name)).Header("Accept", "application/vnd.npm.install-v1+json").Send(ctx, nil)
if err != nil {
return nil, fmt.Errorf("unable to fetch registry: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/pypi/pypi.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (a App) LatestVersions(name string, patterns []string) (map[string]semver.V
return nil, fmt.Errorf("unable to prepare pattern matching: %s", err)
}

resp, err := request.New().Get(fmt.Sprintf("%s/%s/json", registryURL, name)).Send(ctx, nil)
resp, err := request.Get(fmt.Sprintf("%s/%s/json", registryURL, name)).Send(ctx, nil)
if err != nil {
return nil, fmt.Errorf("unable to fetch registry: %s", err)
}
Expand Down

0 comments on commit 74bb9a2

Please sign in to comment.