mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
build: update golangci-lint to 1.60.1 (#23807)
* build: update golangci-lint to 1.60.1 * ci: update golangci-lint to v1.60.1 Helps with go1.23 compatability. Introduces some breaking changes / newly enforced linter patterns so those are fixed as well.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
run:
|
||||
# Timeout for analysis.
|
||||
deadline: 10m
|
||||
timeout: 10m
|
||||
|
||||
# Modules download mode (do not modify go.mod)
|
||||
module-download-mode: readonly
|
||||
@@ -11,26 +11,19 @@ run:
|
||||
# Exclude test files
|
||||
tests: false
|
||||
|
||||
# which dirs to skip: they won't be analyzed;
|
||||
# can use regexp here: generated.*, regexp is applied on full path;
|
||||
# default value is empty list, but next dirs are always skipped independently
|
||||
# from this option's value:
|
||||
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
|
||||
# Skip ui and generated files
|
||||
issues:
|
||||
exclude-files:
|
||||
- ".*\\.generated\\.go$"
|
||||
- ".*bindata_assetfs\\.go$"
|
||||
skip-dirs:
|
||||
- ui
|
||||
|
||||
# which files to skip: they will be analyzed, but issues from them
|
||||
# won't be reported. Default value is empty list, but there is
|
||||
# no need to include all autogenerated files, we confidently recognize
|
||||
# autogenerated files. If it's not please let us know.
|
||||
skip-files:
|
||||
- ".*\\.generated\\.go$"
|
||||
- ".*bindata_assetfs\\.go$"
|
||||
|
||||
# output configuration options
|
||||
# Output configuration options
|
||||
output:
|
||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
|
||||
format: colored-line-number
|
||||
formats:
|
||||
- format: colored-line-number
|
||||
path: stdout
|
||||
|
||||
# print lines of code with issue, default is true
|
||||
print-issued-lines: true
|
||||
@@ -45,10 +38,9 @@ linters-settings:
|
||||
# default is false: such cases aren't reported by default.
|
||||
check-type-assertions: false
|
||||
|
||||
# [deprecated] comma-separated list of pairs of the form pkg:regex
|
||||
# the regex is used to ignore names within pkg. (default "fmt:.*").
|
||||
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
|
||||
ignore: fmt:.*,io/ioutil:^Read.*
|
||||
exclude-functions:
|
||||
- io.*
|
||||
- fmt.*
|
||||
|
||||
# path to a file containing a list of functions to exclude from checking
|
||||
# see https://github.com/kisielk/errcheck#excluding-functions for details
|
||||
|
||||
@@ -141,7 +141,7 @@ deps: ## Install build and development dependencies
|
||||
.PHONY: lint-deps
|
||||
lint-deps: ## Install linter dependencies
|
||||
@echo "==> Updating linter dependencies..."
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1
|
||||
go install github.com/client9/misspell/cmd/misspell@v0.3.4
|
||||
go install github.com/hashicorp/go-hclog/hclogvet@v0.2.0
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ func (f *EnvGCEFingerprint) isGCE() bool {
|
||||
// Query the metadata url for the machine type, to verify we're on GCE
|
||||
machineType, err := f.Get("machine-type", false)
|
||||
if err != nil {
|
||||
if re, ok := err.(ReqError); !ok || re.StatusCode != 404 {
|
||||
if re, ok := err.(ReqError); !ok || re.StatusCode != http.StatusNotFound {
|
||||
// If it wasn't a 404 error, print an error message.
|
||||
f.logger.Debug("error querying GCE Metadata URL, skipping")
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func (s *HTTPServer) ACLTokensRequest(resp http.ResponseWriter, req *http.Reques
|
||||
|
||||
func (s *HTTPServer) ACLTokenBootstrap(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
// Ensure this is a PUT or POST
|
||||
if !(req.Method == "PUT" || req.Method == "POST") {
|
||||
if !(req.Method == http.MethodPut || req.Method == http.MethodPost) {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func (s *HTTPServer) ACLTokenSpecificRequest(resp http.ResponseWriter, req *http
|
||||
|
||||
switch path {
|
||||
case "/v1/acl/token":
|
||||
if !(req.Method == "PUT" || req.Method == "POST") {
|
||||
if !(req.Method == http.MethodPut || req.Method == http.MethodPost) {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
return s.aclTokenUpdate(resp, req, "")
|
||||
@@ -290,7 +290,7 @@ func (s *HTTPServer) aclTokenDelete(resp http.ResponseWriter, req *http.Request,
|
||||
|
||||
func (s *HTTPServer) UpsertOneTimeToken(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
// Ensure this is a PUT or POST
|
||||
if !(req.Method == "PUT" || req.Method == "POST") {
|
||||
if !(req.Method == http.MethodPut || req.Method == http.MethodPost) {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ func (s *HTTPServer) UpsertOneTimeToken(resp http.ResponseWriter, req *http.Requ
|
||||
|
||||
func (s *HTTPServer) ExchangeOneTimeToken(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
// Ensure this is a PUT or POST
|
||||
if !(req.Method == "PUT" || req.Method == "POST") {
|
||||
if !(req.Method == http.MethodPut || req.Method == http.MethodPost) {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ func (s *HTTPServer) AgentSelfRequest(resp http.ResponseWriter, req *http.Reques
|
||||
}
|
||||
|
||||
func (s *HTTPServer) AgentJoinRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
srv := s.agent.Server()
|
||||
@@ -312,7 +312,7 @@ func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) (
|
||||
}
|
||||
|
||||
func (s *HTTPServer) AgentForceLeaveRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
srv := s.agent.Server()
|
||||
|
||||
@@ -143,7 +143,7 @@ func (s *HTTPServer) allocGet(allocID string, resp http.ResponseWriter, req *htt
|
||||
}
|
||||
|
||||
func (s *HTTPServer) allocStop(allocID string, resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
if !(req.Method == "POST" || req.Method == "PUT") {
|
||||
if !(req.Method == http.MethodPost || req.Method == http.MethodPut) {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ func (s *HTTPServer) allocGC(allocID string, resp http.ResponseWriter, req *http
|
||||
}
|
||||
|
||||
func (s *HTTPServer) allocSignal(allocID string, resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
if !(req.Method == "POST" || req.Method == "PUT") {
|
||||
if !(req.Method == http.MethodPost || req.Method == http.MethodPut) {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ func (s *HTTPServer) JobSpecificRequest(resp http.ResponseWriter, req *http.Requ
|
||||
}
|
||||
|
||||
func (s *HTTPServer) jobForceEvaluate(resp http.ResponseWriter, req *http.Request, jobID string) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
var args structs.JobEvaluateRequest
|
||||
@@ -159,7 +159,7 @@ func (s *HTTPServer) jobForceEvaluate(resp http.ResponseWriter, req *http.Reques
|
||||
|
||||
func (s *HTTPServer) jobPlan(resp http.ResponseWriter, req *http.Request,
|
||||
jobName string) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ func (s *HTTPServer) jobPlan(resp http.ResponseWriter, req *http.Request,
|
||||
|
||||
func (s *HTTPServer) ValidateJobRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
// Ensure request method is POST or PUT
|
||||
if !(req.Method == "POST" || req.Method == "PUT") {
|
||||
if !(req.Method == http.MethodPost || req.Method == http.MethodPut) {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ func (s *HTTPServer) ValidateJobRequest(resp http.ResponseWriter, req *http.Requ
|
||||
|
||||
func (s *HTTPServer) periodicForceRequest(resp http.ResponseWriter, req *http.Request,
|
||||
jobName string) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -646,7 +646,7 @@ func (s *HTTPServer) jobScaleStatus(resp http.ResponseWriter, req *http.Request,
|
||||
|
||||
func (s *HTTPServer) jobScaleAction(resp http.ResponseWriter, req *http.Request, jobID string) (interface{}, error) {
|
||||
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -717,7 +717,7 @@ func (s *HTTPServer) jobVersions(resp http.ResponseWriter, req *http.Request, jo
|
||||
|
||||
func (s *HTTPServer) jobRevert(resp http.ResponseWriter, req *http.Request, jobID string) (interface{}, error) {
|
||||
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ func (s *HTTPServer) jobRevert(resp http.ResponseWriter, req *http.Request, jobI
|
||||
|
||||
func (s *HTTPServer) jobStable(resp http.ResponseWriter, req *http.Request, jobID string) (interface{}, error) {
|
||||
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
@@ -793,7 +793,7 @@ func (s *HTTPServer) jobSummaryRequest(resp http.ResponseWriter, req *http.Reque
|
||||
}
|
||||
|
||||
func (s *HTTPServer) jobDispatchRequest(resp http.ResponseWriter, req *http.Request, jobID string) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
if req.Method != http.MethodPut && req.Method != http.MethodPost {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
args := structs.JobDispatchRequest{}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// SearchRequest accepts a prefix and context and returns a list of matching
|
||||
// IDs for that context.
|
||||
func (s *HTTPServer) SearchRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
if req.Method == "POST" || req.Method == "PUT" {
|
||||
if req.Method == http.MethodPost || req.Method == http.MethodPut {
|
||||
return s.newSearchRequest(resp, req)
|
||||
}
|
||||
return nil, CodedError(http.StatusMethodNotAllowed, ErrInvalidMethod)
|
||||
@@ -39,7 +39,7 @@ func (s *HTTPServer) newSearchRequest(resp http.ResponseWriter, req *http.Reques
|
||||
}
|
||||
|
||||
func (s *HTTPServer) FuzzySearchRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
||||
if req.Method == "POST" || req.Method == "PUT" {
|
||||
if req.Method == http.MethodPost || req.Method == http.MethodPut {
|
||||
return s.newFuzzySearchRequest(resp, req)
|
||||
}
|
||||
return nil, CodedError(http.StatusMethodNotAllowed, ErrInvalidMethod)
|
||||
|
||||
@@ -336,7 +336,7 @@ func (tc *ClientStateTC) TestClientState_KillDuringRestart(f *framework.F) {
|
||||
return false, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return resp.StatusCode == 200, fmt.Errorf("%d != 200", resp.StatusCode)
|
||||
return resp.StatusCode == http.StatusOK, fmt.Errorf("%d != 200", resp.StatusCode)
|
||||
}, func(err error) {
|
||||
f.NoError(err)
|
||||
})
|
||||
|
||||
@@ -357,7 +357,7 @@ func (v *CSIVolume) Register(args *structs.CSIVolumeRegisterRequest, reply *stru
|
||||
|
||||
*vol = *existingVol
|
||||
|
||||
} else if vol.Topologies == nil || len(vol.Topologies) == 0 {
|
||||
} else if len(vol.Topologies) == 0 {
|
||||
// The topologies for the volume have already been set
|
||||
// when it was created, so for newly register volumes
|
||||
// we accept the user's description of that topology
|
||||
|
||||
@@ -2031,7 +2031,7 @@ func (j *Job) Dispatch(args *structs.JobDispatchRequest, reply *structs.JobDispa
|
||||
// Fetch all jobs that match the parameterized job ID prefix
|
||||
iter, err := snap.JobsByIDPrefix(ws, parameterizedJob.Namespace, parameterizedJob.ID, state.SortDefault)
|
||||
if err != nil {
|
||||
errMsg := "failed to retrieve jobs for idempotency check"
|
||||
const errMsg = "failed to retrieve jobs for idempotency check"
|
||||
j.logger.Error(errMsg, "error", err)
|
||||
return fmt.Errorf(errMsg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user