14
14
* limitations under the License.
15
15
*/
16
16
17
+ //go:generate mockgen -destination mocks/job_mock.go -source image.go -package mocks
18
+
17
19
package job
18
20
19
21
import (
@@ -165,10 +167,26 @@ type ManifestRequest struct {
165
167
InsecureSkipVerify bool
166
168
}
167
169
170
+ // Image implements the interface for handling container images.
171
+ type Image interface {
172
+ // CreatePreheatRequestsByManifestURL generates a list of preheat requests for a container image
173
+ // by fetching and parsing its manifest from a registry. It handles authentication, platform-specific
174
+ // manifest filtering, and layer extraction for preheating.
175
+ CreatePreheatRequestsByManifestURL (ctx context.Context , req * ManifestRequest ) ([]* PreheatRequest , error )
176
+ }
177
+
178
+ // image is the implementation of the Image interface.
179
+ type image struct {}
180
+
181
+ // NewImage creates a new instance of the Image interface.
182
+ func NewImage () Image {
183
+ return & image {}
184
+ }
185
+
168
186
// CreatePreheatRequestsByManifestURL generates a list of preheat requests for a container image
169
187
// by fetching and parsing its manifest from a registry. It handles authentication, platform-specific
170
188
// manifest filtering, and layer extraction for preheating.
171
- func CreatePreheatRequestsByManifestURL (ctx context.Context , req * ManifestRequest ) ([]PreheatRequest , error ) {
189
+ func ( i * image ) CreatePreheatRequestsByManifestURL (ctx context.Context , req * ManifestRequest ) ([]* PreheatRequest , error ) {
172
190
ctx , span := tracer .Start (ctx , config .SpanGetLayers , trace .WithSpanKind (trace .SpanKindProducer ))
173
191
defer span .End ()
174
192
@@ -320,7 +338,7 @@ func filterManifests(manifests []manifestlist.ManifestDescriptor, platform specs
320
338
// buildPreheatRequestFromManifests constructs preheat requests for container image layers from
321
339
// the provided manifests. It extracts layer URLs from the manifests and builds a PreheatRequest
322
340
// using the specified arguments, headers, and TLS settings.
323
- func buildPreheatRequestFromManifests (manifests []distribution.Manifest , req * ManifestRequest , header http.Header , image * preheatImage ) ([]PreheatRequest , error ) {
341
+ func buildPreheatRequestFromManifests (manifests []distribution.Manifest , req * ManifestRequest , header http.Header , image * preheatImage ) ([]* PreheatRequest , error ) {
324
342
var certificateChain [][]byte
325
343
if req .RootCAs != nil {
326
344
certificateChain = req .RootCAs .Subjects ()
@@ -334,7 +352,7 @@ func buildPreheatRequestFromManifests(manifests []distribution.Manifest, req *Ma
334
352
}
335
353
}
336
354
337
- layers := PreheatRequest {
355
+ layers := & PreheatRequest {
338
356
URLs : layerURLs ,
339
357
PieceLength : req .PieceLength ,
340
358
Tag : req .Tag ,
@@ -352,7 +370,7 @@ func buildPreheatRequestFromManifests(manifests []distribution.Manifest, req *Ma
352
370
Timeout : req .Timeout ,
353
371
}
354
372
355
- return []PreheatRequest {layers }, nil
373
+ return []* PreheatRequest {layers }, nil
356
374
}
357
375
358
376
// imageAuthClientOption is an option for imageAuthClient.
0 commit comments