From dfc4b0293f1b40a49765d739711087c883dfd291 Mon Sep 17 00:00:00 2001 From: Robson Roberto Souza Peixoto Date: Thu, 13 Apr 2017 12:53:05 -0300 Subject: [PATCH 1/2] Accept chart in a local path If the chart is in directory, for example, `./my/chart` the `helmfile -f my.yaml sync` will fail. This PR will check if the chart starts with `/`, `./` or `../` and will transform it in a full path of the chart directory. --- helmexec/exec.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/helmexec/exec.go b/helmexec/exec.go index c55c41ba..408e87b2 100644 --- a/helmexec/exec.go +++ b/helmexec/exec.go @@ -6,6 +6,8 @@ import ( "io/ioutil" "os" "os/exec" + "path/filepath" + "regexp" "strings" ) @@ -42,7 +44,27 @@ func (helm *execer) UpdateRepo() error { return err } +func normalizeChart(chart string) (string, error) { + regex, err := regexp.Compile("^[.]?[.]?/") + if err != nil { + return "", err + } + if !regex.MatchString(chart) { + return chart, nil + } + wd, err := os.Getwd() + if err != nil { + return "", err + } + path := filepath.Join(wd, chart) + return path, nil +} + func (helm *execer) SyncChart(name, chart string, flags ...string) error { + chart, err := normalizeChart(chart) + if err != nil { + return err + } out, err := helm.exec(append([]string{"upgrade", "--install", name, chart}, flags...)...) if helm.writer != nil { helm.writer.Write(out) From a61ae2a5b3dd6044335a2fff13c199b036207e2f Mon Sep 17 00:00:00 2001 From: Robson Roberto Souza Peixoto Date: Thu, 13 Apr 2017 14:30:00 -0300 Subject: [PATCH 2/2] Only accept `./` and `../` --- helmexec/exec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helmexec/exec.go b/helmexec/exec.go index 408e87b2..f74ac881 100644 --- a/helmexec/exec.go +++ b/helmexec/exec.go @@ -45,7 +45,7 @@ func (helm *execer) UpdateRepo() error { } func normalizeChart(chart string) (string, error) { - regex, err := regexp.Compile("^[.]?[.]?/") + regex, err := regexp.Compile("^[.]?./") if err != nil { return "", err }