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

fixes #2413 - cli/command: fix docstring for ContainerFormat.CreatedAt and add CreatedAtTimestamp #4379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion cli/command/formatter/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,16 @@ func (c *ContainerContext) Command() string {
return strconv.Quote(command)
}

// CreatedAt returns the "Created" date/time of the container as a unix timestamp.
// CreatedAt returns the "Created" date/time of the container as a stringified unix timestamp.
func (c *ContainerContext) CreatedAt() string {
return time.Unix(c.c.Created, 0).String()
}

// CreatedAtTimestamp returns the "Created" date/time of the container as a unix timestamp.
func (c *ContainerContext) CreatedAtTimestamp() time.Time {
return time.Unix(c.c.Created, 0)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this should just return c.Created as-is (and perhaps the function be named Created(), and probably needs an entry in the "headers" (when used for table-view). Do we need to look at other formatters?

I'm slightly considering if we should have an option to expose the Container itself for formatting (have .Container() function that returns c.c)

Choose a reason for hiding this comment

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

Good point. What benefit would there be to simply returning the Container directly as opposed to presenting these APIs? That feels like a potential leaky abstraction to me, but that's just a gut feeling.

I could definitely see these as redundant since the Container does have Created accessible, but having other modules do the formatting seems like we could end up with a lot of duplication unless we had an interface to standardize that. Thoughts?

}

// RunningFor returns a human-readable representation of the duration for which
// the container has been running.
//
Expand Down