File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -43,9 +43,16 @@ func DefaultImagesGCConfig() ImagesGCConfig {
43
43
}
44
44
45
45
type ImagesGC struct {
46
- path string
46
+ // path contains the path to the GC cache when read from disk.
47
+ path string
48
+
49
+ // images contains the entries of the tracked docker images.
47
50
images []gcEntry
48
- clock func () time.Time
51
+
52
+ // clock returns the current time.
53
+ clock func () time.Time
54
+
55
+ // client implements a docker client.
49
56
client imagesGCClient
50
57
51
58
ImagesGCConfig
@@ -113,11 +120,16 @@ func (gc *ImagesGC) Persist() error {
113
120
return nil
114
121
}
115
122
123
+ err := os .MkdirAll (filepath .Dir (gc .path ), 0755 )
124
+ if err != nil && ! errors .Is (err , os .ErrExist ) {
125
+ return err
126
+ }
127
+
116
128
d , err := json .Marshal (gc .images )
117
129
if err != nil {
118
130
return fmt .Errorf ("failed to encode list of images: %w" , err )
119
131
}
120
- return os .WriteFile (gc .path , d , 0o644 )
132
+ return os .WriteFile (gc .path , d , 0644 )
121
133
}
122
134
123
135
// Track images before they are downloaded. Images already present are ignored if they are not already tracked.
You can’t perform that action at this time.
0 commit comments