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.
This commit is contained in:
parent
4674af9608
commit
dfc4b0293f
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -42,7 +44,27 @@ func (helm *execer) UpdateRepo() error {
|
||||||
return err
|
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 {
|
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...)...)
|
out, err := helm.exec(append([]string{"upgrade", "--install", name, chart}, flags...)...)
|
||||||
if helm.writer != nil {
|
if helm.writer != nil {
|
||||||
helm.writer.Write(out)
|
helm.writer.Write(out)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue