Skip to content

Commit

Permalink
move to metal-toolbox/bmc-common
Browse files Browse the repository at this point in the history
Also, tightened up linting config and github action for linting, fixed
up some gosec lint warnings.
  • Loading branch information
DoctorVin committed Nov 14, 2024
1 parent a697bf6 commit 0383d55
Show file tree
Hide file tree
Showing 57 changed files with 122 additions and 106 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/push-pr-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
go-version-file: go.mod

- name: Run golangci-lint
run: make golangci-lint
uses: golangci/golangci-lint-action@v6
with:
args: --config .golangci.yml --timeout 2m
version: v1.61.0

- name: Check go generated files
run: make check-go-generated
Expand Down
23 changes: 10 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,52 +41,49 @@ linters:
# Comments help explain why its disabled or point at ones we should not disable but will take a little work
# If its not commented its likely because its just too annoying or we don't find useful
disable:
- copyloopvar # requires go >=1.22
- cyclop
- deadcode # deprecated
- depguard
- errname # maybe should be enabled
- exhaustivestruct # deprecated
- execinquery
- exhaustruct
- exportloopref
- forbidigo
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- godot
- godox
- golint # deprecated
- gomnd
- ifshort # deprecated
- inamedparam
- interfacebloat
- interfacer # deprecated
- intrange # requires go >=1.22
- ireturn # should be enabled, ironlib needs some changes
- intrange
- lll # not previously enabled, ironlib and mctl both fail this
- maligned # deprecated
- mnd
- nestif
- nilnil
- nlreturn
- nolintlint
- nonamedreturns # should be enabled, probably
- nosnakecase # deprecated
- nonamedreturns # FIXME: named returns are unmaintainable
- paralleltest
- perfsprint
- scopelint # deprecated
- structcheck # deprecated
- tagliatelle
- tenv # should be enabled
- testpackage
- testifylint # should be enabled
- thelper # should be enabled
- varcheck # deprecated
- varnamelen
- wrapcheck
- wsl

issues:
exclude-files:
- ".*_test\\.go"
exclude-dirs:
- fixtures
exclude-rules:
- linters:
- stylecheck
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ lint: golangci-lint check-go-generated

## Run golangci-lint
golangci-lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
golangci-lint run --config .golangci.yml

## Run go generate
Expand Down
3 changes: 2 additions & 1 deletion actions/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package actions
import (
"strings"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"

"github.com/metal-toolbox/ironlib/utils"
)

Expand Down
5 changes: 3 additions & 2 deletions actions/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package actions
import (
"context"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
"github.com/sirupsen/logrus"
)

// DeviceManager interface is returned to the caller when calling ironlib.New()
Expand Down
10 changes: 5 additions & 5 deletions actions/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"slices"
"strings"

"github.com/bmc-toolbox/common"
"github.com/metal-toolbox/ironlib/firmware"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
common "github.com/metal-toolbox/bmc-common"
"github.com/pkg/errors"
"github.com/r3labs/diff/v3"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib/firmware"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
)

var (
Expand Down Expand Up @@ -840,7 +841,6 @@ func (a *InventoryCollectorAction) vetChanges(changes diff.Changelog) diff.Chang

for _, change := range changes {
// Skip changes that delete items
change := change
if a.acceptChange(&change) {
accepted = append(accepted, change)
}
Expand Down
7 changes: 4 additions & 3 deletions actions/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"os"
"testing"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"

dellFixtures "github.com/metal-toolbox/ironlib/fixtures/dell"
smcFixtures "github.com/metal-toolbox/ironlib/fixtures/supermicro"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
)

func Test_Inventory_dell(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions actions/storage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"fmt"
"strings"

"github.com/bmc-toolbox/common"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
common "github.com/metal-toolbox/bmc-common"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
)

var ErrVirtualDiskManagerUtilNotIdentified = errors.New("virtual disk management utility not identifed")
Expand Down
5 changes: 3 additions & 2 deletions actions/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"strings"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/pkg/errors"

"github.com/metal-toolbox/ironlib/errs"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
"github.com/pkg/errors"
)

