-
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: container stats command #2306
Conversation
} | ||
|
||
noStream, err := cmd.Flags().GetBool("no-stream") | ||
if err != nil { | ||
return err | ||
return types.ContainerStatsOptions{}, err | ||
} | ||
|
||
format, err := cmd.Flags().GetString("format") |
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.
Lint is failing
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.
Fixed
Signed-off-by: Ziwen Ning <ningziwe@amazon.com>
} | ||
|
||
// when (firstSet == true), we only set container stats without rendering stat entry | ||
statsEntry, err := setContainerStatsAndRenderStatsEntry(previousStats, firstSet, anydata, int(task.Pid()), netNS.Interfaces) |
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.
statsEntry, err := setContainerStatsAndRenderStatsEntry(previousStats, firstSet, anydata, int(task.Pid()), netNS.Interfaces) | |
statsEntry, err := setContainerStatsThenRenderStatsEntry(previousStats, firstSet, anydata, int(task.Pid()), netNS.Interfaces) |
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.
"And" seems more common to me than "Then" in my impression. Any specific reasons of preferring "Then"?
(This is out of the scope of the current refactoring goal but I'm good to quickly include it if it makes sense)
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.
what happens behind the scenes: in the first iteration we only set ContainerStats
, then in the second iteration we set a new ContainerStats
and render the statistics by making diff. My idea was to reflect this strategy in the title of the function but we can keep it if you don't feel the need @AkihiroSuda @ningziwen
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.
To me, for the meanings, "and" and "then" should be interchangable in Go naming.
Even In daily usage, they seem very similar in most scenarios.
"I opened the door, and entered the room"
"I opened the door, then entered the room"
I'm leaning to keeping the more common one "and" but don't have strong preference.
I left small comment, Globally LGTM , Thanks |
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.
Thanks
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.
Thanks
#1680