Skip to content

Commit

Permalink
Rename errors
Browse files Browse the repository at this point in the history
In practice, go developers tend to use the same error name
err for every error, rather than giving meaningful names.

This patch moves the code in that direction.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Dec 21, 2020
1 parent 539d698 commit 95fc8b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,14 @@ Provide the --local-path flag with --merge if a kubeconfig already exists in som
}

command.PreRunE = func(command *cobra.Command, args []string) error {
_, ipErr := command.Flags().GetIP("ip")
if ipErr != nil {
return ipErr
if _, err := command.Flags().GetIP("ip"); err != nil {
return err
}

_, sshPortErr := command.Flags().GetInt("ssh-port")
if sshPortErr != nil {
return sshPortErr
if _, err := command.Flags().GetInt("ssh-port"); err != nil {
return err
}

return nil
}
return command
Expand Down Expand Up @@ -315,8 +314,8 @@ func obtainKubeconfig(operator operator.CommandOperator, getConfigcommand, host,
}

// Create a new kubeconfig
if writeErr := writeConfig(absPath, []byte(kubeconfig), context, false); writeErr != nil {
return writeErr
if err := writeConfig(absPath, []byte(kubeconfig), context, false); err != nil {
return err
}

return nil
Expand Down Expand Up @@ -353,8 +352,8 @@ func mergeConfigs(localKubeconfigPath, context string, k3sconfig []byte) ([]byte
}
defer file.Close()

if writeErr := writeConfig(file.Name(), []byte(k3sconfig), context, true); writeErr != nil {
return nil, writeErr
if err := writeConfig(file.Name(), []byte(k3sconfig), context, true); err != nil {
return nil, err
}

fmt.Printf("Merging with existing kubeconfig at %s\n", localKubeconfigPath)
Expand Down
6 changes: 3 additions & 3 deletions cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ func MakeJoin() *cobra.Command {
}

sshKey, _ := command.Flags().GetString("ssh-key")
server, getServerErr := command.Flags().GetBool("server")
if getServerErr != nil {
return getServerErr
server, err := command.Flags().GetBool("server")
if err != nil {
return err
}

port, _ := command.Flags().GetInt("ssh-port")
Expand Down

0 comments on commit 95fc8b0

Please sign in to comment.