Example #1
0
File: chart.go Project: jackgr/helm
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, ".")
}
Example #2
0
func doUpload(filename, cname string, cxt *cli.Context) (string, error) {

	fi, err := os.Stat(filename)
	if err != nil {
		return "", err
	}

	if fi.IsDir() {
		format.Info("Chart is directory")
		c, err := chart.LoadDir(filename)
		if err != nil {
			return "", err
		}
		if cname == "" {
			cname = genName(c.Chartfile().Name)
		}

		// TODO: Is it better to generate the file in temp dir like this, or
		// just put it in the CWD?
		//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
		}
		filename = tfile
	} else if cname == "" {
		n, _, e := parseTarName(filename)
		if e != nil {
			return "", e
		}
		cname = n
	}

	// TODO: Add a version build metadata on the chart.

	if cxt.Bool("dry-run") {
		format.Info("Prepared deploy %q using file %q", cname, filename)
		return "", nil
	}

	c := NewClient(cxt)
	return c.PostChart(filename, cname)
}