Skip to content

Commit

Permalink
fix(autok3s): fix nil pointer dereference
Browse files Browse the repository at this point in the history
Signed-off-by: Jason-ZW <zhenyang@rancher.com>
  • Loading branch information
rancher-sy-bot committed Oct 13, 2020
1 parent 5d09459 commit efb10d1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func CreateCommand() *cobra.Command {
}

createCmd.Run = func(cmd *cobra.Command, args []string) {
if cProvider == "" {
logrus.Fatalln("required flags(s) \"[provider]\" not set")
}

// must bind after dynamic provider flags loaded.
common.BindPFlags(cmd, cp)

Expand Down
5 changes: 4 additions & 1 deletion cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func init() {
}

func DeleteCommand() *cobra.Command {

pStr := common.FlagHackLookup("--provider")

if pStr != "" {
Expand All @@ -46,6 +45,10 @@ func DeleteCommand() *cobra.Command {
}

deleteCmd.Run = func(cmd *cobra.Command, args []string) {
if dProvider == "" {
logrus.Fatalln("required flags(s) \"[provider]\" not set")
}

common.BindPFlags(cmd, dp)

// read options from config.
Expand Down
4 changes: 4 additions & 0 deletions cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func JoinCommand() *cobra.Command {
}

joinCmd.Run = func(cmd *cobra.Command, args []string) {
if jProvider == "" {
logrus.Fatalln("required flags(s) \"[provider]\" not set")
}

// must bind after dynamic provider flags loaded.
common.BindPFlags(cmd, jp)

Expand Down
4 changes: 4 additions & 0 deletions cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func SSHCommand() *cobra.Command {
}

sshCmd.Run = func(cmd *cobra.Command, args []string) {
if sProvider == "" {
logrus.Fatalln("required flags(s) \"[provider]\" not set")
}

// must bind after dynamic provider flags loaded.
common.BindPFlags(cmd, sp)

Expand Down
5 changes: 4 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func init() {
}

func StartCommand() *cobra.Command {

pStr := common.FlagHackLookup("--provider")

if pStr != "" {
Expand All @@ -44,6 +43,10 @@ func StartCommand() *cobra.Command {
}

startCmd.Run = func(cmd *cobra.Command, args []string) {
if stProvider == "" {
logrus.Fatalln("required flags(s) \"[provider]\" not set")
}

common.BindPFlags(cmd, stP)

// read options from config.
Expand Down
5 changes: 4 additions & 1 deletion cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func init() {
}

func StopCommand() *cobra.Command {

pStr := common.FlagHackLookup("--provider")

if pStr != "" {
Expand All @@ -46,6 +45,10 @@ func StopCommand() *cobra.Command {
}

stopCmd.Run = func(cmd *cobra.Command, args []string) {
if spProvider == "" {
logrus.Fatalln("required flags(s) \"[provider]\" not set")
}

common.BindPFlags(cmd, spP)

// read options from config.
Expand Down

0 comments on commit efb10d1

Please sign in to comment.