Skip to content

Commit

Permalink
cmd/configure_raid.go,internal/command.go: Use cobra provided cmd.Con…
Browse files Browse the repository at this point in the history
…text()
  • Loading branch information
splaspood committed Nov 15, 2022
1 parent 045bb9a commit 7930c87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/configure_raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var configureRaidCmd = &cobra.Command{
Short: "Configures various types of RAID",
Long: "Configures various types of RAID",
Run: func(cmd *cobra.Command, args []string) {
ctx := command.NewContextWithLogger(logger)
ctx := command.NewContextWithLogger(logger, cmd.Context())

if GetBool(cmd, "delete") {
raidArray := model.RaidArray{
Expand Down
4 changes: 2 additions & 2 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type contextKey string

var contextLoggerKey = contextKey("logger")

func NewContextWithLogger(l *zap.SugaredLogger) context.Context {
ctx := context.WithValue(context.Background(), contextLoggerKey, l)
func NewContextWithLogger(l *zap.SugaredLogger, existingCtx context.Context) context.Context {
ctx := context.WithValue(existingCtx, contextLoggerKey, l)
return ctx
}

Expand Down

0 comments on commit 7930c87

Please sign in to comment.