|
|
|
@ -1,13 +1,13 @@
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"errors"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
|
dep "github.com/deis/helm-dm/deploy"
|
|
|
|
|
"github.com/deis/helm-dm/format"
|
|
|
|
|
"github.com/kubernetes/deployment-manager/chart"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func deploy(c *cli.Context) error {
|
|
|
|
@ -35,7 +35,7 @@ func deploy(c *cli.Context) error {
|
|
|
|
|
d.Input = os.Stdin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run"))
|
|
|
|
|
return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run"))
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -44,26 +44,43 @@ func doDeploy(cfg *dep.Deployment, host string, dry bool) error {
|
|
|
|
|
return errors.New("A filename must be specified. For a tar archive, this is the name of the root template in the archive.")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := cfg.Prepare(); err != nil {
|
|
|
|
|
format.Error("Failed to prepare deployment: %s", err)
|
|
|
|
|
fi, err := os.Stat(cfg.Filename)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For a dry run, print the template and exit.
|
|
|
|
|
if dry {
|
|
|
|
|
format.Info("Template prepared for %s", cfg.Template.Name)
|
|
|
|
|
data, err := json.MarshalIndent(cfg.Template, "", "\t")
|
|
|
|
|
if fi.IsDir() {
|
|
|
|
|
format.Info("Chart is directory")
|
|
|
|
|
c, err := chart.LoadDir(cfg.Filename)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//tdir, err := ioutil.TempDir("", "helm-")
|
|
|
|
|
//if err != nil {
|
|
|
|
|
//format.Warn("Could not create temporary directory. Using .")
|
|
|
|
|
//tdir = "."
|
|
|
|
|
//} else {
|
|
|
|
|
//defer os.RemoveAll(tdir)
|
|
|
|
|
//}
|
|
|
|
|
tdir := "."
|
|
|
|
|
tfile, err := chart.Save(c, tdir)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
format.Msg(string(data))
|
|
|
|
|
return nil
|
|
|
|
|
cfg.Filename = tfile
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := cfg.Commit(host); err != nil {
|
|
|
|
|
format.Error("Failed to commit deployment: %s", err)
|
|
|
|
|
return err
|
|
|
|
|
if !dry {
|
|
|
|
|
if err := uploadTar(cfg.Filename); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func uploadTar(filename string) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|