cli/command/formatter: add CreatedAt to volume list output - #7146
Open
UditDewan wants to merge 1 commit into
Open
cli/command/formatter: add CreatedAt to volume list output#7146UditDewan wants to merge 1 commit into
UditDewan wants to merge 1 commit into
Conversation
Containers, images and networks all expose a "CreatedAt" placeholder in
their list output, but volumes did not, even though the API returns a
CreatedAt field for them. This made the creation time unavailable to
`docker volume ls --format`, including `--format json`.
Add a CreatedAt method to the volume context. The daemon returns the
value as an RFC3339 string, which is parsed and rendered with the same
formatting used by the other list commands, so that a template such as
`{{.CreatedAt}}` produces consistent output across commands.
The field is optional in the API, so an empty string is returned when
the daemon does not report a creation time; a value that cannot be
parsed is passed through as-is.
Fixes docker#3871
Signed-off-by: uditDewan <udit.dewan21@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a
CreatedAtplaceholder todocker volume ls --format, which fixes #3871.Containers, images and networks all expose
CreatedAtin their list output, but volumes did not, even though the API has returned aCreatedAtfield for volumes since API v1.42. As a result, the creation time was not reachable fromdocker volume ls --format '{{.CreatedAt}}'ordocker volume ls --format json, and consumers had to fall back todocker volume inspectper volume.Added a
CreatedAt()method tovolumeContextand registered theCREATED ATheader, mirroring the other list formatters.The API returns the value as an RFC3339 string, so it's parsed and rendered with
time.Time.String(), matching whatdocker ps,docker imagesanddocker network lsalready emit for{{.CreatedAt}}. Two edge cases are handled explicitly:omitemptyin the API, so an empty string is returned when the daemon doesn't report a creation time (rather than a zero time)The default table format is unchanged; this only adds a placeholder.
Unit tests were extended to cover the populated, empty and unparsable cases:
$ go test ./cli/command/formatter/ -run Volume -vAdd a
CreatedAtplaceholder to thedocker volume ls --formatoutput.🦫