From b6411be797b381ffc7fede1c2ced29c118f4157b Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Wed, 27 Apr 2016 15:50:56 -0600 Subject: [PATCH] feat(helm): add helm repo list command --- cmd/helm/repo.go | 27 +++++++++++++++++++++++++++ glide.lock | 11 +++++++++-- glide.yaml | 7 ++++--- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/cmd/helm/repo.go b/cmd/helm/repo.go index e60bd5f41..43f32f15a 100644 --- a/cmd/helm/repo.go +++ b/cmd/helm/repo.go @@ -5,12 +5,14 @@ import ( "os" "github.com/deis/tiller/pkg/repo" + "github.com/gosuri/uitable" "github.com/spf13/cobra" "gopkg.in/yaml.v2" ) func init() { repoCmd.AddCommand(repoAddCmd) + repoCmd.AddCommand(repoListCmd) RootCommand.AddCommand(repoCmd) } @@ -25,6 +27,12 @@ var repoAddCmd = &cobra.Command{ RunE: runRepoAdd, } +var repoListCmd = &cobra.Command{ + Use: "list [flags]", + Short: "list chart repositories", + RunE: runRepoList, +} + func runRepoAdd(cmd *cobra.Command, args []string) error { if len(args) != 2 { return fmt.Errorf("This command needs two argument, a name for the chart repository and the url of the chart repository") @@ -38,6 +46,25 @@ func runRepoAdd(cmd *cobra.Command, args []string) error { return nil } +func runRepoList(cmd *cobra.Command, args []string) error { + f, err := repo.LoadRepositoriesFile(repositoriesFile()) + if err != nil { + return err + } + if len(f.Repositories) == 0 { + fmt.Println("No repositories to show") + return nil + } + table := uitable.New() + table.MaxColWidth = 50 + table.AddRow("NAME", "URL") + for k, v := range f.Repositories { + table.AddRow(k, v) + } + fmt.Println(table) + return nil +} + func insertRepoLine(name, url string) error { err := checkUniqueName(name) if err != nil { diff --git a/glide.lock b/glide.lock index c95060074..52380e0f9 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 78e69db1e2c08b4c326c61c47d602ccb5d0d4a782e5047a460e984d0c22f43a3 -updated: 2016-04-27T13:31:53.384640094-07:00 +hash: 998d87445fec0bd715fa5ccbcc227cb4997e56ceff58dc8eb53ea2e0cc84abfd +updated: 2016-04-27T16:11:47.531200165-06:00 imports: - name: bitbucket.org/ww/goautoneg version: 75cd24fc2f2c @@ -121,6 +121,11 @@ imports: - version - name: github.com/google/gofuzz version: bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5 +- name: github.com/gosuri/uitable + version: 36ee7e946282a3fb1cfecd476ddc9b35d8847e42 + subpackages: + - util/strutil + - util/wordwrap - name: github.com/imdario/mergo version: 6633656539c1639d9d78127b7d47c622b5d7b6dc - name: github.com/inconshreveable/mousetrap @@ -131,6 +136,8 @@ imports: version: 808ed7761c233af2de3f9729a041d68c62527f3a - name: github.com/Masterminds/sprig version: e6494bc7e81206ba6db404d2fd96500ffc453407 +- name: github.com/mattn/go-runewidth + version: d6bea18f789704b5f83375793155289da36a3c7f - name: github.com/matttproud/golang_protobuf_extensions version: fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a subpackages: diff --git a/glide.yaml b/glide.yaml index d150d3442..5cc7b0744 100644 --- a/glide.yaml +++ b/glide.yaml @@ -26,6 +26,7 @@ import: - package: k8s.io/kubernetes version: ^1.2 subpackages: - - pkg/client/unversioned/clientcmd - - pkg/kubectl/cmd/util - - pkg/kubectl/resource + - pkg/client/unversioned/clientcmd + - pkg/kubectl/cmd/util + - pkg/kubectl/resource +- package: github.com/gosuri/uitable