From 01c5120be7622f179ae129e1c26f5708d03682e0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 2 Sep 2022 22:41:48 +0200 Subject: [PATCH] linting: use consts from stdlib (usestdlibvars) cli/command/image/build/context.go:238:23: "400" can be replaced by http.StatusBadRequest (usestdlibvars) if resp.StatusCode < 400 { ^ cli/trust/trust.go:139:30: "GET" can be replaced by http.MethodGet (usestdlibvars) req, err := http.NewRequest("GET", endpointStr, nil) ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit d3d9301d2dfd8d3758e6b6f54b1573c60ce07a01) Signed-off-by: Cory Snider --- cli/command/image/build/context.go | 2 +- cli/trust/trust.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/command/image/build/context.go b/cli/command/image/build/context.go index 1b9f975d9b..b55ec22a5a 100644 --- a/cli/command/image/build/context.go +++ b/cli/command/image/build/context.go @@ -235,7 +235,7 @@ func getWithStatusError(url string) (resp *http.Response, err error) { if resp, err = http.Get(url); err != nil { return nil, err } - if resp.StatusCode < 400 { + if resp.StatusCode < http.StatusBadRequest { return resp, nil } msg := fmt.Sprintf("failed to GET %s with status %s", url, resp.Status) diff --git a/cli/trust/trust.go b/cli/trust/trust.go index df11227e93..bb8aad8524 100644 --- a/cli/trust/trust.go +++ b/cli/trust/trust.go @@ -136,7 +136,7 @@ func GetNotaryRepository(in io.Reader, out io.Writer, userAgent string, repoInfo Timeout: 5 * time.Second, } endpointStr := server + "/v2/" - req, err := http.NewRequest("GET", endpointStr, nil) + req, err := http.NewRequest(http.MethodGet, endpointStr, nil) if err != nil { return nil, err }