-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: allow custom handlers for processing push/pull status updates #2342
base: main
Are you sure you want to change the base?
Conversation
61efde6
to
458f034
Compare
pkg/api/types/image_types.go
Outdated
@@ -165,14 +169,15 @@ type ImagePushOptions struct { | |||
IpfsAddress string | |||
// Suppress verbose output | |||
Quiet bool | |||
// If non-nil, the Push job will send upload statuses to the handler instead of Stdout | |||
ProgressHandler jobs.StatusHandler | |||
// AllowNondistributableArtifacts allow pushing non-distributable artifacts | |||
AllowNondistributableArtifacts bool | |||
} | |||
|
|||
// ImagePullOptions specifies options for `nerdctl (image) pull`. | |||
type ImagePullOptions struct { | |||
Stdout io.Writer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just removing Stdout
and pass progressHandler
as jobs.PrintProgress(cmd.OutOrStderr())
in CLI layer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. The push command also prints the image reference to stdout if --quiet
flag is set, so I have changed the push/pull method signature to return image reference along with error.
Signed-off-by: Mrudul Harwani <[email protected]>
Signed-off-by: Mrudul Harwani <[email protected]>
Signed-off-by: Mrudul Harwani <[email protected]>
Signed-off-by: Mrudul Harwani <[email protected]>
Signed-off-by: Mrudul Harwani <[email protected]>
f29ec0e
to
2df8955
Compare
Signed-off-by: Mrudul Harwani <[email protected]>
2df8955
to
747fe3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the refactoring pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integration tests are failing and please squash the commits to one.
Needs rebase |
Hey @mharwani Do you think you could rebase this? |
Contributing to the refactoring issue #1680
Currently, the way image push/pull commands are refactored, it is difficult to obtain download/upload status updates programmatically. Nerdctl has its own printing logic, but users may want to handle status updates directly via code when importing those subcommands. These changes allow users to define custom handlers for processing status updates during push/pull.