Skip to content

Commit

Permalink
Fix golangci related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kashifest committed Nov 3, 2023
1 parent f55e392 commit 7385cc2
Show file tree
Hide file tree
Showing 51 changed files with 379 additions and 526 deletions.
56 changes: 28 additions & 28 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ linters:
- asciicheck
- bodyclose
- dogsled
- errcheck
- errorlint
# - errcheck
# - errorlint
- exportloopref
- goconst
- gocritic
- godot
- gofmt
- goimports
- gosimple
- govet
- importas
- gosec
- ineffassign
- misspell
# - nakedret
- nilerr
- noctx
- nolintlint
- prealloc
- predeclared
- revive
- rowserrcheck
- staticcheck
- stylecheck
- thelper
- typecheck
- unconvert
- unused
- whitespace
# - goconst
# - gocritic
# - godot
# - gofmt
# - goimports
# - gosimple
# - govet
# - importas
# - gosec
# - ineffassign
# - misspell
# - nakedret
# - nilerr
# - noctx
# - nolintlint
# - prealloc
# - predeclared
# - revive
# - rowserrcheck
# - staticcheck
# - stylecheck
# - thelper
# - typecheck
# - unconvert
# - unused
# - whitespace
# Run with --fast=false for more extensive checks
fast: true

Expand Down
2 changes: 1 addition & 1 deletion cmd/get-hardware-details/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
ironicTrustedCAFile := os.Getenv("IRONIC_CACERT_FILE")
ironicInsecureStr := os.Getenv("IRONIC_INSECURE")
ironicInsecure := false
if strings.ToLower(ironicInsecureStr) == "true" {
if strings.EqualFold(ironicInsecureStr, "true") {
ironicInsecure = true
}

Expand Down
1 change: 0 additions & 1 deletion cmd/make-bm-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,4 @@ func main() {
}

fmt.Fprint(os.Stdout, result)

}
1 change: 1 addition & 0 deletions cmd/make-bm-worker/templates/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

func compareStrings(t *testing.T, s1, s2 string) bool {
t.Helper()
if s1 == s2 {
return true
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/make-virt-host/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ const (
</interface>
*/

// MAC is a hardware address for a NIC
// MAC is a hardware address for a NIC.
type MAC struct {
XMLName xml.Name `xml:"mac"`
Address string `xml:"address,attr"`
}

// Source is the network to which the interface is attached
// Source is the network to which the interface is attached.
type Source struct {
XMLName xml.Name `xml:"source"`
Bridge string `xml:"bridge,attr"`
}

// Interface is one NIC
// Interface is one NIC.
type Interface struct {
XMLName xml.Name `xml:"interface"`
MAC MAC `xml:"mac"`
Source Source `xml:"source"`
}

// Domain is the main tag for the XML document
// Domain is the main tag for the XML document.
type Domain struct {
Interfaces []Interface `xml:"devices>interface"`
}
Expand Down Expand Up @@ -113,7 +113,7 @@ vbmc list -f json -c 'Domain name' -c Port
*/

// VBMC holds the parameters for describing a virtual machine
// controller
// controller.
type VBMC struct {
Port int `json:"Port"`
Name string `json:"Domain name"`
Expand Down
11 changes: 5 additions & 6 deletions controllers/metal3.io/action_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

"sigs.k8s.io/controller-runtime/pkg/reconcile"

metal3 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
"github.com/metal3-io/baremetal-operator/pkg/provisioner"
)

// This is an upper limit for the ErrorCount, so that the max backoff
// timeout will not exceed (roughly) 8 hours
// timeout will not exceed (roughly) 8 hours.
const maxBackOffCount = 9

func init() {
Expand Down Expand Up @@ -57,7 +57,7 @@ func (r actionUpdate) Dirty() bool {
}

// actionDelayed it's the same of an actionUpdate, but the requeue time
// is calculated using a fixed backoff with jitter
// is calculated using a fixed backoff with jitter.
type actionDelayed struct {
actionUpdate
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func (r actionError) NeedsRegistration() bool {
// and that the resource should be marked as in error.
type actionFailed struct {
dirty bool
ErrorType metal3.ErrorType
ErrorType metal3api.ErrorType
errorCount int
}

Expand All @@ -133,9 +133,8 @@ type actionFailed struct {
// 6 [32m, 1h4m]
// 7 [1h4m, 2h8m]
// 8 [2h8m, 4h16m]
// 9 [4h16m, 8h32m]
// 9 [4h16m, 8h32m].
func calculateBackoff(errorCount int) time.Duration {

if errorCount > maxBackOffCount {
errorCount = maxBackOffCount
}
Expand Down
3 changes: 0 additions & 3 deletions controllers/metal3.io/action_result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ import (
)

func TestBackoffIncrements(t *testing.T) {

var backOff time.Duration
for i := 1; i <= maxBackOffCount; i++ {
prev := backOff
backOff = calculateBackoff(i)

assert.GreaterOrEqual(t, backOff.Milliseconds(), prev.Milliseconds())
}

}

func TestMaxBackoffDuration(t *testing.T) {

maxBackOffDuration := (time.Minute * time.Duration(math.Exp2(float64(maxBackOffCount)))).Milliseconds()

assert.LessOrEqual(t, calculateBackoff(maxBackOffCount-1).Milliseconds(), maxBackOffDuration)
Expand Down
Loading

0 comments on commit 7385cc2

Please sign in to comment.