feat(repo): list repo name and url

* + fix addRepo
pull/448/head
Michelle Noorali 9 years ago
parent efe317791b
commit 174961ab6a

@ -66,19 +66,19 @@ func addRepo(c *cli.Context) error {
return errors.New("'helm repo add' requires a name and repository url as arguments")
}
name := args[0]
repoURL := args[0]
repoURL := args[1]
payload, _ := json.Marshal(repo.Repo{URL: repoURL, Name: name})
msg := ""
if _, err := NewClient(c).Post(chartRepoPath, payload, &msg); err != nil {
//TODO: Return more specific errors to the user
return err
}
format.Info(repoURL + " has been added to your chart repositories!")
format.Info(name + " has been added to your chart repositories!")
return nil
}
func listRepos(c *cli.Context) error {
dest := []string{}
dest := map[string]string{}
if _, err := NewClient(c).Get(chartRepoPath, &dest); err != nil {
return err
}
@ -87,7 +87,10 @@ func listRepos(c *cli.Context) error {
format.Info("Add a chart repository using the `helm repo add [REPOSITORY_URL]` command.")
} else {
format.Msg("Chart Repositories:\n")
format.List(dest)
for k, v := range dest {
//TODO: make formatting pretty
format.Msg(k + "\t" + v + "\n")
}
}
return nil
}

@ -58,7 +58,7 @@ type Manager interface {
GetCredential(name string) (*repo.Credential, error)
// Chart Repositories
ListChartRepos() ([]string, error)
ListChartRepos() (map[string]string, error)
AddChartRepo(addition repo.IRepo) error
RemoveChartRepo(name string) error
GetChartRepo(URL string) (repo.IRepo, error)
@ -367,7 +367,7 @@ func (m *manager) GetChart(reference string) (*chart.Chart, error) {
}
// ListChartRepos returns the list of available chart repository URLs
func (m *manager) ListChartRepos() ([]string, error) {
func (m *manager) ListChartRepos() (map[string]string, error) {
return m.service.ListRepos()
}

@ -95,8 +95,8 @@ func (m *mockManager) AddChartRepo(addition repo.IRepo) error {
return nil
}
func (m *mockManager) ListChartRepos() ([]string, error) {
return []string{}, nil
func (m *mockManager) ListChartRepos() (map[string]string, error) {
return map[string]string{}, nil
}
func (m *mockManager) RemoveChartRepo(name string) error {

@ -42,13 +42,13 @@ func NewInmemRepoService() IRepoService {
}
// ListRepos returns the list of all known chart repositories
func (rs *inmemRepoService) ListRepos() ([]string, error) {
func (rs *inmemRepoService) ListRepos() (map[string]string, error) {
rs.RLock()
defer rs.RUnlock()
ret := []string{}
ret := make(map[string]string)
for _, r := range rs.repositories {
ret = append(ret, r.GetURL())
ret[r.GetName()] = r.GetURL()
}
return ret, nil

@ -118,7 +118,7 @@ type IStorageRepo interface {
// repository based operations, such as search and chart reference resolution.
type IRepoService interface {
// ListRepos returns the list of all known chart repositories
ListRepos() ([]string, error)
ListRepos() (map[string]string, error)
// CreateRepo adds a known repository to the list
CreateRepo(repository IRepo) error
// GetRepoByURL returns the repository with the given name

Loading…
Cancel
Save