From 75cbba95e7f24b0a6e0e0c32f023ddac42cf05de Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Wed, 16 Mar 2016 13:59:01 -0600 Subject: [PATCH 1/3] feat(repo): stub repo client commands --- cmd/helm/repository.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/cmd/helm/repository.go b/cmd/helm/repository.go index 520f2f6a3..9340e102e 100644 --- a/cmd/helm/repository.go +++ b/cmd/helm/repository.go @@ -18,6 +18,8 @@ package main import ( "github.com/codegangsta/cli" + "github.com/kubernetes/deployment-manager/pkg/format" + "os" ) func init() { @@ -40,6 +42,12 @@ func repoCommands() cli.Command { Usage: "The name of the credential.", }, }, + Action: func(c *cli.Context) { + if err := addRepo(c); err != nil { + format.Err("%s Error adding chart repo: ", err) + os.Exit(1) + } + }, }, { Name: "show", @@ -50,13 +58,45 @@ func repoCommands() cli.Command { Name: "list", Usage: "List the repositories on the remote manager.", ArgsUsage: "", + Action: func(c *cli.Context) { + if err := listRepos(c); err != nil { + format.Err("%s Error listing chart repositories: ", err) + os.Exit(1) + } + }, }, { Name: "remove", Aliases: []string{"rm"}, Usage: "Remove a repository from the remote manager.", ArgsUsage: "REPOSITORY", + Action: func(c *cli.Context) { + if err := removeRepo(c); err != nil { + format.Err("%s Error removing chart repo: ", err) + os.Exit(1) + } + }, }, }, } } + +func addRepo(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return errors.New("'helm repo add' requires a repository as an argument") + } + return nil +} + +func listRepos(c *cli.Context) error { + return nil +} + +func removeRepo(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return errors.New("'helm repo remove' requires a repository as an argument") + } + return nil +} From 07e05429775e30a16057045061cb40f9ea8223a4 Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Wed, 16 Mar 2016 14:06:30 -0600 Subject: [PATCH 2/3] feat(repos): add routes for chart repo management --- cmd/manager/chartrepos.go | 31 +++++++++++++++++++++++++++++++ cmd/manager/deployments.go | 2 +- cmd/manager/main.go | 3 ++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 cmd/manager/chartrepos.go diff --git a/cmd/manager/chartrepos.go b/cmd/manager/chartrepos.go new file mode 100644 index 000000000..07b3bfda7 --- /dev/null +++ b/cmd/manager/chartrepos.go @@ -0,0 +1,31 @@ +package main + +import ( + "github.com/kubernetes/helm/cmd/manager/router" + "github.com/kubernetes/helm/pkg/util" + "net/http" +) + +func registerChartRepoRoutes(c *router.Context, h *router.Handler) { + h.Add("GET /chart_repositories", listChartRepositoriesHandlerFunc) + h.Add("POST /chart_repositories", addChartRepoHandlerFunc) + h.Add("DELETE /chart_repositories", removeChartRepoHandlerFunc) +} + +func listChartRepositoriesHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error { + handler := "manager: list chart repositories" + util.LogHandlerExitWithJSON(handler, w, "a repo here", http.StatusOK) + return nil +} + +func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error { + handler := "manager: add chart repository" + util.LogHandlerExitWithJSON(handler, w, "add a repo", http.StatusOK) + return nil +} + +func removeChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.Context) error { + handler := "manager: remove chart repository" + util.LogHandlerExitWithJSON(handler, w, "remove a repo", http.StatusOK) + return nil +} diff --git a/cmd/manager/deployments.go b/cmd/manager/deployments.go index 9cc403420..9076a7d89 100644 --- a/cmd/manager/deployments.go +++ b/cmd/manager/deployments.go @@ -78,7 +78,7 @@ type Route struct { Type string } -func registerRoutes(c *router.Context, h *router.Handler) { +func registerDeploymentRoutes(c *router.Context, h *router.Handler) { re := regexp.MustCompile("{[a-z]+}") h.Add("GET /healthz", healthz) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index ce570a8dd..126e9ed77 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -54,7 +54,8 @@ func main() { // Set up routes handler := router.NewHandler(c) - registerRoutes(c, handler) + registerDeploymentRoutes(c, handler) + registerChartRepoRoutes(c, handler) // Now create a server. log.Printf("Starting Manager %s on %s", version.Version, c.Config.Address) From 29b1325fae5329f7ff10666dcc245d9508918540 Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Wed, 16 Mar 2016 16:32:52 -0600 Subject: [PATCH 3/3] ref(repo): update import path --- cmd/helm/repository.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/helm/repository.go b/cmd/helm/repository.go index 9340e102e..8cd52273d 100644 --- a/cmd/helm/repository.go +++ b/cmd/helm/repository.go @@ -17,8 +17,9 @@ limitations under the License. package main import ( + "errors" "github.com/codegangsta/cli" - "github.com/kubernetes/deployment-manager/pkg/format" + "github.com/kubernetes/helm/pkg/format" "os" )