ref(repos): clean up repo commands

pull/448/head
Michelle Noorali 9 years ago
parent 162e93413e
commit 75ca24ac90

@ -17,6 +17,7 @@ limitations under the License.
package main package main
import ( import (
"encoding/json"
"errors" "errors"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"github.com/kubernetes/helm/pkg/format" "github.com/kubernetes/helm/pkg/format"
@ -61,19 +62,20 @@ func repoCommands() cli.Command {
func addRepo(c *cli.Context) error { func addRepo(c *cli.Context) error {
args := c.Args() args := c.Args()
if len(args) < 1 { if len(args) < 1 {
return errors.New("'helm repo add' requires a repository as an argument") return errors.New("'helm repo add' requires a repository url as an argument")
} }
repoURL := args[0] repoURL := args[0]
dest := repo.Repo{} payload, _ := json.Marshal(repo.Repo{URL: repoURL})
if _, err := NewClient(c).Post(chartRepoPath, repoURL, &dest); err != nil { msg := ""
if _, err := NewClient(c).Post(chartRepoPath, payload, &msg); err != nil {
return err return err
} }
format.Msg(dest.URL + "has been added to your list of chart repositories") format.Msg(repoURL + " has been added to your list of chart repositories")
return nil return nil
} }
func listRepos(c *cli.Context) error { func listRepos(c *cli.Context) error {
dest := []repo.Repo{} dest := []string{}
if _, err := NewClient(c).Get(chartRepoPath, &dest); err != nil { if _, err := NewClient(c).Get(chartRepoPath, &dest); err != nil {
return err return err
} }
@ -82,9 +84,7 @@ func listRepos(c *cli.Context) error {
format.Info("Add a chart repository using the `helm repo add [REPOSITORY_URL]` command.") format.Info("Add a chart repository using the `helm repo add [REPOSITORY_URL]` command.")
} else { } else {
format.Msg("Chart Repositories:\n") format.Msg("Chart Repositories:\n")
for _, r := range dest { format.List(dest)
format.Msg(r.URL + "\n")
}
} }
return nil return nil
} }
@ -92,13 +92,12 @@ func listRepos(c *cli.Context) error {
func removeRepo(c *cli.Context) error { func removeRepo(c *cli.Context) error {
args := c.Args() args := c.Args()
if len(args) < 1 { if len(args) < 1 {
return errors.New("'helm repo remove' requires a repository as an argument") return errors.New("'helm repo remove' requires a repository url as an argument")
} }
repoURL := args[0] repoURL := args[0]
dest := repo.Repo{URL: repoURL} if _, err := NewClient(c).Delete(chartRepoPath, repoURL); err != nil {
if _, err := NewClient(c).Delete(chartRepoPath, &dest); err != nil {
return err return err
} }
format.Msg(dest.URL + "has been removed.\n") format.Msg(repoURL + "has been removed.\n")
return nil return nil
} }

Loading…
Cancel
Save