From 1009fa4164bce24e4a84c55da3cfc8db773e3c1a 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. (cherry picked from commit 93153a97db45f8679d07659535343186c2fe9316) --- 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 961aebb24..c0bf72ac8 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 a4fc1cef3..480450bb1 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.