Skip to content

Commit

Permalink
Fix helmfile-template not writing to stdout (#1737)
Browse files Browse the repository at this point in the history
This fixes #1691 by redirecting helm-template output to our logger when and only when --output-dir is being passed to helm-template.

See #1691 (comment) for more context.
  • Loading branch information
mumoshu authored Mar 25, 2021
1 parent 28cf300 commit faa7496
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion pkg/helmexec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,31 @@ func (helm *execer) TemplateRelease(name string, chart string, flags ...string)
}

out, err := helm.exec(append(args, flags...), map[string]string{})
helm.info(out)

var outputToFile bool

for _, f := range flags {
if strings.HasPrefix("--output-dir", f) {
outputToFile = true
break
}
}

if outputToFile {
// With --output-dir is passed to helm-template,
// we can safely direct all the logs from it to our logger.
//
// It's safe because anything written to stdout by helm-template with output-dir is logs,
// like excessive `wrote path/to/output/dir/chart/template/file.yaml` messages,
// but manifets.
//
// See https://github.com/roboll/helmfile/pull/1691#issuecomment-805636021 for more information.
helm.info(out)
} else {
// Always write to stdout for use with e.g. `helmfile template | kubectl apply -f -`
helm.write(nil, out)
}

return err
}

Expand Down

0 comments on commit faa7496

Please sign in to comment.