| 348 | } |
| 349 | |
| 350 | func (helm *execer) TemplateRelease(name string, chart string, flags ...string) error { |
| 351 | helm.logger.Infof("Templating release=%v, chart=%v", name, chart) |
| 352 | var args []string |
| 353 | if helm.IsHelm3() { |
| 354 | args = []string{"template", name, chart} |
| 355 | } else { |
| 356 | args = []string{"template", chart, "--name", name} |
| 357 | } |
| 358 | |
| 359 | out, err := helm.exec(append(args, flags...), map[string]string{}) |
| 360 | |
| 361 | var outputToFile bool |
| 362 | |
| 363 | for _, f := range flags { |
| 364 | if strings.HasPrefix("--output-dir", f) { |
| 365 | outputToFile = true |
| 366 | break |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | if outputToFile { |
| 371 | // With --output-dir is passed to helm-template, |
| 372 | // we can safely direct all the logs from it to our logger. |
| 373 | // |
| 374 | // It's safe because anything written to stdout by helm-template with output-dir is logs, |
| 375 | // like excessive `wrote path/to/output/dir/chart/template/file.yaml` messages, |
| 376 | // but manifets. |
| 377 | // |
| 378 | // See https://github.com/roboll/helmfile/pull/1691#issuecomment-805636021 for more information. |
| 379 | helm.info(out) |
| 380 | } else { |
| 381 | // Always write to stdout for use with e.g. `helmfile template | kubectl apply -f -` |
| 382 | helm.write(nil, out) |
| 383 | } |
| 384 | |
| 385 | return err |
| 386 | } |
| 387 | |
| 388 | func (helm *execer) DiffRelease(context HelmContext, name, chart string, suppressDiff bool, flags ...string) error { |
| 389 | if context.Writer != nil { |