MCPcopy Create free account
hub / github.com/containers/image / newImageSource

Function newImageSource

storage/storage_src.go:63–96  ·  view source on GitHub ↗

newImageSource sets up an image for reading.

(sys *types.SystemContext, imageRef storageReference)

Source from the content-addressed store, hash-verified

61
62// newImageSource sets up an image for reading.
63func newImageSource(sys *types.SystemContext, imageRef storageReference) (*storageImageSource, error) {
64 // First, locate the image.
65 img, err := imageRef.resolveImage(sys)
66 if err != nil {
67 return nil, err
68 }
69
70 // Build the reader object.
71 image := &storageImageSource{
72 PropertyMethodsInitialize: impl.PropertyMethods(impl.Properties{
73 HasThreadSafeGetBlob: true,
74 }),
75 NoGetBlobAtInitialize: stubs.NoGetBlobAt(imageRef),
76
77 imageRef: imageRef,
78 systemContext: sys,
79 image: img,
80 metadata: storageImageMetadata{
81 SignatureSizes: []int{},
82 SignaturesSizes: make(map[digest.Digest][]int),
83 },
84 getBlobMutexProtected: getBlobMutexProtected{
85 digestToLayerID: make(map[digest.Digest]string),
86 layerPosition: make(map[digest.Digest]int),
87 },
88 }
89 image.Compat = impl.AddCompat(image)
90 if img.Metadata != "" {
91 if err := json.Unmarshal([]byte(img.Metadata), &image.metadata); err != nil {
92 return nil, fmt.Errorf("decoding metadata for source image: %w", err)
93 }
94 }
95 return image, nil
96}
97
98// Reference returns the image reference that we used to find this image.
99func (s *storageImageSource) Reference() types.ImageReference {

Callers 2

newImageFunction · 0.70
NewImageSourceMethod · 0.70

Calls 4

PropertyMethodsFunction · 0.92
NoGetBlobAtFunction · 0.92
AddCompatFunction · 0.92
resolveImageMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…