Skip to content

Commit

Permalink
fix pull image process output from stderr to stdout
Browse files Browse the repository at this point in the history
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
  • Loading branch information
yankay committed Dec 19, 2024
1 parent 0e5f7fd commit c0da4d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cmd/nerdctl/image/image_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ func processPullCommandFlags(cmd *cobra.Command) (types.ImagePullOptions, error)
RFlags: types.RemoteSnapshotterFlags{
SociIndexDigest: sociIndexDigest,
},
Stdout: cmd.OutOrStdout(),
Stderr: cmd.OutOrStderr(),
Stdout: cmd.OutOrStdout(),
Stderr: cmd.OutOrStderr(),
ProgressOutputToStdout: true,
}, nil
}

Expand Down
7 changes: 5 additions & 2 deletions pkg/api/types/image_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ type RemoteSnapshotterFlags struct {

// ImagePullOptions specifies options for `nerdctl (image) pull`.
type ImagePullOptions struct {
Stdout io.Writer
Stderr io.Writer
Stdout io.Writer
Stderr io.Writer
// ProgressOutputToStdout directs progress output to stdout instead of stderr
ProgressOutputToStdout bool

GOptions GlobalCommandOptions
VerifyOptions ImageVerifyOptions
// Unpack the image for the current single platform.
Expand Down
3 changes: 3 additions & 0 deletions pkg/imgutil/imgutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ func PullImage(ctx context.Context, client *containerd.Client, resolver remotes.
}
if !options.Quiet {
config.ProgressOutput = options.Stderr
if options.ProgressOutputToStdout {
config.ProgressOutput = options.Stdout
}
}

// unpack(B) if given 1 platform unless specified by `unpack`
Expand Down

0 comments on commit c0da4d8

Please sign in to comment.