Skip to content
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

Add quiet mode to progress printer #558

Merged

Conversation

ulyssessouza
Copy link
Contributor

Allows it to write to os.DevNull and by this silencing the printer.

Related to docker-archive/compose-cli#1390

@ulyssessouza ulyssessouza force-pushed the add-quiet-mode-to-progress-printer branch from 03c1f62 to f8b1e80 Compare March 5, 2021 13:35
@ulyssessouza
Copy link
Contributor Author

@tonistiigi Could you PTAL?

c = cons
switch mode {
case PrinterModeQuiet:
devNull, err := os.Open(os.DevNull)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just set out to ioutil.Discard , no fallthrough needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ioutil.Discard is a Writer and out is a File.

About the fallthrough I'm not sure if I understood, but it is needed in order to execute console.ConsoleFromFile(out) and assign to c. Otherwise, how could it affect the console? Note that if not, plain output is printed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter that DisplaySolveStatus takes is an io.Writer. If you discard the output then you don't have a console. That should answer to the fallthrough case as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh... Got it... I missunderstood the out you said with the variable out.
PTAL

}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be connected to -q as well. Otherwise, the ux is confusing unless we want to completely remove -q. But there are some things to figure out like outputs can pipe to stdout if image ID is printed there so I guess it could be follow up. Another way to make it faster is to just read the channel here directly until end if the content is disarded anyway. DisplaySolveStatus does need to analyze the objects and sort/cache them so has some overhead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! The intent of this PR is only to make docker-archive/compose-cli#1390 possible.
I can propose follow up PR to connect -q if you want.

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
@ulyssessouza ulyssessouza force-pushed the add-quiet-mode-to-progress-printer branch from f8b1e80 to 55d5b80 Compare March 9, 2021 20:12
@tonistiigi tonistiigi merged commit c9f02c3 into docker:master Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants