Merge pull request #46911 from vvoland/c8d-prune-dangling-default
c8d/prune: Default `dangling` to true, familiarize untagged images
This commit is contained in:
commit
312fbb6d41
2 changed files with 13 additions and 2 deletions
|
@ -341,3 +341,14 @@ func (i *ImageService) getAllImagesWithRepository(ctx context.Context, ref refer
|
|||
nameFilter := "^" + regexp.QuoteMeta(ref.Name()) + ":" + reference.TagRegexp.String() + "$"
|
||||
return i.client.ImageService().List(ctx, "name~="+strconv.Quote(nameFilter))
|
||||
}
|
||||
|
||||
func imageFamiliarName(img containerdimages.Image) string {
|
||||
if isDanglingImage(img) {
|
||||
return img.Target.Digest.String()
|
||||
}
|
||||
|
||||
if ref, err := reference.ParseNamed(img.Name); err == nil {
|
||||
return reference.FamiliarString(ref)
|
||||
}
|
||||
return img.Name
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func (i *ImageService) ImagesPrune(ctx context.Context, fltrs filters.Args) (*ty
|
|||
return nil, err
|
||||
}
|
||||
|
||||
danglingOnly, err := fltrs.GetBoolOrDefault("dangling", false)
|
||||
danglingOnly, err := fltrs.GetBoolOrDefault("dangling", true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFu
|
|||
|
||||
report.ImagesDeleted = append(report.ImagesDeleted,
|
||||
image.DeleteResponse{
|
||||
Untagged: img.Name,
|
||||
Untagged: imageFamiliarName(img),
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue