feat(repo): hook up `helm repo list` cmd

pull/404/head
Michelle Noorali 9 years ago
parent 3070839117
commit 899dc0b225

@ -17,7 +17,11 @@ limitations under the License.
package main
import (
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
"github.com/codegangsta/cli"
"github.com/kubernetes/helm/pkg/client"
@ -84,3 +88,25 @@ 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"
//dmURL := "http://localhost:8001/api/v1/proxy/namespaces/dm/services/manager-service:manager"
var URL *url.URL
URL, err := url.Parse(dmURL)
if err != nil {
return nil, err
}
URL.Path = strings.TrimRight(URL.String(), "/") + "/" + strings.TrimLeft(path, "/")
resp, err := http.Get(URL.Path) //TODO: change later
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
}

@ -91,6 +91,12 @@ func addRepo(c *cli.Context) error {
}
func listRepos(c *cli.Context) error {
path := "chart_repositories"
body, err := callService(path, "GET", "list chart repos")
if err != nil {
return err
}
format.Msg(string(body))
return nil
}

Loading…
Cancel
Save