From a19875adcc3b3a9fe5b086d94acfbfb7a4a1aabb Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 25 May 2016 00:02:52 -0700 Subject: [PATCH] fix(style): cleanup coding style on error returns --- cmd/helm/create.go | 7 ++----- cmd/helm/repo.go | 22 ++++------------------ cmd/helm/tunnel.go | 2 +- pkg/chart/chart_test.go | 6 +----- pkg/chart/save.go | 6 +----- pkg/repo/local.go | 6 +----- pkg/repo/repo.go | 12 ++---------- 7 files changed, 12 insertions(+), 49 deletions(-) diff --git a/cmd/helm/create.go b/cmd/helm/create.go index 1cf1e949c..fff8778ae 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -55,9 +55,6 @@ func runCreate(cmd *cobra.Command, args []string) error { Version: "0.1.0", } - if _, err := chart.Create(&cfile, filepath.Dir(cname)); err != nil { - return err - } - - return nil + _, err := chart.Create(&cfile, filepath.Dir(cname)) + return err } diff --git a/cmd/helm/repo.go b/cmd/helm/repo.go index cb09b0046..6c0119da0 100644 --- a/cmd/helm/repo.go +++ b/cmd/helm/repo.go @@ -89,10 +89,7 @@ func runRepoRemove(cmd *cobra.Command, args []string) error { if err := checkArgsLength(1, len(args), "name of chart repository"); err != nil { return err } - if err := removeRepoLine(args[0]); err != nil { - return err - } - return nil + return removeRepoLine(args[0]) } func runRepoIndex(cmd *cobra.Command, args []string) error { @@ -105,11 +102,7 @@ func runRepoIndex(cmd *cobra.Command, args []string) error { return err } - if err := index(path, args[1]); err != nil { - return err - } - - return nil + return index(path, args[1]) } func index(dir, url string) error { @@ -118,10 +111,7 @@ func index(dir, url string) error { return err } - if err := chartRepo.Index(); err != nil { - return err - } - return nil + return chartRepo.Index() } func removeRepoLine(name string) error { @@ -165,9 +155,5 @@ func insertRepoLine(name, url string) error { f.Repositories[name] = url b, _ := yaml.Marshal(&f.Repositories) - if err := ioutil.WriteFile(repositoriesFile(), b, 0666); err != nil { - return err - } - - return nil + return ioutil.WriteFile(repositoriesFile(), b, 0666) } diff --git a/cmd/helm/tunnel.go b/cmd/helm/tunnel.go index 97de02960..a626ff59f 100644 --- a/cmd/helm/tunnel.go +++ b/cmd/helm/tunnel.go @@ -17,7 +17,7 @@ func newTillerPortForwarder() (*kube.Tunnel, error) { if err != nil { return nil, err } - // FIXME use a constain that is accessable on init + // FIXME use a constain that is accessible on init const tillerPort = 44134 return kube.New(nil).ForwardPort("helm", podName, tillerPort) } diff --git a/pkg/chart/chart_test.go b/pkg/chart/chart_test.go index f7c804c1e..6ed4e4f84 100644 --- a/pkg/chart/chart_test.go +++ b/pkg/chart/chart_test.go @@ -191,11 +191,7 @@ func findMember(root, path string, members []*Member) error { for _, member := range members { if member.Path == path { filename := filepath.Join(root, path) - if err := compareContent(filename, member.Content); err != nil { - return err - } - - return nil + return compareContent(filename, member.Content) } } diff --git a/pkg/chart/save.go b/pkg/chart/save.go index d6fc5600e..5b8b302ed 100644 --- a/pkg/chart/save.go +++ b/pkg/chart/save.go @@ -103,11 +103,7 @@ func Save(c *Chart, outDir string) (string, error) { } _, err = io.Copy(twriter, in) in.Close() - if err != nil { - return err - } - - return nil + return err }) if err != nil { rollback = true diff --git a/pkg/repo/local.go b/pkg/repo/local.go index ec6e13a07..2dbdb98e5 100644 --- a/pkg/repo/local.go +++ b/pkg/repo/local.go @@ -46,11 +46,7 @@ func AddChartToLocalRepo(ch *chart.Chart, path string) error { if err != nil { return err } - err = Reindex(ch, path+"/index.yaml") - if err != nil { - return err - } - return nil + return Reindex(ch, path+"/index.yaml") } // Reindex adds an entry to the index file at the given path diff --git a/pkg/repo/repo.go b/pkg/repo/repo.go index b5a388020..5da66911e 100644 --- a/pkg/repo/repo.go +++ b/pkg/repo/repo.go @@ -98,11 +98,7 @@ func (r *ChartRepository) saveIndexFile() error { return err } - if err = ioutil.WriteFile(filepath.Join(r.RootPath, indexPath), index, 0644); err != nil { - return err - } - - return nil + return ioutil.WriteFile(filepath.Join(r.RootPath, indexPath), index, 0644) } func (r *ChartRepository) Index() error { @@ -143,11 +139,7 @@ func (r *ChartRepository) Index() error { } - if err := r.saveIndexFile(); err != nil { - return err - } - - return nil + return r.saveIndexFile() } func generateChecksum(path string) (string, error) {