Exemple #1
0
// Create a chart
//
// - chartName being created
// - homeDir is the helm home directory for the user
func Create(chartName, homeDir string) {

	chart := newSkelChartfile(chartName)
	chartDir := filepath.Join(homeDir, WorkspaceChartPath, chartName)

	// create directories
	if err := os.MkdirAll(filepath.Join(chartDir, "manifests"), 0755); err != nil {
		log.Die("Could not create %q: %s", chartDir, err)
	}

	// create Chartfile.yaml
	if err := chart.Save(filepath.Join(chartDir, "Chart.yaml")); err != nil {
		log.Die("Could not create Chart.yaml: err", err)
	}

	// create README.md
	if err := createReadme(chartDir, chart); err != nil {
		log.Die("Could not create README.md: err", err)
	}

	// create example-pod
	if err := createExampleManifest(chartDir); err != nil {
		log.Die("Could not create example manifest: err", err)
	}

	log.Info("Created chart in %s", chartDir)
}
Exemple #2
0
// ensureHome ensures that a HELM_HOME exists.
func ensureHome(home string) {

	must := []string{home, filepath.Join(home, CachePath), filepath.Join(home, WorkspacePath), filepath.Join(home, CacheChartPath)}

	for _, p := range must {
		if fi, err := os.Stat(p); err != nil {
			log.Debug("Creating %s", p)
			if err := os.MkdirAll(p, 0755); err != nil {
				log.Die("Could not create %q: %s", p, err)
			}
		} else if !fi.IsDir() {
			log.Die("%s must be a directory.", home)
		}
	}

	refi := filepath.Join(home, Configfile)
	if _, err := os.Stat(refi); err != nil {
		log.Info("Creating %s", refi)
		// Attempt to create a Repos.yaml
		if err := ioutil.WriteFile(refi, []byte(config.DefaultConfigfile), 0755); err != nil {
			log.Die("Could not create %s: %s", refi, err)
		}
	}

	if err := os.Chdir(home); err != nil {
		log.Die("Could not change to directory %q: %s", home, err)
	}
}
Exemple #3
0
// Edit charts using the shell-defined $EDITOR
//
// - chartName being edited
// - homeDir is the helm home directory for the user
func Edit(chartName, homeDir string) {

	chartDir := path.Join(homeDir, "workspace", "charts", chartName)

	// enumerate chart files
	files, err := listChart(chartDir)
	if err != nil {
		log.Die("could not list chart: %v", err)
	}

	// join chart with YAML delimeters
	contents, err := joinChart(chartDir, files)
	if err != nil {
		log.Die("could not join chart data: %v", err)
	}

	// write chart to temporary file
	f, err := ioutil.TempFile(os.TempDir(), "helm-edit")
	if err != nil {
		log.Die("could not open tempfile: %v", err)
	}
	f.Write(contents.Bytes())
	f.Close()

	// NOTE: removing the tempfile causes issues with editors
	// that fork, so we let the OS remove them later

	openEditor(f.Name())
	saveChart(chartDir, f.Name())

}
Exemple #4
0
// ensurePrereqs verifies that Git and Kubectl are both available.
func ensurePrereqs() {
	if _, err := exec.LookPath("git"); err != nil {
		log.Die("Could not find 'git' on $PATH: %s", err)
	}
	if _, err := exec.LookPath("kubectl"); err != nil {
		log.Die("Could not find 'kubectl' on $PATH: %s", err)
	}
}
Exemple #5
0
// DeleteRepo deletes a repository.
func DeleteRepo(homedir, name string) {
	cfg := mustConfig(homedir)

	if err := cfg.Repos.Delete(name); err != nil {
		log.Die("Failed to delete repository: %s", err)
	}
	if err := cfg.Save(""); err != nil {
		log.Die("Deleted repo, but could not save settings: %s", err)
	}
}
Exemple #6
0
// AddRepo adds a repo to the list of repositories.
func AddRepo(homedir, name, repository string) {
	cfg := mustConfig(homedir)

	if err := cfg.Repos.Add(name, repository); err != nil {
		log.Die(err.Error())
	}
	if err := cfg.Save(""); err != nil {
		log.Die("Could not save configuration: %s", err)
	}
}
Exemple #7
0
// Remove removes a chart from the workdir.
//
// - chart is the source
// - homedir is the home directory for the user
func Remove(chart string, homedir string) {
	chartPath := filepath.Join(homedir, WorkspaceChartPath, chart)
	if _, err := os.Stat(chartPath); err != nil {
		log.Die("Chart not found. %s", err)
	}

	if err := os.RemoveAll(chartPath); err != nil {
		log.Die("%s", err)
	}

	log.Info("All clear! You have successfully removed %s from your workspace.", chart)
}
Exemple #8
0
// saveChart reads a delimited chart and write out its parts
// to the workspace directory
func saveChart(chartDir string, filename string) error {

	// read the serialized chart file
	contents, err := ioutil.ReadFile(filename)
	if err != nil {
		return err
	}

	chartData := make(map[string][]byte)

	// use a regular expression to read file paths and content
	match := delimeterRegexp.FindAllSubmatch(contents, -1)
	for _, m := range match {
		chartData[string(m[1])] = m[2]
	}

	// save edited chart data to the workspace
	for k, v := range chartData {
		fp := path.Join(chartDir, k)
		if err := ioutil.WriteFile(fp, v, 0644); err != nil {
			log.Die("could not write chart file", err)
		}
	}
	return nil

}
Exemple #9
0
// Update fetches the remote repo into the home directory.
func Update(home string) {
	home, err := filepath.Abs(home)
	if err != nil {
		log.Die("Could not generate absolute path for %q: %s", home, err)
	}

	// Basically, install if this is the first run.
	ensurePrereqs()
	ensureHome(home)

	rc := mustConfig(home).Repos
	if err := rc.UpdateAll(); err != nil {
		log.Die("Not all repos could be updated: %s", err)
	}
	log.Info("Done")
}
Exemple #10
0
// Fetch gets a chart from the source repo and copies to the workdir.
//
// - chartName is the source
// - lname is the local name for that chart (chart-name); if blank, it is set to the chart.
// - homedir is the home directory for the user
func Fetch(chartName, lname, homedir string) {

	r := mustConfig(homedir).Repos
	repository, chartName := r.RepoChart(chartName)

	if lname == "" {
		lname = chartName
	}

	fetch(chartName, lname, homedir, repository)

	chartFilePath := filepath.Join(homedir, WorkspaceChartPath, lname, "Chart.yaml")
	cfile, err := chart.LoadChartfile(chartFilePath)
	if err != nil {
		log.Die("Source is not a valid chart. Missing Chart.yaml: %s", err)
	}

	deps, err := dependency.Resolve(cfile, filepath.Join(homedir, WorkspaceChartPath))
	if err != nil {
		log.Warn("Could not check dependencies: %s", err)
		return
	}

	if len(deps) > 0 {
		log.Warn("Unsatisfied dependencies:")
		for _, d := range deps {
			log.Msg("\t%s %s", d.Name, d.Version)
		}
	}

	log.Info("Fetched chart into workspace %s", filepath.Join(homedir, WorkspaceChartPath, lname))
	log.Info("Done")
}
Exemple #11
0
func search(term, base, table string, charts map[string]*chart.Chartfile) error {
	dirs, err := filepath.Glob(base)
	if err != nil {
		return fmt.Errorf("No results found. %s", err)
	} else if len(dirs) == 0 {
		return errors.New("No results found.")
	}

	r, err := regexp.Compile(term)
	if err != nil {
		log.Die("Invalid expression %q: %s", term, err)
	}

	for _, dir := range dirs {
		cname := filepath.Join(table, filepath.Base(dir))
		chrt, err := chart.LoadChartfile(filepath.Join(dir, "Chart.yaml"))

		if err != nil {
			// This dir is not a chart. Skip it.
			continue
		} else if r.MatchString(chrt.Name) || r.MatchString(chrt.Description) {
			charts[cname] = chrt
		}
	}

	return nil
}
Exemple #12
0
// Install loads a chart into Kubernetes.
//
// If the chart is not found in the workspace, it is fetched and then installed.
//
// During install, manifests are sent to Kubernetes in the following order:
//
//	- Namespaces
// 	- Secrets
// 	- Volumes
// 	- Services
// 	- Pods
// 	- ReplicationControllers
func Install(chartName, home, namespace string, force bool, dryRun bool) {

	ochart := chartName
	r := mustConfig(home).Repos
	table, chartName := r.RepoChart(chartName)

	if !chartFetched(chartName, home) {
		log.Info("No chart named %q in your workspace. Fetching now.", ochart)
		fetch(chartName, chartName, home, table)
	}

	cd := filepath.Join(home, WorkspaceChartPath, chartName)
	c, err := chart.Load(cd)
	if err != nil {
		log.Die("Failed to load chart: %s", err)
	}

	// Give user the option to bale if dependencies are not satisfied.
	nope, err := dependency.Resolve(c.Chartfile, filepath.Join(home, WorkspaceChartPath))
	if err != nil {
		log.Warn("Failed to check dependencies: %s", err)
		if !force {
			log.Die("Re-run with --force to install anyway.")
		}
	} else if len(nope) > 0 {
		log.Warn("Unsatisfied dependencies:")
		for _, d := range nope {
			log.Msg("\t%s %s", d.Name, d.Version)
		}
		if !force {
			log.Die("Stopping install. Re-run with --force to install anyway.")
		}
	}

	msg := "Running `kubectl create -f` ..."
	if dryRun {
		msg = "Performing a dry run of `kubectl create -f` ..."
	}
	log.Info(msg)
	if err := uploadManifests(c, namespace, dryRun); err != nil {
		log.Die("Failed to upload manifests: %s", err)
	}
	log.Info("Done")

	PrintREADME(chartName, home)
}
Exemple #13
0
// Target displays information about the cluster
func Target() {
	if _, err := exec.LookPath("kubectl"); err != nil {
		log.Die("Could not find 'kubectl' on $PATH: %s", err)
	}

	c, _ := exec.Command("kubectl", "cluster-info").Output()
	fmt.Println(string(c))
}
Exemple #14
0
// Uninstall removes a chart from Kubernetes.
//
// Manifests are removed from Kubernetes in the following order:
//
// 	- Services (to shut down traffic)
// 	- Pods (which can be part of RCs)
// 	- ReplicationControllers
// 	- Volumes
// 	- Secrets
//	- Namespaces
func Uninstall(chartName, home, namespace string) {
	if !chartFetched(chartName, home) {
		log.Info("No chart named %q in your workspace. Nothing to delete.", chartName)
		return
	}

	cd := filepath.Join(home, WorkspaceChartPath, chartName)
	c, err := chart.Load(cd)
	if err != nil {
		log.Die("Failed to load chart: %s", err)
	}

	log.Info("Running `kubectl delete` ...")
	if err := deleteChart(c, namespace); err != nil {
		log.Die("Failed to completely delete chart: %s", err)
	}
	log.Info("Done")
}
Exemple #15
0
func fetch(chartName, lname, homedir, chartpath string) {
	src := filepath.Join(homedir, CachePath, chartpath, chartName)
	dest := filepath.Join(homedir, WorkspaceChartPath, lname)

	if fi, err := os.Stat(src); err != nil {
		log.Die("Chart %s not found in %s", lname, src)
	} else if !fi.IsDir() {
		log.Die("Malformed chart %s: Chart must be in a directory.", chartName)
	}

	if err := os.MkdirAll(dest, 0755); err != nil {
		log.Die("Could not create %q: %s", dest, err)
	}

	log.Debug("Fetching %s to %s", src, dest)
	if err := copyDir(src, dest); err != nil {
		log.Die("Failed copying %s to %s", src, dest)
	}
}
Exemple #16
0
// minArgs checks to see if the right number of args are passed.
//
// If not, it prints an error and quits.
func minArgs(c *cli.Context, i int, name string) {
	if len(c.Args()) < i {
		m := "arguments"
		if i == 1 {
			m = "argument"
		}
		log.Err("Expected %d %s", i, m)
		cli.ShowCommandHelp(c, name)
		log.Die("")
	}
}
Exemple #17
0
// ensureRepo ensures that the repo exists and is checked out.
// DEPRECATED: You should use the functions in package `repo` instead.
func ensureRepo(repo, home string) *vcs.GitRepo {
	if err := os.Chdir(home); err != nil {
		log.Die("Could not change to directory %q: %s", home, err)
	}
	git, err := vcs.NewGitRepo(repo, home)
	if err != nil {
		log.Die("Could not get repository %q: %s", repo, err)
	}

	git.Logger = log.New()

	if !git.CheckLocal() {
		log.Debug("Cloning repo into %q. Please wait.", home)
		if err := git.Get(); err != nil {
			log.Die("Could not create repository in %q: %s", home, err)
		}
	}

	return git
}
Exemple #18
0
// AltInstall allows loading a chart from the current directory.
//
// It does not directly support chart tables (repos).
func AltInstall(chartName, cachedir, home, namespace string, force bool, dryRun bool) {
	// Make sure there is a chart in the cachedir.
	if _, err := os.Stat(filepath.Join(cachedir, "Chart.yaml")); err != nil {
		log.Die("Expected a Chart.yaml in %s: %s", cachedir, err)
	}
	// Make sure there is a manifests dir.
	if fi, err := os.Stat(filepath.Join(cachedir, "manifests")); err != nil {
		log.Die("Expected 'manifests/' in %s: %s", cachedir, err)
	} else if !fi.IsDir() {
		log.Die("Expected 'manifests/' to be a directory in %s: %s", cachedir, err)
	}

	// Copy the source chart to the workspace. We ruthlessly overwrite in
	// this case.
	dest := filepath.Join(home, WorkspaceChartPath, chartName)
	if err := copyDir(cachedir, dest); err != nil {
		log.Die("Failed to copy %s to %s: %s", cachedir, dest, err)
	}

	// Load the chart.
	c, err := chart.Load(dest)
	if err != nil {
		log.Die("Failed to load chart: %s", err)
	}

	// Give user the option to bale if dependencies are not satisfied.
	nope, err := dependency.Resolve(c.Chartfile, filepath.Join(home, WorkspaceChartPath))
	if err != nil {
		log.Warn("Failed to check dependencies: %s", err)
		if !force {
			log.Die("Re-run with --force to install anyway.")
		}
	} else if len(nope) > 0 {
		log.Warn("Unsatisfied dependencies:")
		for _, d := range nope {
			log.Msg("\t%s %s", d.Name, d.Version)
		}
		if !force {
			log.Die("Stopping install. Re-run with --force to install anyway.")
		}
	}

	msg := "Running `kubectl create -f` ..."
	if dryRun {
		msg = "Performing a dry run of `kubectl create -f` ..."
	}
	log.Info(msg)
	if err := uploadManifests(c, namespace, dryRun); err != nil {
		log.Die("Failed to upload manifests: %s", err)
	}
}
Exemple #19
0
// Info prints information about a chart.
//
// - chartName to display
// - homeDir is the helm home directory for the user
// - format is a optional Go template
func Info(chartName, homedir, format string) {
	r := mustConfig(homedir).Repos
	table, chartLocal := r.RepoChart(chartName)
	chartPath := filepath.Join(homedir, CachePath, table, chartLocal, "Chart.yaml")

	if format == "" {
		format = defaultInfoFormat
	}

	chart, err := chart.LoadChartfile(chartPath)
	if err != nil {
		log.Die("Could not find chart %s: %s", chartName, err.Error())
	}

	tmpl, err := template.New("info").Parse(format)
	if err != nil {
		log.Die("%s", err)
	}

	if err = tmpl.Execute(log.Stdout, chart); err != nil {
		log.Die("%s", err)
	}
}
Exemple #20
0
// openEditor opens the given filename in an interactive editor
func openEditor(filename string) {
	var cmd *exec.Cmd

	editor := os.ExpandEnv("$EDITOR")
	if editor == "" {
		log.Die("must set shell $EDITOR")
	}

	args := []string{filename}
	cmd = exec.Command(editor, args...)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	cmd.Run()
}
Exemple #21
0
// Search looks for packages with 'term' in their name.
func Search(term, homedir string) {
	charts, err := searchAll(term, homedir)
	if err != nil {
		log.Die(err.Error())
	}

	if len(charts) > 0 {
		for _, name := range sortedIndex(charts) {
			chart := charts[name]
			log.Msg("\t%s (%s %s) - %s", name, chart.Name, chart.Version, chart.Description)
		}
	} else {
		log.Msg("No chart found for \"%s\".", term)
	}

}
Exemple #22
0
// Publish a chart from the workspace to the cache directory
//
// - chartName being published
// - homeDir is the helm home directory for the user
// - force publishing even if the chart directory already exists
func Publish(chartName, homeDir string, force bool) {

	src := path.Join(homeDir, WorkspaceChartPath, chartName)
	dst := path.Join(homeDir, CacheChartPath, chartName)

	if _, err := os.Stat(dst); err == nil {
		if force != true {
			log.Info("chart already exists, use -f to force")
			return
		}
	}

	if err := copyDir(src, dst); err != nil {
		log.Die("failed to publish directory: %v", err)
	}
}
Exemple #23
0
func main() {
	app := cli.NewApp()
	app.Name = "helm"
	app.Usage = `The Kubernetes package manager

To begin working with Helm, run the 'helm update' command:

	$ helm update

This will download all of the necessary data. Common actions from this point
include:

	- helm help COMMAND: see help for a specific command
	- helm search: search for charts
	- helm fetch: make a local working copy of a chart
	- helm install: upload the chart to Kubernetes

For more information on Helm, go to http://helm.sh.

ENVIRONMENT:
   $HELM_HOME:     Set an alternative location for Helm files. By default, these
                   are stored in ~/.helm

`
	app.Version = version
	app.EnableBashCompletion = true

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "home",
			Value:  "$HOME/.helm",
			Usage:  "The location of your Helm files",
			EnvVar: "HELM_HOME",
		},
		cli.BoolFlag{
			Name:  "debug",
			Usage: "Enable verbose debugging output",
		},
	}

	app.CommandNotFound = func(c *cli.Context, command string) {
		log.Err("No matching command '%s'", command)
		cli.ShowAppHelp(c)
		log.Die("")
	}

	app.Commands = []cli.Command{
		{
			Name:    "update",
			Aliases: []string{"up"},
			Usage:   "Get the latest version of all Charts from GitHub.",
			Description: `This will synchronize the local repository with the upstream GitHub project.
The local cached copy is stored in '~/.helm/cache' or (if specified)
'$HELM_HOME/cache'.

The first time 'helm update' is run, the necessary directory structures are
created and then the Git repository is pulled in full.

Subsequent calls to 'helm update' will simply synchronize the local cache
with the remote.`,
			ArgsUsage: "",
			Action: func(c *cli.Context) {
				if !c.Bool("no-version-check") {
					action.CheckLatest(version)
				}
				action.Update(home(c))
			},
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "no-version-check",
					Usage: "Disable Helm's automatic check for newer versions of itself.",
				},
			},
		},
		{
			Name:  "fetch",
			Usage: "Fetch a Chart to your working directory.",
			Description: `Copy a chart from the Chart repository to a local workspace.
From this point, the copied chart may be safely modified to your needs.

If an optional 'chart-name' is specified, the chart will be copied to a directory
of that name. For example, 'helm fetch nginx www' will copy the the contents of
the 'nginx' chart into a directory named 'www' in your workspace.
`,
			ArgsUsage: "[chart] [chart-name]",
			Action:    fetch,
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "namespace, n",
					Value: "default",
					Usage: "The Kubernetes destination namespace.",
				},
			},
		},
		{
			Name:      "remove",
			Aliases:   []string{"rm"},
			Usage:     "Removes a Chart from your working directory.",
			ArgsUsage: "[chart-name]",
			Action:    remove,
		},
		{
			Name:  "install",
			Usage: "Install a named package into Kubernetes.",
			Description: `If the given 'chart-name' is present in your workspace, it
will be uploaded into Kubernetes. If no chart named 'chart-name' is found in
your workspace, Helm will look for a chart with that name, install it into the
workspace, and then immediately upload it to Kubernetes.

When multiple charts are specified, Helm will attempt to install all of them,
following the resolution process described above.

As a special case, if the flag --chart-path is specified, Helm will look for a
Chart.yaml file and manifests/ directory at that path, and will install that
chart if found. In this case, you may not specify multiple charts at once.
`,
			ArgsUsage: "[chart-name...]",
			Action:    install,
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "chart-path,p",
					Value: "",
					Usage: "An alternate path to fetch a chart. If specified, Helm will ignore the cache.",
				},
				cli.StringFlag{
					Name:  "namespace, n",
					Value: "",
					Usage: "The Kubernetes destination namespace.",
				},
				cli.BoolFlag{
					Name:  "force, aye-aye",
					Usage: "Perform install even if dependencies are unsatisfied.",
				},
				cli.BoolFlag{
					Name:  "dry-run",
					Usage: "Fetch the chart, but only display the underlying kubectl commands.",
				},
			},
		},
		{
			Name:  "uninstall",
			Usage: "Uninstall a named package from Kubernetes.",
			Description: `For each supplied 'chart-name', this will connect to Kubernetes
and remove all of the manifests specified.

This will not alter the charts in your workspace.
`,
			ArgsUsage: "[chart-name...]",
			Action: func(c *cli.Context) {
				minArgs(c, 1, "uninstall")
				for _, chart := range c.Args() {
					action.Uninstall(chart, home(c), c.String("namespace"))
				}
			},
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "namespace, n",
					Value: "",
					Usage: "The Kubernetes destination namespace.",
				},
			},
		},
		{
			Name:  "create",
			Usage: "Create a chart in the local workspace.",
			Description: `This will scaffold a new chart named 'chart-name' in your
local workdir. To edit the resulting chart, you may edit the files directly or
use the 'helm edit' command.
`,
			ArgsUsage: "[chart-name]",
			Action: func(c *cli.Context) {
				minArgs(c, 1, "create")
				action.Create(c.Args()[0], home(c))
			},
		},
		{
			Name:  "edit",
			Usage: "Edit a named chart in the local workspace.",
			Description: `Existing charts in the workspace can be edited using this command.
'helm edit' will open all of the chart files in a single editor (as specified
by the $EDITOR environment variable).
`,
			ArgsUsage: "[chart-name]",
			Action: func(c *cli.Context) {
				minArgs(c, 1, "edit")
				action.Edit(c.Args()[0], home(c))
			},
		},
		{
			Name:  "publish",
			Usage: "Publish a named chart to the git checkout.",
			Description: `This copies a chart from the workdir into the cache. Doing so
is the first stage of contributing a chart upstream.
`,
			ArgsUsage: "[chart-name]",
			Action: func(c *cli.Context) {
				action.Publish(c.Args()[0], home(c), c.Bool("force"))
			},
			Flags: []cli.Flag{
				cli.BoolFlag{
					Name:  "force, f",
					Usage: "Force publish over an existing chart.",
				},
			},
		},
		{
			Name:  "list",
			Usage: "List all fetched packages.",
			Description: `This prints all of the packages that are currently installed in
the workspace. Packages are printed by the local name.
`,
			ArgsUsage: "",
			Action: func(c *cli.Context) {
				action.List(home(c))
			},
		},
		{
			Name:  "search",
			Usage: "Search for a package.",
			Description: `This provides a simple interface for searching the chart cache
for charts matching a given pattern.

If no string is provided, or if the special string '*' is provided, this will
list all available charts.
`,
			ArgsUsage: "[string]",
			Action:    search,
		},
		{
			Name:      "info",
			Usage:     "Print information about a Chart.",
			ArgsUsage: "[string]",
			Flags: []cli.Flag{
				cli.StringFlag{
					Name:  "format",
					Usage: "Print using a Go template",
				},
			},
			Action: func(c *cli.Context) {
				minArgs(c, 1, "info")
				action.Info(c.Args()[0], home(c), c.String("format"))
			},
		},
		{
			Name:      "target",
			Usage:     "Displays information about cluster.",
			ArgsUsage: "",
			Action: func(c *cli.Context) {
				action.Target()
			},
		},
		{
			Name:      "home",
			Usage:     "Displays the location of the Helm home.",
			ArgsUsage: "",
			Action: func(c *cli.Context) {
				log.Msg(home(c))
			},
		},
		{
			Name:    "repo",
			Aliases: []string{"repository"},
			Usage:   "Work with other Chart repositories.",
			Subcommands: []cli.Command{
				{
					Name:      "add",
					Usage:     "Add a remote chart repository.",
					ArgsUsage: "[name] [git url]",
					Action: func(c *cli.Context) {
						minArgs(c, 2, "add")
						a := c.Args()
						action.AddRepo(home(c), a[0], a[1])
					},
				},
				{
					Name:  "list",
					Usage: "List all remote chart repositories.",
					Action: func(c *cli.Context) {
						action.ListRepos(home(c))
					},
				},
				{
					Name:      "remove",
					Aliases:   []string{"rm"},
					Usage:     "Remove a remote chart repository.",
					ArgsUsage: "[name] [git url]",
					Action: func(c *cli.Context) {
						minArgs(c, 1, "remove")
						action.DeleteRepo(home(c), c.Args()[0])
					},
				},
			},
		},
	}

	app.Before = func(c *cli.Context) error {
		log.IsDebugging = c.Bool("debug")
		return nil
	}

	app.Run(os.Args)
}