Skip to content

Commit

Permalink
fix(cmd/driver): avoid nil pointer deref.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Nov 15, 2023
1 parent cc6443f commit e0cf86f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (

type driverConfigOptions struct {
*options.Common
Type options.DriverTypes
Type *options.DriverTypes
Version string
Repos []string
Name string
Expand All @@ -57,6 +57,7 @@ type driverConfigOptions struct {
func NewDriverConfigCmd(ctx context.Context, opt *options.Common) *cobra.Command {
o := driverConfigOptions{
Common: opt,
Type: options.NewDriverTypes(),
}

cmd := &cobra.Command{
Expand All @@ -69,7 +70,7 @@ func NewDriverConfigCmd(ctx context.Context, opt *options.Common) *cobra.Command
},
}

cmd.Flags().Var(&o.Type, "type", "Driver type to be configured "+o.Type.Allowed())
cmd.Flags().Var(o.Type, "type", "Driver type to be configured "+o.Type.Allowed())
cmd.Flags().StringVar(&o.Version, "version", config.DefaultDriver.Version, "Driver version to be configured.")
cmd.Flags().StringSliceVar(&o.Repos, "repo", config.DefaultDriver.Repos, "Driver repo to be configured.")
cmd.Flags().StringVar(&o.Name, "name", config.DefaultDriver.Name, "Driver name to be configured.")
Expand Down Expand Up @@ -124,7 +125,7 @@ func (o *driverConfigOptions) RunDriverConfig(ctx context.Context, cmd *cobra.Co
if f := cmd.Flags().Lookup("type"); f != nil && f.Changed {
loggerArgs = append(loggerArgs, pterm.LoggerArgument{
Key: "driver type",
Value: o.Type,
Value: o.Type.String(),
})
if o.Type.String() != "auto" {
// Ok driver type was enforced by the user
Expand Down

0 comments on commit e0cf86f

Please sign in to comment.