images.go RawHistoryFolder
1package domain
2
3import "time"
4
5const DefaultImagePruneKeepLast = 3
6
7// ImagePruneOptions controls which prune subsystems are activated.
8type ImagePruneOptions struct {
9 // KeepLast is the number of most-recent non-latest tags to retain per repository.
10 KeepLast int
11 // PruneDangling enables runtime dangling image cleanup.
12 PruneDangling bool
13 // PruneRegistry enables registry tag retention and blob garbage collection.
14 PruneRegistry bool
15 // DryRun plans everything and deletes nothing.
16 DryRun bool
17}
18
19// DefaultImagePruneOptions returns options that prune both scopes with the default retention.
20func DefaultImagePruneOptions() ImagePruneOptions {
21 return ImagePruneOptions{
22 KeepLast: DefaultImagePruneKeepLast,
23 PruneDangling: true,
24 PruneRegistry: true,
25 }
26}
27
28// ImagePruneConfig defines scheduled image cleanup behavior.
29type ImagePruneConfig struct {
30 Enabled bool
31 Schedule BackupSchedule
32 // KeepLast is the number of most-recent non-latest tags to retain per repository.
33 // The latest tag is retained separately when present.
34 KeepLast int
35}
36
37// RuntimePruneResult reports runtime image cleanup results.
38type RuntimePruneResult struct {
39 DeletedCount int
40 // SpaceReclaimed is reported in bytes.
41 SpaceReclaimed int64
42}
43
44// RegistryPruneResult reports registry cleanup results.
45type RegistryPruneResult struct {
46 TagsRemoved int
47 BlobsRemoved int
48 // SpaceReclaimed is reported in bytes.
49 SpaceReclaimed int64
50 // UploadsRemoved is the number of stale upload files removed.
51 UploadsRemoved int
52 // UploadSpaceReclaimed is bytes recovered from stale uploads.
53 UploadSpaceReclaimed int64
54}
55
56// ImagePruneReport aggregates runtime and registry cleanup results.
57type ImagePruneReport struct {
58 Runtime RuntimePruneResult
59 Registry RegistryPruneResult
60 // Plan carries every candidate's verdict, the inventory gaps, and
61 // the applied flag. Dry-run and execution share this shape.
62 Plan PruneReport
63}
64
65// ImageInfo describes an image/tag visible from runtime and registry data.
66type ImageInfo struct {
67 Repository string
68 Tag string
69 // Size is reported in bytes.
70 Size int64
71 Created time.Time
72 // ID is the runtime image identifier (for example, image ID/digest).
73 ID string
74 Dangling bool
75}