Skip to content

Commit

Permalink
Merge pull request #171 from jacobweinstock/update-go
Browse files Browse the repository at this point in the history
Update Go to 1.23:

## Description

<!--- Please describe what this PR is going to change -->
Needed for security dependency updates.

## Why is this needed

<!--- Link to issue you have raised -->

Fixes: #

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->


## How are existing users impacted? What migration steps/scripts do we need?

<!--- Fixes a bug, unblocks installation, removes a component of the stack etc -->
<!--- Requires a DB migration script, etc. -->


## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
  • Loading branch information
jacobweinstock authored Jan 11, 2025
2 parents 67791ae + 289d81c commit 209cbb1
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 31 deletions.
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
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

0 comments on commit 209cbb1

Please sign in to comment.