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

Condense output of compose top #12391

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

dmke
Copy link

@dmke dmke commented Dec 16, 2024

What I did

This changes the output format of compose top and inlines the service container name into the table.

Previously, compose top had printed something like:

<service name>
UID    PID   ...
root   1     ...

Now, the output looks more like this:

SERVICE   UID    PID   ...
<name>    root   1     ...

Related issue

Closes #12381

image

Baby mountain goat on rock, CC-by-sa Shaundd, WP:Commons

@dmke
Copy link
Author

dmke commented Dec 16, 2024

This is a first draft. The tests could be a bit more exhaustive (i.e. mocking (api.Service).Top()).

Looking at the test cases now, I also think it should ensure to reorder the CMD column to the end.

Copy link
Contributor

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

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

LGTM, just a comment regarding service vs container name

cmd/compose/top.go Outdated Show resolved Hide resolved
@dmke dmke force-pushed the 12381-compact-top branch from b0c36fb to 9b0c720 Compare December 17, 2024 10:02
dmke added 4 commits December 17, 2024 17:45
This changes the output format of `compose top` and inlines the service
container name into the table.

Previously, `compose top` had printed something like:

  <service name>
  UID    PID   ...
  root   1     ...

Now, the output looks more like this:

  SERVICE   UID    PID   ...
  <name>    root   1     ...

Signed-off-by: Dominik Menke <[email protected]>
Signed-off-by: Dominik Menke <[email protected]>
@dmke dmke force-pushed the 12381-compact-top branch from 9b0c720 to 489d8b8 Compare December 17, 2024 16:45
@dmke
Copy link
Author

dmke commented Dec 17, 2024

I've also taken the opportunity to:

  1. Ensure the CMD column is the right-most one, as this column has likely a very diverse length.
  2. Reduced the padding and minwidth parameters passed to tabwriter, to decrease horizontal space requirements.
  3. Rebase the branch onto main.

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.

Condense output of docker compose top
2 participants