fix: wrap file operation errors with context in post-renderer workaround

Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/33d92423-fc47-4080-8307-5af9b16dd9c6

Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-10 00:06:59 +00:00 committed by yxxhero
parent 1ec00a378f
commit 0bdda42dbe
1 changed files with 3 additions and 3 deletions

View File

@ -691,17 +691,17 @@ func (helm *execer) TemplateRelease(name string, chart string, flags ...string)
legacyOutputPath := filepath.Join(outputDir, name+".yaml")
if removeErr := os.Remove(legacyOutputPath); removeErr != nil && !os.IsNotExist(removeErr) {
return removeErr
return fmt.Errorf("failed to remove legacy output file %s: %w", legacyOutputPath, removeErr)
}
if len(out) > 0 {
if mkdirErr := os.MkdirAll(templatesDir, 0755); mkdirErr != nil {
return mkdirErr
return fmt.Errorf("failed to create templates directory %s: %w", templatesDir, mkdirErr)
}
outputPath := filepath.Join(templatesDir, name+".yaml")
if writeErr := os.WriteFile(outputPath, append(out, '\n'), 0644); writeErr != nil {
return writeErr
return fmt.Errorf("failed to write output file %s: %w", outputPath, writeErr)
}
helm.logger.Debugf("Wrote post-renderer output to %s", outputPath)
}