diff --git a/api/builtins/HelmChartInflationGenerator.go b/api/builtins/HelmChartInflationGenerator.go index 673a8d3fc..65d8d45f5 100644 --- a/api/builtins/HelmChartInflationGenerator.go +++ b/api/builtins/HelmChartInflationGenerator.go @@ -218,7 +218,17 @@ func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) { return nil, err } - return p.h.ResmapFactory().NewResMapFromBytes(stdout) + rm, rmfErr := p.h.ResmapFactory().NewResMapFromBytes(stdout) + if rmfErr == nil { + return rm, nil + } + // try to remove the contents before first "---" because + // helm may produce messages to stdout before it + stdoutStr := string(stdout) + if idx := strings.Index(stdoutStr, "---"); idx != -1 { + return p.h.ResmapFactory().NewResMapFromBytes([]byte(stdoutStr[idx:])) + } + return nil, rmfErr } func (p *HelmChartInflationGeneratorPlugin) getTemplateCommandArgs() []string { diff --git a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go index 7c0af7ca7..14f457152 100644 --- a/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go +++ b/plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go @@ -226,7 +226,17 @@ func (p *HelmChartInflationGeneratorPlugin) Generate() (resmap.ResMap, error) { return nil, err } - return p.h.ResmapFactory().NewResMapFromBytes(stdout) + rm, rmfErr := p.h.ResmapFactory().NewResMapFromBytes(stdout) + if rmfErr == nil { + return rm, nil + } + // try to remove the contents before first "---" because + // helm may produce messages to stdout before it + stdoutStr := string(stdout) + if idx := strings.Index(stdoutStr, "---"); idx != -1 { + return p.h.ResmapFactory().NewResMapFromBytes([]byte(stdoutStr[idx:])) + } + return nil, rmfErr } func (p *HelmChartInflationGeneratorPlugin) getTemplateCommandArgs() []string {