Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
go-version: '1.22.x'
id: go

- name: Check out code into the Go module directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
go-version: '1.22.x'
cache: false
- name: Checkout code
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
version: v1.63.4
- name: gofmt
run: |
make gofmt
40 changes: 0 additions & 40 deletions .golangci.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LDFLAGS := "${ldflags:+$ldflags }-X main.version=${ver}${suff}"
BUILD_FLAGS := -ldflags "-X main.version=$(VERSION_FULL)"
ENV_ROOT := $(shell [ "$$(id -u)" = "0" ] && echo env || echo sudo )

GOLANGCI_VER = v1.56.1
GOLANGCI_VER = v1.63.4
GOLANGCI = ./tools/golangci-lint-$(GOLANGCI_VER)

CMDS := demo/demo ptimg/ptimg
Expand Down Expand Up @@ -46,7 +46,7 @@ $(GOLANGCI):

lint: .lint

.lint: $(ALL_GO_FILES) $(GOLANGCI) .golangci.yml
.lint: $(ALL_GO_FILES) $(GOLANGCI)
$(GOLANGCI) run ./...
@touch $@

Expand Down
1 change: 1 addition & 0 deletions demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
&diskCommands,
&megaraidCommands,
&smartpqiCommands,
&mpi3mrCommands,

Check warning on line 52 in demo/main.go

View check run for this annotation

Codecov / codecov/patch

demo/main.go#L52

Added line #L52 was not covered by tests
&lvmCommands,
&miscCommands,
},
Expand Down
9 changes: 7 additions & 2 deletions demo/megaraid.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
},
}

const (
HDD = "HDD"
SSD = "SSD"
)

func megaraidDiskSummary(c *cli.Context) error {
var err error
var ctrlNum = 0
Expand All @@ -50,10 +55,10 @@
data := [][]string{{"Path", "Name", "Type", "State"}}

for _, vd := range ctrl.VirtDrives {
stype := "HDD"
stype := HDD

Check warning on line 58 in demo/megaraid.go

View check run for this annotation

Codecov / codecov/patch

demo/megaraid.go#L58

Added line #L58 was not covered by tests

if ctrl.DriveGroups[vd.DriveGroup].IsSSD() {
stype = "SSD"
stype = SSD

Check warning on line 61 in demo/megaraid.go

View check run for this annotation

Codecov / codecov/patch

demo/megaraid.go#L61

Added line #L61 was not covered by tests
}

name := vd.RaidName
Expand Down
130 changes: 130 additions & 0 deletions demo/mpi3mr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package main

import (
"encoding/json"
"fmt"
"strconv"

"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"machinerun.io/disko/linux"
"machinerun.io/disko/mpi3mr"
)

//nolint:gochecknoglobals
var mpi3mrCommands = cli.Command{
Name: "mpi3mr",
Usage: "mpi3mr / storcli2 commands",
Subcommands: []*cli.Command{
{
Name: "dump",
Usage: "Dump information about mpi3mr",
Action: mpi3mrDump,
},
{
Name: "disk-summary",
Usage: "Show information about virtual disk devices on system",
Action: mpi3mrDiskSummary,
},
{
Name: "list-controllers",
Usage: "Show the discovered controllers' ID",
Action: mpi3mrListControllers,
},
},
}

func mpi3mrListControllers(c *cli.Context) error {
stor := mpi3mr.StorCli2()
ctrls, err := stor.List()
if err != nil {
return errors.Errorf("failed to list controllers: %v", err)

Check warning on line 41 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L37-L41

Added lines #L37 - L41 were not covered by tests
}

fmt.Printf("Found %d controllers:\n", len(ctrls))
for _, cID := range ctrls {
fmt.Printf("Controller ID: %d\n", cID)

Check warning on line 46 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L44-L46

Added lines #L44 - L46 were not covered by tests
}

return nil

Check warning on line 49 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L49

Added line #L49 was not covered by tests
}

func mpi3mrDiskSummary(c *cli.Context) error {
var err error
var ctrlNum = 0
var ctrlArg = c.Args().First()

Check warning on line 55 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L52-L55

Added lines #L52 - L55 were not covered by tests

if ctrlArg != "" {
ctrlNum, err = strconv.Atoi(ctrlArg)
if err != nil {
return errors.Errorf("invalid controller number: %v", err)

Check warning on line 60 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L57-L60

Added lines #L57 - L60 were not covered by tests
}
}

stor := mpi3mr.StorCli2()
ctrl, err := stor.Query(ctrlNum)
if err != nil {
return errors.Errorf("failed to query controller %d: %v", ctrlNum, err)

Check warning on line 67 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L64-L67

Added lines #L64 - L67 were not covered by tests
}

data := [][]string{{"Path", "Name", "Type", "State"}}

Check warning on line 70 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L70

Added line #L70 was not covered by tests

for _, vd := range ctrl.VirtualDrives {
stype := "HDD"

Check warning on line 73 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L72-L73

Added lines #L72 - L73 were not covered by tests

if vd.IsSSD() {
stype = "SSD"

Check warning on line 76 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L75-L76

Added lines #L75 - L76 were not covered by tests
}

name := vd.Name
if vd.Name == "" {
name = fmt.Sprintf("virtid-%s", vd.ID())

Check warning on line 81 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L79-L81

Added lines #L79 - L81 were not covered by tests
}

data = append(data, []string{vd.Path(), name, stype, vd.State})

Check warning on line 84 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L84

Added line #L84 was not covered by tests
}

for _, d := range ctrl.PhysicalDrives {
if d.DG >= 0 {
continue

Check warning on line 89 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L87-L89

Added lines #L87 - L89 were not covered by tests
}

path := ""
if bname, err := linux.NameByDiskID(stor.DriverSysfsPath(), d.PID); err == nil {
path = "/dev/" + bname

Check warning on line 94 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L92-L94

Added lines #L92 - L94 were not covered by tests
}

data = append(data, []string{path, fmt.Sprintf("diskid-%d", d.PID),
d.Medium, d.State})

Check warning on line 98 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L97-L98

Added lines #L97 - L98 were not covered by tests
}

printTextTable(data)
return nil

Check warning on line 102 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L101-L102

Added lines #L101 - L102 were not covered by tests
}

func mpi3mrDump(c *cli.Context) error {
var err error
var ctrlNum = 0
var ctrlArg = c.Args().First()

Check warning on line 108 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L105-L108

Added lines #L105 - L108 were not covered by tests

if ctrlArg != "" {
ctrlNum, err = strconv.Atoi(ctrlArg)
if err != nil {
return errors.Errorf("invalid controller number: %v", err)

Check warning on line 113 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L110-L113

Added lines #L110 - L113 were not covered by tests
}
}

stor := mpi3mr.StorCli2()
ctrl, err := stor.Query(ctrlNum)
if err != nil {
return errors.Errorf("failed to query controller %d: %v", ctrlNum, err)

Check warning on line 120 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L117-L120

Added lines #L117 - L120 were not covered by tests
}

jbytes, err := json.MarshalIndent(&ctrl, "", " ")
if err != nil {
return errors.Errorf("failed to marshal controller: %v", err)

Check warning on line 125 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L123-L125

Added lines #L123 - L125 were not covered by tests
}

fmt.Printf("%s\n", string(jbytes))
return nil

Check warning on line 129 in demo/mpi3mr.go

View check run for this annotation

Codecov / codecov/patch

demo/mpi3mr.go#L128-L129

Added lines #L128 - L129 were not covered by tests
}
15 changes: 14 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module machinerun.io/disko

go 1.13
go 1.22

require (
github.com/google/go-cmp v0.6.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/rekby/gpt v0.0.0-20200614112001-7da10aec5566
Expand All @@ -13,3 +14,15 @@ require (
github.com/urfave/cli/v2 v2.25.3
golang.org/x/sys v0.8.0
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/smartystreets/assertions v1.13.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading