Beispiel #1
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)
}
Beispiel #2
0
func listRepos(c *cli.Context) error {
	dest := map[string]string{}
	if _, err := NewClient(c).Get(chartRepoPath, &dest); err != nil {
		return err
	}
	if len(dest) < 1 {
		format.Info("Looks like you don't have any chart repositories.")
		format.Info("Add a chart repository using the `helm repo add [REPOSITORY_URL]` command.")
	} else {
		format.Msg("Chart Repositories:\n")
		for k, v := range dest {
			//TODO: make formatting pretty
			format.Msg(k + "\t" + v + "\n")
		}
	}
	return nil
}
Beispiel #3
0
func deleteDeployment(c *cli.Context) error {
	args := c.Args()
	if len(args) < 1 {
		return errMissingDeploymentArg
	}
	for _, name := range args {
		deployment, err := NewClient(c).DeleteDeployment(name)
		if err != nil {
			return err
		}
		format.Info("Deleted %q at %s", name, deployment.DeletedAt)
	}
	return nil
}
Beispiel #4
0
func addRepo(c *cli.Context) error {
	args := c.Args()
	if len(args) < 2 {
		return errors.New("'helm repo add' requires a name and repository url as arguments")
	}
	name := args[0]
	repoURL := args[1]
	payload, _ := json.Marshal(repo.Repo{URL: repoURL, Name: name})
	msg := ""
	if _, err := NewClient(c).Post(chartRepoPath, payload, &msg); err != nil {
		return err
	}
	format.Info(name + " has been added to your chart repositories!")
	return nil
}