From bc4bb79f5cfd379684afc806fac424de20b78910 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Mon, 14 Mar 2016 21:40:10 -0600 Subject: [PATCH] feat(cli): added back 'helm release' This re-adds the top level Helm command that sends a packaged helm chart to the server. This existed in an earlier draft of the Helm-DM client, but it fell through the cracks when we re-organized the helm commands. --- cmd/helm/pack.go | 15 +++++++++++---- cmd/helm/release.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/cmd/helm/pack.go b/cmd/helm/pack.go index 4d1f71d53..62d704923 100644 --- a/cmd/helm/pack.go +++ b/cmd/helm/pack.go @@ -53,12 +53,19 @@ func pack(cxt *cli.Context) error { return fmt.Errorf("Not a directory: %s", dir) } - c, err := chart.LoadDir(dir) + fname, err := packDir(dir) if err != nil { - return fmt.Errorf("Failed to load %s: %s", dir, err) + return err } - - fname, err := chart.Save(c, ".") format.Msg(fname) return nil } + +func packDir(dir string) (string, error) { + c, err := chart.LoadDir(dir) + if err != nil { + return "", fmt.Errorf("Failed to load %s: %s", dir, err) + } + + return chart.Save(c, ".") +} diff --git a/cmd/helm/release.go b/cmd/helm/release.go index 1277a0195..03c92ac9c 100644 --- a/cmd/helm/release.go +++ b/cmd/helm/release.go @@ -17,7 +17,11 @@ limitations under the License. package main import ( + "errors" + "os" + "github.com/codegangsta/cli" + "github.com/kubernetes/deployment-manager/pkg/format" ) func init() { @@ -35,5 +39,30 @@ func releaseCmd() cli.Command { Usage: "Destination URL to which this will be POSTed.", }, }, + Action: func(c *cli.Context) { run(c, release) }, + } +} + +func release(c *cli.Context) error { + a := c.Args() + if len(a) == 0 { + return errors.New("'helm release' requires a path to a chart archive or directory.") } + + var arch string + if fi, err := os.Stat(a[0]); err != nil { + return err + } else if fi.IsDir() { + var err error + arch, err = packDir(a[0]) + if err != nil { + return err + } + } else { + arch = a[0] + } + + u, err := NewClient(c).PostChart(arch, arch) + format.Msg(u) + return err }