Skip to content

Commit

Permalink
feat: allow using - for stdout when rending template
Browse files Browse the repository at this point in the history
  • Loading branch information
micovery committed May 8, 2024
1 parent c209d54 commit e3a3427
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,20 @@ func RenderGeneric(context any, cFlags *CommonFlags, dryRun bool) error {
}

//write rendered template to output
if !dryRun {
useStdout := false
if cFlags.OutputFile == "-" || dryRun == true {
useStdout = true
}

if useStdout {
fmt.Print(string(rendered))
} else {
err = os.WriteFile(string(cFlags.OutputFile), rendered, os.ModePerm)
if err != nil {
return errors.New(err)
}
}

if dryRun {
fmt.Print(string(rendered))
}

return nil
}

Expand Down

0 comments on commit e3a3427

Please # to comment.