From df54adeaae6e247bfe07b39fa3e2a2c0a5e8f335 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 7 Nov 2017 08:53:06 -0500 Subject: Respect the quiet flag. When setting the `kpod load -q` flag, output was still going to the screen. This patch adds a check to not output to the terminal unless there is an io.Writer specified, and then to write to the io.Writer. Signed-off-by: Daniel J Walsh Closes: #23 Approved by: rhatdan --- libpod/runtime_img.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index d291840e9..a57aec86c 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -409,8 +409,7 @@ func getRegistriesToTry(image string, store storage.Store) ([]*pullStruct, error } searchRegistries, err := sysregistries.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: registryConfigPath}) if err != nil { - fmt.Println(err) - return nil, errors.Errorf("unable to parse the registries.conf file and"+ + return nil, errors.Wrapf(err, "unable to parse the registries.conf file and"+ " the image name '%s' is incomplete.", imageName) } for _, searchRegistry := range searchRegistries { @@ -587,9 +586,13 @@ func (r *Runtime) PullImage(imgName string, options CopyOptions) error { copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, &options.DockerRegistryOptions, nil, options.SigningOptions, options.AuthFile) for _, imageInfo := range pullStructs { - fmt.Printf("Trying to pull %s...\n", imageInfo.image) + if options.Writer != nil { + io.WriteString(options.Writer, fmt.Sprintf("Trying to pull %s...\n", imageInfo.image)) + } if err = cp.Image(policyContext, imageInfo.dstRef, imageInfo.srcRef, copyOptions); err != nil { - fmt.Println("Failed") + if options.Writer != nil { + io.WriteString(options.Writer, "Failed\n") + } } else { return nil } -- cgit v1.2.3-54-g00ecf