-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix CREATED field when listing image if date is not specified #2107
Fix CREATED field when listing image if date is not specified #2107
Conversation
hey there, any comments on this? 🌱 |
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! And apologies for the long delay; maintainers have been quite busy, and there's a bit of a backlog in reviewing pull requests. Left a comment; suggestion following 🤗
cli/command/formatter/image.go
Outdated
@@ -235,6 +235,11 @@ func (c *imageContext) Digest() string { | |||
|
|||
func (c *imageContext) CreatedSince() string { | |||
createdAt := time.Unix(c.i.Created, 0) | |||
|
|||
if createdAt.IsZero() { | |||
return "<none>" |
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.
Thinking of a slightly different approach; I'll write down a comment / suggestion
I'm thinking if we should use this special format, or instead to return an empty string. I realise we already have some of the "special" values that we return, and have not been really consistent in that matter (unfortunately; bad choices in the past), e.g. here's an example of {
"Containers": "N/A",
"CreatedAt": "2019-08-20 22:19:55 +0200 CEST",
"CreatedSince": "2 months ago",
"Digest": "<none>",
"ID": "961769676411",
"Repository": "alpine",
"SharedSize": "N/A",
"Size": "5.58MB",
"Tag": "3.10",
"UniqueSize": "N/A",
"VirtualSize": "5.582MB"
} I'm thinking of using an empty string instead. That way, the docker image ls -a --format "table {{.ID}}\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}Prehistoric image, may contain dragons{{end}}"
IMAGE ID CREATED
dc2fed1afb2c 19 hours ago
8c75c34169e5 2 days ago
48479b5deffa 2 days ago
75fed645a5a0 Prehistoric image, may contain dragons
87b2dd3fa15d 3 days ago
3a3b77f619aa 3 days ago
1544ad69a5d2 Prehistoric image, may contain dragons
9614462fec5e 3 days ago
1f61a4270ed5 4 days ago If we go for this option, I'd be ok with changing the default table format to print cli/cli/command/formatter/image.go Lines 14 to 15 in 69fdd2a
I'm slightly leaning towards These would then look something like; defaultImageTableFormat = "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}N/A{{end}}\t{{.Size}}"
defaultImageTableFormatWithDigest = "table {{.Repository}}\t{{.Tag}}\t{{.Digest}}\t{{.ID}}\t{{if .CreatedSince }}{{.CreatedSince}}{{else}}N/A{{end}}\t{{.Size}}"
|
Happy to hear your thoughts! If you agree with my suggestions, could you update the pull request? As to the empty values themselves; I think this was a bug in BuildKit (not 100% sure), which should be resolved, but I agree that there may still be images with that issue, so it's nice to take those into account |
Hey there! I don't have strong opinions on this, so I'm good going with an empty string return and Will make the changes! |
Did the changes ✨ Here's the outputs:
|
Please sign your commits following these rules: $ git clone -b "2047-fix-image-createdsince-without-value" git@github.com:jonatasbaldin/cli.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354553256
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f Amending updates the existing PR. You DO NOT need to open a new one. |
cli/command/formatter/image.go
Outdated
@@ -235,6 +235,11 @@ func (c *imageContext) Digest() string { | |||
|
|||
func (c *imageContext) CreatedSince() string { | |||
createdAt := time.Unix(c.i.Created, 0) | |||
|
|||
if createdAt.IsZero() { | |||
return "N/A" |
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! Could you change this to return an empty string, so that the --format '{{ json .}}'
output will show the empty value as-is?
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.
Oh man, I'm so sorry, shouldn't do any PRs when I'm waking up hahaha Fixed.
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.
LOL no worries! 😂
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.
changes look good! erm (my bad, forgot to ask); could you squash your commits down to one? (Let me know if you need a hand on that)
Squashed ✨! |
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.
LGTM 👍
ping @vdemeester @silvin-lubecki PTAL |
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 for this PR @jonatasbaldin ! Just a small change requested 😅
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>
Hey there, just a gentle nudge on this! @silvin-lubecki answered your comment in the thread ✨ |
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.
LGTM
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.
LGTM
Thank you @jonatasbaldin !! |
Signed-off-by: Jonatas Baldin jonatas.baldin@gmail.com
Fixes #2047.
- What I did
When listing images with the
docker images
command, returns<none>
in theCREATED
field if the date is not specified during the image build. Without this fix, a292 years ago
string was displayed.- How I did it
Added a special case in the CLI formatter.
- How to verify it
docker pull nixery.dev/hello
Before the fix:
docker images
After the fix:
- Description for the changelog
Fix CREATED field when listing image if date is not specified.
- A picture of a cute animal (not mandatory but encouraged)
an alpaca an me