From 93153a97db45f8679d07659535343186c2fe9316 Mon Sep 17 00:00:00 2001 From: Seebs Date: Thu, 17 Nov 2022 14:59:46 -0600 Subject: [PATCH] actually honor provided stdin/stdout the BackupTar and RestoreTar functionality was ignoring provided readers, which doesn't matter for real usage but breaks tests by making them dump raw tar binaries to stdout. --- ctl/backup_tar.go | 2 +- ctl/restore_tar.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ctl/backup_tar.go b/ctl/backup_tar.go index 879045dbf..50898ef43 100644 --- a/ctl/backup_tar.go +++ b/ctl/backup_tar.go @@ -127,7 +127,7 @@ func (cmd *BackupTarCommand) Run(ctx context.Context) (err error) { // Create output file in temporary location, or send to stdout if a dash is specified. var w io.Writer if useStdout { - w = os.Stdout + w = cmd.Stdout } else { f, err := os.Create(cmd.OutputPath + ".tmp") if err != nil { diff --git a/ctl/restore_tar.go b/ctl/restore_tar.go index 6b2651e32..86901ba3a 100644 --- a/ctl/restore_tar.go +++ b/ctl/restore_tar.go @@ -73,16 +73,17 @@ func (cmd *RestoreTarCommand) Run(ctx context.Context) (err error) { } useStdin := cmd.Path == "-" - var f *os.File + var f io.Reader // read from Stdin if path specified as - if useStdin { - f = os.Stdin + f = cmd.Stdin } else { - f, err = os.Open(cmd.Path) + file, err := os.Open(cmd.Path) if err != nil { return (err) } - defer f.Close() + defer file.Close() + f = file } // Parse TLS configuration for node-specific clients.