Skip to content

Commit

Permalink
Fix Go linting errors:
Browse files Browse the repository at this point in the history
New Go linter required some fixes.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
  • Loading branch information
jacobweinstock committed Jan 11, 2025
1 parent 237131a commit 289d81c
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
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
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 289d81c

Please # to comment.