From 566be4c14c7cda9675baeaf2ae189635aae8d5ea Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Fri, 11 Mar 2022 02:51:11 -0600 Subject: [PATCH] :sparkles: Write dump to stdout if "-" filename is given --- cmd/dump/dump.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/dump/dump.go b/cmd/dump/dump.go index df43e2df..4087ccc4 100644 --- a/cmd/dump/dump.go +++ b/cmd/dump/dump.go @@ -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,