diff options
author | Vladimir Kochnev <hashtable@yandex.ru> | 2022-08-19 00:41:22 +0300 |
---|---|---|
committer | Vladimir Kochnev <hashtable@yandex.ru> | 2022-08-19 00:41:22 +0300 |
commit | 3bf52aa338b33de719e087e15402081568453284 (patch) | |
tree | 7ec3736282de122eba75ebd9b1870908be9b3b28 /pkg/bindings/images/pull.go | |
parent | ec9508ea177a50ff3361a9ef14efbe1ff6baf05d (diff) | |
download | podman-3bf52aa338b33de719e087e15402081568453284.tar.gz podman-3bf52aa338b33de719e087e15402081568453284.tar.bz2 podman-3bf52aa338b33de719e087e15402081568453284.zip |
Add ProgressWriter to PullOptions
Signed-off-by: Vladimir Kochnev <hashtable@yandex.ru>
Diffstat (limited to 'pkg/bindings/images/pull.go')
-rw-r--r-- | pkg/bindings/images/pull.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pkg/bindings/images/pull.go b/pkg/bindings/images/pull.go index 1a4aa3038..109981c63 100644 --- a/pkg/bindings/images/pull.go +++ b/pkg/bindings/images/pull.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "os" "strconv" @@ -57,10 +56,14 @@ func Pull(ctx context.Context, rawImage string, options *PullOptions) ([]string, return nil, response.Process(err) } - // Historically pull writes status to stderr - stderr := io.Writer(os.Stderr) + var writer io.Writer if options.GetQuiet() { - stderr = ioutil.Discard + writer = io.Discard + } else if progressWriter := options.GetProgressWriter(); progressWriter != nil { + writer = progressWriter + } else { + // Historically push writes status to stderr + writer = os.Stderr } dec := json.NewDecoder(response.Body) @@ -84,7 +87,7 @@ func Pull(ctx context.Context, rawImage string, options *PullOptions) ([]string, switch { case report.Stream != "": - fmt.Fprint(stderr, report.Stream) + fmt.Fprint(writer, report.Stream) case report.Error != "": pullErrors = append(pullErrors, errors.New(report.Error)) case len(report.Images) > 0: |