From e33800a7bcc3dfd66ad236347bedf20158cfcc1e Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 23 May 2021 02:38:33 +0200 Subject: [PATCH] fix: add chart hooks to the output. Relates to #16 --- pkg/helm/render.go | 9 +++++++-- pkg/helm/values.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/helm/render.go b/pkg/helm/render.go index 03e83b9..8112ec6 100644 --- a/pkg/helm/render.go +++ b/pkg/helm/render.go @@ -104,7 +104,12 @@ func renderChart(chartRequested *chart.Chart, req *config.ChartConfig, getters g chartHookMatcher := matcher.NewChartHookMatcher(transformer.Excludes, !req.ExcludeHooks) transformer.Excludes = chartHookMatcher - transformed, err := transformer.TransformManifest(bytes.NewReader([]byte((release.Manifest)))) + manifest := release.Manifest + for _, hook := range release.Hooks { + manifest += fmt.Sprintf("\n---\n%s", hook.Manifest) + } + + transformed, err := transformer.TransformManifest(bytes.NewReader([]byte((manifest)))) if err != nil { return nil, err } @@ -119,7 +124,7 @@ func renderChart(chartRequested *chart.Chart, req *config.ChartConfig, getters g return nil, errors.Errorf("chart %s output is empty", chartRequested.Metadata.Name) } if hooks := chartHookMatcher.FoundHooks(); !req.ExcludeHooks && len(hooks) > 0 { - log.Printf("WARNING: The chart output contains the following hooks: %s", strings.Join(hooks, ", ")) + log.Printf("WARNING: Chart output contains the following hooks: %s", strings.Join(hooks, ", ")) } return transformed, nil } diff --git a/pkg/helm/values.go b/pkg/helm/values.go index 464e565..d27b0fa 100644 --- a/pkg/helm/values.go +++ b/pkg/helm/values.go @@ -28,7 +28,7 @@ func loadValues(cfg *config.ChartConfig, getters getter.Providers) (map[string]i } vals, err := valueOpts.MergeValues(valueGetters) if err != nil { - return nil, errors.Wrap(err, "load values: %w") + return nil, errors.Wrap(err, "load values") } return vals, nil }