diff --git a/cmd/helm/create.go b/cmd/helm/create.go new file mode 100644 index 000000000..95bd3016f --- /dev/null +++ b/cmd/helm/create.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + + "github.com/codegangsta/cli" + "github.com/kubernetes/deployment-manager/chart" +) + +func create(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return fmt.Errorf("'helm create' requires a chart name as an argument.") + } + + cf := &chart.Chartfile{ + Name: args[0], + Description: "Created by Helm", + Version: "0.1.0", + } + + _, err := chart.Create(cf, ".") + return err +} diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index 80faeea6d..e8776c290 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -3,12 +3,43 @@ package main import ( "encoding/json" "errors" + "os" + "github.com/codegangsta/cli" dep "github.com/deis/helm-dm/deploy" "github.com/deis/helm-dm/format" ) -func deploy(cfg *dep.Deployment, host string, dry bool) error { +func deploy(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + format.Error("First argument, filename, is required. Try 'helm deploy --help'") + os.Exit(1) + } + + props, err := parseProperties(c.String("properties")) + if err != nil { + format.Error("Failed to parse properties: %s", err) + os.Exit(1) + } + + d := &dep.Deployment{ + Name: c.String("Name"), + Properties: props, + Filename: args[0], + Imports: args[1:], + Repository: c.String("repository"), + } + + if c.Bool("stdin") { + d.Input = os.Stdin + } + + //return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run")) + return nil +} + +func doDeploy(cfg *dep.Deployment, host string, dry bool) error { if cfg.Filename == "" { return errors.New("A filename must be specified. For a tar archive, this is the name of the root template in the archive.") } diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index bbae7554b..8ae38aa87 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -4,7 +4,6 @@ import ( "os" "github.com/codegangsta/cli" - dep "github.com/deis/helm-dm/deploy" "github.com/deis/helm-dm/format" ) @@ -125,41 +124,22 @@ func commands() []cli.Command { } }, }, + { + Name: "create", + Usage: "Create a new local chart for editing.", + Action: func(c *cli.Context) { run(c, create) }, + }, + { + Name: "package", + Aliases: []string{"pack"}, + Usage: "Given a chart directory, package it into a release.", + Action: func(c *cli.Context) { run(c, pack) }, + }, { Name: "deploy", Aliases: []string{"install"}, Usage: "Deploy a chart into the cluster.", - Action: func(c *cli.Context) { - - args := c.Args() - if len(args) < 1 { - format.Error("First argument, filename, is required. Try 'helm deploy --help'") - os.Exit(1) - } - - props, err := parseProperties(c.String("properties")) - if err != nil { - format.Error("Failed to parse properties: %s", err) - os.Exit(1) - } - - d := &dep.Deployment{ - Name: c.String("Name"), - Properties: props, - Filename: args[0], - Imports: args[1:], - Repository: c.String("repository"), - } - - if c.Bool("stdin") { - d.Input = os.Stdin - } - - if err := deploy(d, c.GlobalString("host"), c.Bool("dry-run")); err != nil { - format.Error("%s (Try running 'helm doctor')", err) - os.Exit(1) - } - }, + Action: func(c *cli.Context) { run(c, deploy) }, Flags: []cli.Flag{ cli.BoolFlag{ Name: "dry-run", @@ -193,3 +173,10 @@ func commands() []cli.Command { listCmd(), } } + +func run(c *cli.Context, f func(c *cli.Context) error) { + if err := f(c); err != nil { + os.Stderr.Write([]byte(err.Error())) + os.Exit(1) + } +} diff --git a/cmd/helm/pack.go b/cmd/helm/pack.go new file mode 100644 index 000000000..dea528f61 --- /dev/null +++ b/cmd/helm/pack.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "os" + + "github.com/codegangsta/cli" + "github.com/deis/helm-dm/format" + "github.com/kubernetes/deployment-manager/chart" +) + +func pack(cxt *cli.Context) error { + args := cxt.Args() + if len(args) < 1 { + return fmt.Errorf("'helm package' requires a path to a chart directory as an argument.") + } + + dir := args[0] + if fi, err := os.Stat(dir); err != nil { + return fmt.Errorf("Could not find directory %s: %s", dir, err) + } else if !fi.IsDir() { + return fmt.Errorf("Not a directory: %s", dir) + } + + c, err := chart.LoadDir(dir) + if err != nil { + return fmt.Errorf("Failed to load %s: %s", dir, err) + } + + fname, err := chart.Save(c, ".") + format.Msg(fname) + return nil +} diff --git a/deploy/deploy.go b/deploy/deploy.go index 1ba09e394..43c45aefe 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -1,16 +1,16 @@ package deploy import ( - "archive/tar" - "errors" - "fmt" + //"archive/tar" + //"errors" + //"fmt" "os" - "strings" + //"strings" - "github.com/ghodss/yaml" + //"github.com/ghodss/yaml" "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/expandybird/expander" - "github.com/kubernetes/deployment-manager/registry" + //"github.com/kubernetes/deployment-manager/expandybird/expander" + //"github.com/kubernetes/deployment-manager/registry" ) // Deployer is capable of deploying an object to a back-end. @@ -48,17 +48,19 @@ type Deployment struct { // This will generate the Template based on other information. func (d *Deployment) Prepare() error { - tpl, err := d.resolveTemplate() - if err != nil { - return err - } + /* + tpl, err := d.resolveTemplate() + if err != nil { + return err + } - // If a deployment Name is specified, set that explicitly. - if d.Name != "" { - tpl.Name = d.Name - } + // If a deployment Name is specified, set that explicitly. + if d.Name != "" { + tpl.Name = d.Name + } - d.Template = tpl + d.Template = tpl + */ return nil } @@ -68,6 +70,7 @@ func (d *Deployment) Commit(host string) error { return nil } +/* // resolveTemplate resolves what kind of template is being loaded, and then returns the template. func (d *Deployment) resolveTemplate() (*common.Template, error) { // If some input has been specified, read it. @@ -179,3 +182,4 @@ func getGitRegistry(reg string) (registry.Registry, error) { return r, nil } } +*/ diff --git a/glide.lock b/glide.lock index ddd774cc4..d34eae154 100644 --- a/glide.lock +++ b/glide.lock @@ -1,53 +1,56 @@ -hash: 4cc1aba06a344d43c0c1005d71dc0659ada5d90f0b2235b1d8e8c7352d1251a7 -updated: 2016-01-06T14:30:55.041267875-08:00 +hash: fce0581223b80f7a04fbb4ad4bd7ff8fa3d12e879dba894ba448770933731887 +updated: 2016-02-02T17:30:13.283644703-07:00 imports: - name: github.com/codegangsta/cli - version: c31a7975863e7810c92e2e288a9ab074f9a88f29 + version: cf1f63a7274872768d4037305d572b70b1199397 - name: github.com/emicklei/go-restful - version: ce94a9f819d7dd2b5599ff0c017b1124595a64fb + version: b86acf97a74ed7603ac78d012f5535b4d587b156 - name: github.com/ghodss/yaml version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee - name: github.com/golang/glog - version: fca8c8854093a154ff1eb580aae10276ad6b1b5f + version: 23def4e6c14b4da8ac2ed8007337bc5eb5007998 - name: github.com/golang/protobuf - version: 2402d76f3d41f928c7902a765dfc872356dd3aad + version: 45bba206dd5270d96bac4942dcfe515726613249 - name: github.com/google/go-github - version: 63fbbb283ce4913a5ac1b6de7abae50dbf594a04 + version: b8b4ac742977310ff6e75140a403a38dab109977 + subpackages: + - /github - name: github.com/google/go-querystring version: 2a60fc2ba6c19de80291203597d752e9ba58e4c0 - name: github.com/gorilla/context version: 1c83b3eabd45b6d76072b66b746c20815fb2872d - name: github.com/gorilla/handlers - version: 1af6d56d7cd39d982856bc0cee11142baf392c52 + version: b3aff83722cb2ae031a70cae984650e3a16cd20e - name: github.com/gorilla/mux version: 26a6070f849969ba72b72256e9f14cf519751690 - name: github.com/gorilla/schema version: 14c555599c2a4f493c1e13fd1ea6fdf721739028 - name: github.com/kubernetes/deployment-manager - version: 62f19486073edd020a11922304130f0c5c1dff20 + version: "" + repo: https://github.com/technosophos/deployment-manager + vcs: git subpackages: - /common +- name: github.com/Masterminds/semver + version: c4f7ef0702f269161a60489ccbbc9f1241ad1265 - name: github.com/mjibson/appstats version: 0542d5f0e87ea3a8fa4174322b9532f5d04f9fa8 - name: golang.org/x/crypto - version: 552e9d568fde9701ea1944fb01c8aadaceaa7353 + version: 1f22c0103821b9390939b6776727195525381532 - name: golang.org/x/net - version: 1ade16a5450925b7496e1031938175d1f5d30d31 + version: 6c581b96a7d38dd755f986fcf4f29665597694c0 - name: golang.org/x/oauth2 - version: 2baa8a1b9338cf13d9eeb27696d761155fa480be + version: 8a57ed94ffd43444c0879fe75701732a38afc985 - name: golang.org/x/text - version: cf4986612c83df6c55578ba198316d1684a9a287 -- name: google.golang.com/appengine - version: "" - repo: https://google.golang.com/appengine + version: 5aaa1a807bf8a2f763540b140e7805973476eb88 - name: google.golang.org/api - version: f5b7ec483f357a211c03c6722a840444c2d395dc + version: 8fa1015948e6fc21c025050624e4c4e2f4f405c4 - name: google.golang.org/appengine - version: 54bf9150c922186bfc45a00bf9dfcb91a5063275 + version: 6bde959377a90acb53366051d7d587bfd7171354 - name: google.golang.org/cloud - version: 1bff51b8fae8d33cb3dab8f7858c266ce001ee3e + version: 5a3b06f8b5da3b7c3a93da43163b872c86c509ef - name: google.golang.org/grpc - version: 78905999da08d7f87d5dd11608fa79ff8700daa8 + version: 5d64098b94ee9dbbea8ddc130208696bcd199ba4 - name: gopkg.in/yaml.v2 version: f7716cbe52baa25d2e9b0d0da546fcf909fc16b4 devImports: [] diff --git a/glide.yaml b/glide.yaml index 35922b0fc..dd229737b 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,7 +1,13 @@ package: github.com/deis/helm-dm +ignore: +- google.golang.com/appengine import: - package: github.com/codegangsta/cli - package: github.com/kubernetes/deployment-manager + version: feat/chartfile + repo: https://github.com/technosophos/deployment-manager + vcs: git subpackages: - /common - package: github.com/ghodss/yaml +- package: github.com/Masterminds/semver