-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Prune named but untagged images if danglingOnly=true #30330
Conversation
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.
Maybe we can add a quick test (do we already have a pull-by-digest test somewhere?) for this?
continue | ||
for _, ref := range refs { | ||
if _, ok := ref.(reference.NamedTagged); ok { | ||
repoTagsCount++ |
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.
Can just be a boolean and break can't it?
// Not a dangling image | ||
continue | ||
} | ||
if !danglingOnly { |
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.
Can we simplify this a bit?
Seems like we could do something like
shouldDelete := !danglingOnly
if !shouldDelete {
for _, ref := range refs {
if _, ok := ref.(reference.NamedTagged); ok {
shouldDelete = true
break
}
}
if shouldDelete {
// delete all the things
}
}
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
43e4060
to
044fa10
Compare
@cpuguy83 have a look at this version, it's indeed cleaner, thanks. |
continue | ||
shouldDelete := !danglingOnly | ||
if !shouldDelete { | ||
hasTag := false |
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.
This is really an extra variable since you can set shouldDelete
in the loop below.
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.
shouldDelete
needs to stay false
in that case. I only want to set it to true
if there's no NamedTagged
. If I were to set to true
here it would delete all images.
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 yes, missed that subtlety.
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
LGTM |
Signed-off-by: Kenfe-Mickael Laventure mickael.laventure@gmail.com
--
Closes #30307