diff --git a/go.mod b/go.mod index f1f03fc5..215d6b6d 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/spf13/cobra v1.1.1 github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939 github.com/urfave/cli v1.22.5 - github.com/variantdev/chartify v0.7.3 + github.com/variantdev/chartify v0.8.0 github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 github.com/variantdev/vals v0.13.0 go.uber.org/multierr v1.6.0 diff --git a/go.sum b/go.sum index 89bf970d..6c0a7662 100644 --- a/go.sum +++ b/go.sum @@ -581,6 +581,8 @@ github.com/variantdev/chartify v0.7.2 h1:H7a9xD4rfyKkLDhCO/Oj3VfYnJRb92Dqk+GR6vp github.com/variantdev/chartify v0.7.2/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= github.com/variantdev/chartify v0.7.3 h1:uX0mN8PmYHZDWILcg41sQfasJ7TT/CYnYWSmDgsIBIA= github.com/variantdev/chartify v0.7.3/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= +github.com/variantdev/chartify v0.8.0 h1:yIBsS/dIUeMjWP8U6JWlT3PM0Lky7en9QBi+MgDu2U8= +github.com/variantdev/chartify v0.8.0/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= github.com/variantdev/vals v0.13.0 h1:zdtTBjoWKkUGdFauxETkDVjqWXdjUNwI+ggWcUmpxv8= diff --git a/pkg/state/helmx.go b/pkg/state/helmx.go index 63b98c0a..ebc19a68 100644 --- a/pkg/state/helmx.go +++ b/pkg/state/helmx.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "github.com/roboll/helmfile/pkg/helmexec" "github.com/roboll/helmfile/pkg/remote" @@ -85,7 +84,7 @@ func (st *HelmState) goGetterChart(chart, dir, cacheDir string, force bool) (str } func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSpec, chart string, workerIndex int) (*Chartify, func(), error) { - chartify := &Chartify{ + c := &Chartify{ Opts: &chartify.ChartifyOpts{ WorkaroundOutputDirIssue: true, EnableKustomizeAlphaPlugins: true, @@ -110,25 +109,25 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp } for _, d := range release.Dependencies { - var dep string - - if d.Alias != "" { - dep += d.Alias + "=" - } else { - a := strings.Split(d.Chart, "/") - - chart := a[len(a)-1] - - dep += chart + "=" - } - - dep += d.Chart - - if d.Version != "" { - dep += ":" + d.Version + chart := d.Chart + if st.directoryExistsAt(chart) { + var err error + + // Otherwise helm-dependency-up on the temporary chart generated by chartify ends up errors like: + // Error: directory /tmp/chartify945964195/myapp-57fb4495cf/test/integration/charts/httpbin not found] + // which is due to that the temporary chart is generated outside of the current working directory/basePath, + // and therefore the relative path in `chart` points to somewhere inexistent. + chart, err = filepath.Abs(filepath.Join(st.basePath, chart)) + if err != nil { + return nil, clean, err + } } - chartify.Opts.AdhocChartDependencies = append(chartify.Opts.AdhocChartDependencies, dep) + c.Opts.AdhocChartDependencies = append(c.Opts.AdhocChartDependencies, chartify.ChartDependency{ + Alias: d.Alias, + Chart: chart, + Version: d.Version, + }) shouldRun = true } @@ -143,7 +142,7 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp filesNeedCleaning = append(filesNeedCleaning, generatedFiles...) for _, f := range generatedFiles { - chartify.Opts.JsonPatches = append(chartify.Opts.JsonPatches, f) + c.Opts.JsonPatches = append(c.Opts.JsonPatches, f) } shouldRun = true @@ -157,7 +156,7 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp } for _, f := range generatedFiles { - chartify.Opts.StrategicMergePatches = append(chartify.Opts.StrategicMergePatches, f) + c.Opts.StrategicMergePatches = append(c.Opts.StrategicMergePatches, f) } filesNeedCleaning = append(filesNeedCleaning, generatedFiles...) @@ -173,7 +172,7 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp } for _, f := range generatedFiles { - chartify.Opts.Transformers = append(chartify.Opts.Transformers, f) + c.Opts.Transformers = append(c.Opts.Transformers, f) } filesNeedCleaning = append(filesNeedCleaning, generatedFiles...) @@ -182,7 +181,7 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp } if release.ForceNamespace != "" { - chartify.Opts.OverrideNamespace = release.ForceNamespace + c.Opts.OverrideNamespace = release.ForceNamespace shouldRun = true } @@ -195,11 +194,11 @@ func (st *HelmState) PrepareChartify(helm helmexec.Interface, release *ReleaseSp filesNeedCleaning = append(filesNeedCleaning, generatedFiles...) - chartify.Opts.ValuesFiles = generatedFiles - chartify.Opts.TemplateData = st.newReleaseTemplateData(release) - chartify.Opts.TemplateFuncs = st.newReleaseTemplateFuncMap(dir) + c.Opts.ValuesFiles = generatedFiles + c.Opts.TemplateData = st.newReleaseTemplateData(release) + c.Opts.TemplateFuncs = st.newReleaseTemplateFuncMap(dir) - return chartify, clean, nil + return c, clean, nil } return nil, clean, nil