diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 74a3b0b..7f9161f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5.0.2 with: - go-version: '1.20' + go-version: '1.23' - name: go fmt run: go get golang.org/x/tools/cmd/goimports && goimports -d . | (! grep .) - name: prepare go mod diff --git a/.golangci.yml b/.golangci.yml index f159c65..eefd0ec 100755 --- a/.golangci.yml +++ b/.golangci.yml @@ -78,10 +78,10 @@ linters-settings: - name: waitgroup-by-value staticcheck: - go: "1.20" + go: "1.23" unused: - go: "1.20" + go: "1.23" output: sort-results: true diff --git a/Dockerfile b/Dockerfile index 001749b..3c5b41a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20 as builder +FROM golang:1.23 as builder WORKDIR /code COPY go.mod go.sum /code/ diff --git a/Makefile b/Makefile index c1530f3..e9d808b 100644 --- a/Makefile +++ b/Makefile @@ -104,9 +104,9 @@ run-image: ## run PBnJ container image # BEGIN: lint-install . # http://github.com/tinkerbell/lint-install -GOLINT_VERSION ?= v1.52.2 -HADOLINT_VERSION ?= v2.7.0 -SHELLCHECK_VERSION ?= v0.7.2 +GOLINT_VERSION ?= v1.63.4 +HADOLINT_VERSION ?= v2.12.0 +SHELLCHECK_VERSION ?= v0.10.0 LINT_OS := $(shell uname) LINT_ARCH := $(shell uname -m) @@ -132,7 +132,7 @@ out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck: out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH): mkdir -p out/linters - curl -sfL https://github.com/hadolint/hadolint/releases/download/v2.6.1/hadolint-$(LINT_OS)-$(LINT_ARCH) > out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) + curl -sfL https://github.com/hadolint/hadolint/releases/download/$(HADOLINT_VERSION)/hadolint-$(LINT_OS)-$(LINT_ARCH) > out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) chmod u+x out/linters/hadolint-$(HADOLINT_VERSION)-$(LINT_ARCH) out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH): diff --git a/cmd/machine.go b/cmd/machine.go index 9c78b6e..3171070 100644 --- a/cmd/machine.go +++ b/cmd/machine.go @@ -16,7 +16,7 @@ var machineCmd = &cobra.Command{ Use: "machine", Short: "Run PBnJ client machine actions", Long: `Run PBnJ client for machine actions.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var opts []grpc.DialOption ctx := context.Background() ctx, cancel := context.WithCancel(ctx) diff --git a/cmd/nmi.go b/cmd/nmi.go index 6cfc20a..dec13e1 100644 --- a/cmd/nmi.go +++ b/cmd/nmi.go @@ -16,7 +16,7 @@ var ( Use: "nmi", Short: "Send NMI", Long: `Tell the target BMC to send an NMI to the system`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var opts []grpc.DialOption ctx := context.Background() diff --git a/cmd/root.go b/cmd/root.go index 6b8cc3e..fb439c5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -22,7 +22,7 @@ var rootCmd = &cobra.Command{ Use: "pbnj", Short: "PBnJ does all your power, boot and jelly goodness for your BMCs", Long: `PBnJ is a CLI that provides a gRPC interfaces for interacting with Out-of-Band controllers/BMCs.`, - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { return initConfig(cmd) }, } diff --git a/cmd/screenshot.go b/cmd/screenshot.go index 14d2277..863b39d 100644 --- a/cmd/screenshot.go +++ b/cmd/screenshot.go @@ -16,7 +16,7 @@ var ( Use: "screenshot", Short: "Take a screenshot", Long: `Take a screenshot of a target BMC`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var opts []grpc.DialOption ctx := context.Background() diff --git a/cmd/sel.go b/cmd/sel.go index 6f892f4..afd4306 100644 --- a/cmd/sel.go +++ b/cmd/sel.go @@ -16,7 +16,7 @@ var ( Use: "selclear", Short: "Clear the System Event Log", Long: `Clear the System Event Log of the target BMC`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { var opts []grpc.DialOption ctx := context.Background() diff --git a/cmd/server.go b/cmd/server.go index f3fdb68..52a2303 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -53,7 +53,7 @@ var ( Use: "server", Short: "Run PBnJ server", Long: `Run PBnJ server for interacting with BMCs.`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -63,7 +63,7 @@ var ( logger := defaultLogger(logLevel).WithName("github.com/tinkerbell/pbnj").WithValues("service", "github.com/tinkerbell/pbnj") - authzInterceptor := func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + authzInterceptor := func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return handler(ctx, req) } if enableAuthz { diff --git a/go.mod b/go.mod index 49f55e3..f01df55 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tinkerbell/pbnj -go 1.20 +go 1.23 require ( github.com/bmc-toolbox/bmclib v0.5.7 diff --git a/grpc/oob/common_test.go b/grpc/oob/common_test.go index 8de2d19..4bc31fc 100644 --- a/grpc/oob/common_test.go +++ b/grpc/oob/common_test.go @@ -35,7 +35,7 @@ func TestParseAuth(t *testing.T) { diff := cmp.Diff(tc.want.Error(), errMsg.Error()) if diff != "" { t.Logf("%+v", errMsg) - t.Fatalf(diff) + t.Fatal(diff) } } @@ -96,7 +96,7 @@ func TestSendStatusMessage(t *testing.T) { diff := cmp.Diff(msgs, tc.want) if diff != "" { - t.Fatalf(diff) + t.Fatal(diff) } }) } diff --git a/grpc/rpc/task_test.go b/grpc/rpc/task_test.go index d138415..23e0d33 100644 --- a/grpc/rpc/task_test.go +++ b/grpc/rpc/task_test.go @@ -34,7 +34,7 @@ func TestTaskFound(t *testing.T) { Ctx: ctx, } taskID := xid.New().String() - taskRunner.Execute(ctx, logger, "test", taskID, func(s chan string) (string, error) { + taskRunner.Execute(ctx, logger, "test", taskID, func(_ chan string) (string, error) { return "doing cool stuff", defaultError }) diff --git a/grpc/server_test.go b/grpc/server_test.go index 70767f5..92d6f06 100644 --- a/grpc/server_test.go +++ b/grpc/server_test.go @@ -24,9 +24,9 @@ func TestRunServer(t *testing.T) { ctx, cancel := context.WithTimeout(ctx, 9*time.Second) log := logr.Discard() r := rand.New(rand.NewSource(time.Now().UnixNano())) - min := 40041 - max := 40042 - port := r.Intn(max-min+1) + min + minimum := 40041 + maximum := 40042 + port := r.Intn(maximum-minimum+1) + minimum f := freecache.NewStore(freecache.DefaultOptions) s := gokv.Store(f) @@ -56,9 +56,9 @@ func TestRunServerSignals(t *testing.T) { log := logr.Discard() r := rand.New(rand.NewSource(time.Now().UnixNano())) - min := 40044 - max := 40045 - port := r.Intn(max-min+1) + min + minimum := 40044 + maximum := 40045 + port := r.Intn(maximum-minimum+1) + minimum grpcServer := grpc.NewServer() httpServer := http.NewServer(fmt.Sprintf(":%d", port+1)) httpServer.WithLogger(log) diff --git a/grpc/taskrunner/taskrunner_test.go b/grpc/taskrunner/taskrunner_test.go index 9b44330..fd75288 100644 --- a/grpc/taskrunner/taskrunner_test.go +++ b/grpc/taskrunner/taskrunner_test.go @@ -32,7 +32,7 @@ func TestRoundTrip(t *testing.T) { } taskID := xid.New().String() - runner.Execute(ctx, logger, description, taskID, func(s chan string) (string, error) { + runner.Execute(ctx, logger, description, taskID, func(_ chan string) (string, error) { return "didnt do anything", defaultError }) diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index 2760e22..5c9ee2f 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -30,7 +30,7 @@ func UnaryServerInterceptor(logger logr.Logger) grpc.UnaryServerInterceptor { // UnaryLogRequestID returns a new unary server interceptors that adds logr.Logger with requestID to the context if a requestID doesnt exist. func UnaryLogRequestID(requestIDKey, requestIDLogKey string) grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { var requestID string data, ok := metadata.FromIncomingContext(ctx) if ok { @@ -54,7 +54,7 @@ func UnaryLogRequestID(requestIDKey, requestIDLogKey string) grpc.UnaryServerInt // UnaryLogBMCIP returns a new unary server interceptors that adds the BMC IP to the logger. func UnaryLogBMCIP() grpc.UnaryServerInterceptor { - return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (h interface{}, err error) { + return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (h interface{}, err error) { // handle panics from reflect by just moving on. Calls to the task endpoint will always panic, // as they don't contain Authn. defer func() { diff --git a/test/main.go b/test/main.go index c3ad3f0..2d575d0 100644 --- a/test/main.go +++ b/test/main.go @@ -74,7 +74,7 @@ func defaultLogger(level string) logr.Logger { } // Returns an int >= min, < max. -func randomInt(min, max int) string { +func randomInt(minimum, maximum int) string { r := rand.New(rand.NewSource(time.Now().UnixNano())) - return strconv.Itoa(r.Intn(max-min+1) + min) + return strconv.Itoa(r.Intn(maximum-minimum+1) + minimum) } diff --git a/test/runner/runner.go b/test/runner/runner.go index acb9a3f..07e7e30 100644 --- a/test/runner/runner.go +++ b/test/runner/runner.go @@ -127,7 +127,7 @@ func RunTests(t logr.Logger, cfgData ConfigFile) { goto COMPLETE } got.Result = strings.ToLower(got.Result) - diff = cmp.Diff(stepName.Want, got, cmpopts.IgnoreMapEntries(func(key, i interface{}) bool { return key == "id" }), protocmp.Transform()) + diff = cmp.Diff(stepName.Want, got, cmpopts.IgnoreMapEntries(func(key, _ interface{}) bool { return key == "id" }), protocmp.Transform()) if diff != "" { log.Println(diff) successful = color.RedString("FAIL")