Skip to content

Commit

Permalink
✨ Write dump to stdout if "-" filename is given
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Mar 11, 2022
1 parent da46749 commit 566be4c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,18 @@ func run(cmd *cobra.Command, args []string) (err error) {
}
}

f, err := os.Create(filename)
if err != nil {
return err
var f io.WriteCloser
if filename == "-" {
f = os.Stdout
} else {
f, err = os.Create(filename)
if err != nil {
return err
}
defer func(f io.WriteCloser) {
_ = f.Close()
}(f)
}
defer f.Close()

log.WithFields(log.Fields{
"pod": conf.Pod.Name,
Expand Down

0 comments on commit 566be4c

Please sign in to comment.