Skip to content

Commit

Permalink
remove arbitrary error reporting
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Downs <[email protected]>
  • Loading branch information
briandowns committed Jul 18, 2020
1 parent 65d5224 commit 50750cd
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions pkg/cli/cmds/k3sopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,13 @@ func commandFromK3S(cmd *cli.Command, flagOpts map[string]*K3SFlagOption) (*cli.
}

if opt.Usage != "" {
if err := flagSetUsage(flag, opt); err != nil {
return nil, err
}
flagSetUsage(flag, opt)
}
if opt.Default != "" {
if err := flagSetDefault(flag, opt); err != nil {
return nil, err
}
flagSetDefault(flag, opt)
}
if opt.Hide {
if err := flagSetHide(flag, opt); err != nil {
return nil, err
}
flagSetHide(flag, opt)
}
newFlags = append(newFlags, flag)
}
Expand All @@ -93,7 +87,7 @@ func commandFromK3S(cmd *cli.Command, flagOpts map[string]*K3SFlagOption) (*cli.
// flagSetUsage receives a flag and a K3S flag option, parses
// both and sets the necessary fields based on the underlying
// flag type.
func flagSetUsage(flag cli.Flag, opt *K3SFlagOption) error {
func flagSetUsage(flag cli.Flag, opt *K3SFlagOption) {
v := reflect.ValueOf(flag).Elem()
if v.CanSet() {
switch t := flag.(type) {
Expand All @@ -103,18 +97,14 @@ func flagSetUsage(flag cli.Flag, opt *K3SFlagOption) error {
t.Usage = opt.Usage
case *cli.BoolFlag:
t.Usage = opt.Usage
case *cli.IntFlag:
default:
return fmt.Errorf("error: %T is unsupported", t)
}
}
return nil
}

// flagSetDefault receives a flag and a K3S flag option, parses
// both and sets the necessary fields based on the underlying
// flag type.
func flagSetDefault(flag cli.Flag, opt *K3SFlagOption) error {
func flagSetDefault(flag cli.Flag, opt *K3SFlagOption) {
v := reflect.ValueOf(flag).Elem()
if v.CanSet() {
switch t := flag.(type) {
Expand All @@ -131,18 +121,14 @@ func flagSetDefault(flag cli.Flag, opt *K3SFlagOption) error {
t.DefaultText = opt.Default
t.Destination = &opt.Hide
t.Value = opt.Hide
case *cli.IntFlag:
default:
return fmt.Errorf("error: %T is unsupported", t)
}
}
return nil
}

// flagSetHide receives a flag and a K3S flag option, parses
// both and sets the necessary fields based on the underlying
// flag type.
func flagSetHide(flag cli.Flag, opt *K3SFlagOption) error {
func flagSetHide(flag cli.Flag, opt *K3SFlagOption) {
v := reflect.ValueOf(flag).Elem()
if v.CanSet() {
switch t := flag.(type) {
Expand All @@ -152,10 +138,6 @@ func flagSetHide(flag cli.Flag, opt *K3SFlagOption) error {
t.Hidden = opt.Hide
case *cli.BoolFlag:
t.Hidden = opt.Hide
case *cli.IntFlag:
default:
return fmt.Errorf("error: %T is unsupported", t)
}
}
return nil
}

0 comments on commit 50750cd

Please sign in to comment.