From 5826e4f361f767431de00e0a5c1ce42a259b3bd9 Mon Sep 17 00:00:00 2001 From: xichengliudui Date: Wed, 7 Nov 2018 00:57:10 -0500 Subject: [PATCH 1/2] Remove unnecessary code --- cmd/kops/create_cluster.go | 9 +++------ cmd/kops/create_cluster_test.go | 5 ++--- cmd/kops/replace.go | 5 ++--- cmd/kops/root.go | 5 ++--- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index 66184b1ac27e6..c8f69dd3946a3 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -496,9 +496,8 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e if cluster.Spec.CloudProvider == "" { if allZones.Len() == 0 { return fmt.Errorf("must specify --zones or --cloud") - } else { - return fmt.Errorf("unable to infer CloudProvider from Zones (is there a typo in --zones?)") } + return fmt.Errorf("unable to infer CloudProvider from Zones (is there a typo in --zones?)") } } @@ -1368,11 +1367,9 @@ func loadSSHPublicKeys(sshPublicKey string) (map[string][]byte, error) { authorized, err := ioutil.ReadFile(sshPublicKey) if err != nil { return nil, err - } else { - sshPublicKeys[fi.SecretNameSSHPrimary] = authorized - - glog.Infof("Using SSH public key: %v\n", sshPublicKey) } + sshPublicKeys[fi.SecretNameSSHPrimary] = authorized + glog.Infof("Using SSH public key: %v\n", sshPublicKey) } return sshPublicKeys, nil } diff --git a/cmd/kops/create_cluster_test.go b/cmd/kops/create_cluster_test.go index d94eb1e7119f9..17f4b69eaedf6 100644 --- a/cmd/kops/create_cluster_test.go +++ b/cmd/kops/create_cluster_test.go @@ -36,9 +36,8 @@ func checkParse(t *testing.T, s string, expect map[string]string, shouldErr bool if err != nil { if shouldErr { return - } else { - t.Errorf(err.Error()) - } + } + t.Errorf(err.Error()) } for k, v := range expect { diff --git a/cmd/kops/replace.go b/cmd/kops/replace.go index 86375e34428ed..38688946928b5 100644 --- a/cmd/kops/replace.go +++ b/cmd/kops/replace.go @@ -165,9 +165,8 @@ func RunReplace(f *util.Factory, cmd *cobra.Command, out io.Writer, c *replaceOp if err != nil { if errors.IsNotFound(err) { return fmt.Errorf("cluster %q not found", clusterName) - } else { - return fmt.Errorf("error fetching cluster %q: %v", clusterName, err) - } + } + return fmt.Errorf("error fetching cluster %q: %v", clusterName, err) } // check if the instancegroup exists already igName := v.ObjectMeta.Name diff --git a/cmd/kops/root.go b/cmd/kops/root.go index 399a6acc0a314..9c483f567f41b 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -221,9 +221,8 @@ func (c *RootCmd) ProcessArgs(args []string) error { if len(args) == 1 { return fmt.Errorf("Cannot specify cluster via --name and positional argument") - } else { - return fmt.Errorf("expected a single to be passed as an argument") - } + } + return fmt.Errorf("expected a single to be passed as an argument") } func (c *RootCmd) ClusterName() string { From 99795490500800d67323530f8cafe454b96e3f1e Mon Sep 17 00:00:00 2001 From: xichengliudui Date: Thu, 8 Nov 2018 12:40:13 -0500 Subject: [PATCH 2/2] Remove unnecessary code --- cmd/kops/create_cluster_test.go | 2 +- cmd/kops/replace.go | 2 +- cmd/kops/root.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/kops/create_cluster_test.go b/cmd/kops/create_cluster_test.go index 17f4b69eaedf6..483b61303f4a4 100644 --- a/cmd/kops/create_cluster_test.go +++ b/cmd/kops/create_cluster_test.go @@ -36,7 +36,7 @@ func checkParse(t *testing.T, s string, expect map[string]string, shouldErr bool if err != nil { if shouldErr { return - } + } t.Errorf(err.Error()) } diff --git a/cmd/kops/replace.go b/cmd/kops/replace.go index 38688946928b5..7d502583c8aa3 100644 --- a/cmd/kops/replace.go +++ b/cmd/kops/replace.go @@ -165,7 +165,7 @@ func RunReplace(f *util.Factory, cmd *cobra.Command, out io.Writer, c *replaceOp if err != nil { if errors.IsNotFound(err) { return fmt.Errorf("cluster %q not found", clusterName) - } + } return fmt.Errorf("error fetching cluster %q: %v", clusterName, err) } // check if the instancegroup exists already diff --git a/cmd/kops/root.go b/cmd/kops/root.go index 9c483f567f41b..87e02b923f121 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -221,7 +221,7 @@ func (c *RootCmd) ProcessArgs(args []string) error { if len(args) == 1 { return fmt.Errorf("Cannot specify cluster via --name and positional argument") - } + } return fmt.Errorf("expected a single to be passed as an argument") }