var (
Expand Down
7 changes: 4 additions & 3 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package ironlib
import (
"fmt"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib/actions"
"github.com/metal-toolbox/ironlib/errs"
"github.com/metal-toolbox/ironlib/providers/asrockrack"
"github.com/metal-toolbox/ironlib/providers/dell"
"github.com/metal-toolbox/ironlib/providers/generic"
"github.com/metal-toolbox/ironlib/providers/supermicro"
"github.com/metal-toolbox/ironlib/utils"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

// New returns a device Manager interface based on the hardware deviceVendor, model attributes
Expand Down
5 changes: 3 additions & 2 deletions examples/diskwipe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"strings"
"time"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib"
"github.com/metal-toolbox/ironlib/actions"
"github.com/metal-toolbox/ironlib/utils"
"github.com/sirupsen/logrus"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions examples/firmware-install/firmware-install.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"fmt"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib"
"github.com/metal-toolbox/ironlib/model"
"github.com/sirupsen/logrus"
)

// This example invokes ironlib to install the supermicro BMC firmware
Expand Down
2 changes: 1 addition & 1 deletion fixtures/asrr/e3c246d4i-nl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package asrr

import (
"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
)

// E3C246D4INL is an example inventory taken with lshw
Expand Down
11 changes: 6 additions & 5 deletions fixtures/dell/r6515.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dell

import (
"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"

"github.com/metal-toolbox/ironlib/model"
)

Expand Down Expand Up @@ -1633,7 +1634,7 @@ var (
Common: common.Common{
Oem: false,
Description: "SATA controller",
Vendor: "Advanced Micro Devices, Inc. [AMD]",
Vendor: common.VendorAMD,
Model: "FCH SATA Controller [AHCI mode]",
Serial: "dead:beef",
ProductName: "FCH SATA Controller [AHCI mode]",
Expand All @@ -1654,7 +1655,7 @@ var (
Common: common.Common{
Oem: false,
Description: "SATA controller",
Vendor: "Advanced Micro Devices, Inc. [AMD]",
Vendor: common.VendorAMD,
Model: "FCH SATA Controller [AHCI mode]",
Serial: "dead:beef",
ProductName: "FCH SATA Controller [AHCI mode]",
Expand Down Expand Up @@ -3212,7 +3213,7 @@ var (
Common: common.Common{
Oem: false,
Description: "SATA controller",
Vendor: "Advanced Micro Devices, Inc. [AMD]",
Vendor: common.VendorAMD,
Model: "FCH SATA Controller [AHCI mode]",
Serial: "dead:beef",
ProductName: "FCH SATA Controller [AHCI mode]",
Expand All @@ -3233,7 +3234,7 @@ var (
Common: common.Common{
Oem: false,
Description: "SATA controller",
Vendor: "Advanced Micro Devices, Inc. [AMD]",
Vendor: common.VendorAMD,
Model: "FCH SATA Controller [AHCI mode]",
Serial: "dead:beef",
ProductName: "FCH SATA Controller [AHCI mode]",
Expand Down
3 changes: 2 additions & 1 deletion fixtures/supermicro/x11dph-t.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package supermicro

import (
"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"

"github.com/metal-toolbox/ironlib/model"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22

require (
github.com/beevik/etree v1.4.1
github.com/bmc-toolbox/common v0.0.0-20240426155832-c9882dbabcca
github.com/dselans/dmidecode v0.0.0-20180814053009-65c3f9d81910
github.com/metal-toolbox/bmc-common v1.0.2
github.com/pkg/errors v0.9.1
github.com/r3labs/diff/v3 v3.0.1
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/beevik/etree v1.4.1 h1:PmQJDDYahBGNKDcpdX8uPy1xRCwoCGVUiW669MEirVI=
github.com/beevik/etree v1.4.1/go.mod h1:gPNJNaBGVZ9AwsidazFZyygnd+0pAU38N4D+WemwKNs=
github.com/bmc-toolbox/common v0.0.0-20240426155832-c9882dbabcca h1:8hmbfSQ3cR0KXyAegrgmv9ic2eyDLdYl9j6819dkKb0=
github.com/bmc-toolbox/common v0.0.0-20240426155832-c9882dbabcca/go.mod h1:SY//n1PJjZfbFbmAsB6GvEKbc7UXz3d30s3kWxfJQ/c=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -15,6 +13,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/metal-toolbox/bmc-common v1.0.2 h1:AbUhx4tJzz2dYxKaXu8ENSR8+bCupbqwLvYouzpEc5U=
github.com/metal-toolbox/bmc-common v1.0.2/go.mod h1:WxMpaNb7/yTSEW0fMDOWUrhs/CPAzuCSx0p3uv3vRVA=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
4 changes: 3 additions & 1 deletion model/hardware.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package model

import "github.com/bmc-toolbox/common"
import (
common "github.com/metal-toolbox/bmc-common"
)

// Hardware is a base struct that various providers inherit
type Hardware struct {
Expand Down
2 changes: 1 addition & 1 deletion model/stuff.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package model

import (
"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/pkg/errors"
)

Expand Down
7 changes: 4 additions & 3 deletions providers/asrockrack/asrockrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package asrockrack
import (
"context"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib/actions"
"github.com/metal-toolbox/ironlib/errs"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

// A asrockrack device has methods to collect hardware inventory, regardless of the vendor
Expand Down
7 changes: 4 additions & 3 deletions providers/dell/dell.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"os"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/metal-toolbox/ironlib/actions"
"github.com/metal-toolbox/ironlib/errs"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

// EnvUpdateStoreURL defines up the update store base URL prefix
Expand Down
9 changes: 5 additions & 4 deletions providers/dell/dell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"os"
"testing"

"github.com/bmc-toolbox/common"
common "github.com/metal-toolbox/bmc-common"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"

"github.com/metal-toolbox/ironlib/actions"
dellFixtures "github.com/metal-toolbox/ironlib/fixtures/dell"
"github.com/metal-toolbox/ironlib/model"
"github.com/metal-toolbox/ironlib/utils"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
)

var r6515fixtures = "../../fixtures/dell/r6515"
Expand Down
Loading

0 comments on commit 0383d55

Please sign in to comment.