From 7fa8ed39ff7b3b070855e776da029e931caa5a35 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Fri, 6 Dec 2019 11:48:37 +0100 Subject: [PATCH] Use golangci rather than deprecated metalinter for lint checks. --- .golangci.yml | 44 ++++++++++++++++++++++++++++++++++++ GNUmakefile | 24 +++----------------- levant/deploy.go | 2 +- levant/job_status_checker.go | 4 ++-- levant/structs/config.go | 6 ++--- 5 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..e009c18d5 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,44 @@ +run: + deadline: 5m + issues-exit-code: 1 + tests: true + +output: + format: colored-line-number + print-issued-lines: true + print-linter-name: true + +linters: + enable: + - deadcode + - errcheck + - goimports + - gofmt + - golint + - govet + - ineffassign + - misspell + - structcheck + - unconvert + - varcheck + - interfacer + - unparam + - depguard + - goconst + - gocyclo + - gosec + - maligned + - prealloc + disable: + # - nakedret + # - gosimple + # - staticcheck + # - stylecheck + # - unused + # - dupl + # - gochecknoinits + # - gochecknoglobals + # - lll + # - typecheck + enable-all: false + disable-all: true diff --git a/GNUmakefile b/GNUmakefile index 39a7f4e40..9cf422e67 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,8 +4,7 @@ default: check test build tools: ## Install the tools used to test and build @echo "==> Installing build tools" go get github.com/ahmetb/govvv - go get github.com/alecthomas/gometalinter - gometalinter --install + GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint .PHONY: build build: ## Build Levant for development purposes @@ -29,26 +28,9 @@ release: ## Trigger the release build script @goreleaser --rm-dist .PHONY: check -check: ## Run the gometalinter suite +check: ## Run golangci-lint @echo "==> Running $@..." - gometalinter \ - --deadline 10m \ - --vendor \ - --sort="path" \ - --aggregate \ - --disable-all \ - --enable golint \ - --enable-gc \ - --enable goimports \ - --enable misspell \ - --enable vet \ - --enable deadcode \ - --enable varcheck \ - --enable ineffassign \ - --enable structcheck \ - --enable errcheck \ - --enable gofmt \ - ./... + golangci-lint run buildtime/... client/... command/... helper/... levant/... logging/... scale/... template/... version/... HELP_FORMAT=" \033[36m%-25s\033[0m %s\n" .PHONY: help diff --git a/levant/deploy.go b/levant/deploy.go index 63d227660..f965c7700 100644 --- a/levant/deploy.go +++ b/levant/deploy.go @@ -274,7 +274,7 @@ func (l *levantDeployment) deploymentWatcher(depID string) (success bool) { deploymentChan := make(chan interface{}) t := time.Now() - wt := time.Duration(5 * time.Second) + wt := 5 * time.Second // Setup the canaryChan and launch the autoPromote go routine if autoPromote // has been enabled. diff --git a/levant/job_status_checker.go b/levant/job_status_checker.go index 7e4fc0420..f5e97e704 100644 --- a/levant/job_status_checker.go +++ b/levant/job_status_checker.go @@ -21,7 +21,7 @@ func (l *levantDeployment) jobStatusChecker(evalID *string) bool { // Run the initial job status check to ensure the job reaches a state of // running. - jStatus := l.simpleJobStatusChecker(*l.config.Template.Job.ID) + jStatus := l.simpleJobStatusChecker() // Periodic and parameterized batch jobs do not produce evaluations and so // can only go through the simplest of checks. @@ -40,7 +40,7 @@ func (l *levantDeployment) jobStatusChecker(evalID *string) bool { // simpleJobStatusChecker is used to check that jobs which do not emit initial // evaluations at least reach a job status of running. -func (l *levantDeployment) simpleJobStatusChecker(jobID string) bool { +func (l *levantDeployment) simpleJobStatusChecker() bool { q := &nomad.QueryOptions{WaitIndex: 1} diff --git a/levant/structs/config.go b/levant/structs/config.go index 5a41a4f1e..dba4fde32 100644 --- a/levant/structs/config.go +++ b/levant/structs/config.go @@ -39,12 +39,12 @@ type DeployConfig struct { // and force the count based on the rendered job file. ForceCount bool - // VaultToken is a string with the vault token. - VaultToken string - // EnvVault is a boolean flag that can be used to enable reading the VAULT_TOKEN // from the enviromment. EnvVault bool + + // VaultToken is a string with the vault token. + VaultToken string } // ClientConfig is the config struct which houses all the information needed to connect