diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 2f09be067..eaad0b2c3 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -88,38 +88,3 @@ func NewClient(c *cli.Context) *client.Client { timeout := c.GlobalInt("timeout") return client.NewClient(host).SetDebug(debug).SetTimeout(timeout) } - -func callService(path, method, description string) ([]byte, error) { - dmURL := "http://localhost:8080" - //TODO: dmURL := "http://localhost:8001/api/v1/proxy/namespaces/dm/services/manager-service:manager" - client := &http.Client{} - url, err := formatPath(dmURL, path) - req, err := http.NewRequest(method, url.Path, nil) - if err != nil { - return nil, err - } - resp, err := client.Do(req) - if err != nil { - return nil, err - } - if err != nil { - return nil, err - } - - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - return body, nil -} - -func formatPath(rawURL, route string) (*url.URL, error) { - var URL *url.URL - URL, err := url.Parse(rawURL) - if err != nil { - return nil, err - } - URL.Path = strings.TrimRight(URL.String(), "/") + "/" + strings.TrimLeft(route, "/") - return URL, nil -} diff --git a/cmd/helm/repository.go b/cmd/helm/repository.go index 7863cd05f..69f3ac29d 100644 --- a/cmd/helm/repository.go +++ b/cmd/helm/repository.go @@ -19,6 +19,7 @@ package main import ( "errors" "github.com/codegangsta/cli" + "github.com/kubernetes/helm/pkg/client" "github.com/kubernetes/helm/pkg/format" "os" ) @@ -87,16 +88,29 @@ func addRepo(c *cli.Context) error { if len(args) < 1 { return errors.New("'helm repo add' requires a repository as an argument") } + + dmURL := "http://localhost:8080" + path := "chart_repositories" + client := client.NewClient(dmURL) + var dest string = "" + err := client.CallService(path, "POST", "add a chart repository", &dest, nil) + if err != nil { + return err + } + format.Msg(dest) return nil } func listRepos(c *cli.Context) error { + dmURL := "http://localhost:8080" path := "chart_repositories" - body, err := callService(path, "GET", "list chart repos") + client := client.NewClient(dmURL) + var dest string = "" + err := client.CallService(path, "GET", "list chart repos", &dest, nil) if err != nil { return err } - format.Msg(string(body)) + format.Msg(dest) return nil }