Merge pull request #386 from michelleN/add-repo

add repo commands and routes
pull/388/head
Michelle Noorali 9 years ago
commit f43ac30fd5

@ -17,7 +17,10 @@ limitations under the License.
package main package main
import ( import (
"errors"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"github.com/kubernetes/helm/pkg/format"
"os"
) )
func init() { func init() {
@ -40,6 +43,12 @@ func repoCommands() cli.Command {
Usage: "The name of the credential.", 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", Name: "show",
@ -50,13 +59,45 @@ func repoCommands() cli.Command {
Name: "list", Name: "list",
Usage: "List the repositories on the remote manager.", Usage: "List the repositories on the remote manager.",
ArgsUsage: "", 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", Name: "remove",
Aliases: []string{"rm"}, Aliases: []string{"rm"},
Usage: "Remove a repository from the remote manager.", Usage: "Remove a repository from the remote manager.",
ArgsUsage: "REPOSITORY", 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
}

@ -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
}

@ -78,7 +78,7 @@ type Route struct {
Type string Type string
} }
func registerRoutes(c *router.Context, h *router.Handler) { func registerDeploymentRoutes(c *router.Context, h *router.Handler) {
re := regexp.MustCompile("{[a-z]+}") re := regexp.MustCompile("{[a-z]+}")
h.Add("GET /healthz", healthz) h.Add("GET /healthz", healthz)

@ -54,7 +54,8 @@ func main() {
// Set up routes // Set up routes
handler := router.NewHandler(c) handler := router.NewHandler(c)
registerRoutes(c, handler) registerDeploymentRoutes(c, handler)
registerChartRepoRoutes(c, handler)
// Now create a server. // Now create a server.
log.Printf("Starting Manager %s on %s", version.Version, c.Config.Address) log.Printf("Starting Manager %s on %s", version.Version, c.Config.Address)

Loading…
Cancel
Save