Skip to content

Update Go to 1.23: #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2025
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/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install Go
uses: actions/[email protected]
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
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 as builder
FROM golang:1.23 as builder

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker-images

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /code
COPY go.mod go.sum /code/
Expand Down Expand Up @@ -57,7 +57,7 @@
&& wget -O/tmp/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 \
&& chmod +x /tmp/grpc_health_probe

ENV GIN_MODE release

Check warning on line 60 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker-images

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
USER pbnj
EXPOSE 50051 9090 8080

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/nmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/screenshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion cmd/sel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tinkerbell/pbnj

go 1.20
go 1.23

require (
github.com/bmc-toolbox/bmclib v0.5.7
Expand Down
4 changes: 2 additions & 2 deletions grpc/oob/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ func TestSendStatusMessage(t *testing.T) {

diff := cmp.Diff(msgs, tc.want)
if diff != "" {
t.Fatalf(diff)
t.Fatal(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion grpc/rpc/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
12 changes: 6 additions & 6 deletions grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion grpc/taskrunner/taskrunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
4 changes: 2 additions & 2 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion test/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading