Skip to content

Commit

Permalink
Fix lint issues in configuration and codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mondragonfx committed Sep 25, 2024
1 parent 4904e33 commit 34a7b44
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gochecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
go version
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
- name: Run golangci-lint
run: |
Expand Down
28 changes: 12 additions & 16 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
linters-settings:
depguard:
list-type: denylist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 100
funlen:
Expand All @@ -31,7 +23,7 @@ linters-settings:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
mnd:
# don't include the "operation" and "assign"
checks:
- argument
Expand All @@ -47,7 +39,9 @@ linters-settings:
- strings.SplitN

govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment # a lot of manual overhead for reduced readability and adding a linter "gotcha"
settings:
printf:
funcs:
Expand All @@ -71,27 +65,25 @@ linters-settings:
linters:
disable-all: true
enable:
- bodyclose
- depguard
- copyloopvar
- dogsled
- dupl
- errcheck
- exportloopref
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- mnd
- nakedret
- noctx
- nolintlint
Expand All @@ -105,6 +97,8 @@ linters:
- whitespace

# don't enable:
# - bodyclose
# - depguard
# - asciicheck
# - scopelint
# - gochecknoglobals
Expand Down Expand Up @@ -137,6 +131,8 @@ issues:
- errcheck
- dupl
- gosec

- lll
- goconst
- dogsled
run:
timeout: 5m
timeout: 5m
6 changes: 5 additions & 1 deletion builder/vultr/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
)

const (
defaultStateTimeout = 10 * time.Minute
)

// Config provides the config struct
type Config struct {
common.PackerConfig `mapstructure:",squash"`
Expand Down Expand Up @@ -121,7 +125,7 @@ func (c *Config) Prepare(raws ...interface{}) error { //nolint:gocyclo
}

if c.RawStateTimeout == "" {
c.stateTimeout = 10 * time.Minute
c.stateTimeout = defaultStateTimeout
} else {
if stateTimeout, err := time.ParseDuration(c.RawStateTimeout); err == nil {
c.stateTimeout = stateTimeout
Expand Down
2 changes: 1 addition & 1 deletion builder/vultr/step_create_iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (s *stepCreateISO) Run(ctx context.Context, state multistep.StateBag) multi
c := state.Get("config").(*Config)
ui := state.Get("ui").(packer.Ui)

if len(c.ISOURL) > 0 {
if c.ISOURL != "" {
ui.Say("Creating ISO in Vultr account...")

isoReq := &govultr.ISOReq{
Expand Down
11 changes: 8 additions & 3 deletions builder/vultr/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
"github.com/vultr/govultr/v3"
)

const (
sleepDurationSeconds = 3
stateTimeoutMinutes = 10
)

func waitForISOState(state, isoID string, client *govultr.Client, timeout time.Duration) error { //nolint:dupl
done := make(chan struct{})
defer close(done)
Expand All @@ -30,7 +35,7 @@ func waitForISOState(state, isoID string, client *govultr.Client, timeout time.D
return
}

time.Sleep(3 * time.Second)
time.Sleep(sleepDurationSeconds * time.Second)

select {
case <-done:
Expand Down Expand Up @@ -69,7 +74,7 @@ func waitForServerState(state, power, serverID string, client *govultr.Client, t
return
}

time.Sleep(3 * time.Second)
time.Sleep(sleepDurationSeconds * time.Second)

// Verify we shouldn't exit
select {
Expand Down Expand Up @@ -111,7 +116,7 @@ func waitForSnapshotState(state, snapshotID string, client *govultr.Client, time
return
}

time.Sleep(3 * time.Second)
time.Sleep(sleepDurationSeconds * time.Second)

// Verify we shouldn't exit
select {
Expand Down

0 comments on commit 34a7b44

Please sign in to comment.