From ef9802f514bfe237da4a860dcee309eaa610324e Mon Sep 17 00:00:00 2001 From: Ali Rizwan Date: Wed, 14 Mar 2018 12:47:16 +0100 Subject: [PATCH] Allow Helm create starters option to use paths Updated docs to reflect changes --- cmd/helm/create.go | 9 ++++++++- docs/charts.md | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/helm/create.go b/cmd/helm/create.go index 556ff171d..cc2200e50 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "io" + "os" "path/filepath" "github.com/spf13/cobra" @@ -78,7 +79,7 @@ func newCreateCmd(out io.Writer) *cobra.Command { }, } - cmd.Flags().StringVarP(&cc.starter, "starter", "p", "", "the named Helm starter scaffold") + cmd.Flags().StringVarP(&cc.starter, "starter", "p", "", "the name or path of the Helm starter scaffold") return cmd } @@ -97,6 +98,12 @@ func (c *createCmd) run() error { if c.starter != "" { // Create from the starter lstarter := filepath.Join(c.home.Starters(), c.starter) + // Check without helm home + if _, err := os.Stat(lstarter); os.IsNotExist(err) { + if _, err := os.Stat(c.starter); err == nil { + lstarter = c.starter + } + } return chartutil.CreateFrom(cfile, filepath.Dir(c.name), lstarter) } diff --git a/docs/charts.md b/docs/charts.md index 8722e6862..4e1dc6afc 100644 --- a/docs/charts.md +++ b/docs/charts.md @@ -843,6 +843,7 @@ The `helm create` command takes an optional `--starter` option that lets you specify a "starter chart". Starters are just regular charts, but are located in `$HELM_HOME/starters`. +You can specify the path to a starter using the `--starter` option. As a chart developer, you may author charts that are specifically designed to be used as starters. Such charts should be designed with the following considerations in mind: @@ -853,6 +854,3 @@ considerations in mind: - All occurences of `` will be replaced with the specified chart name so that starter charts can be used as templates. -Currently the only way to add a chart to `$HELM_HOME/starters` is to manually -copy it there. In your chart's documentation, you may want to explain that -process.