handle helm output properly

This commit is contained in:
Donny Xia
2021-03-16 13:09:04 -07:00
parent 297bdc3825
commit a9c20a2eb7
2 changed files with 22 additions and 2 deletions

View File

@@ -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 {