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

Function newImageDestination

storage/storage_dest.go:142–188  ·  view source on GitHub ↗

newImageDestination sets us up to write a new image, caching blobs in a temporary directory until it's time to Commit() the image

(sys *types.SystemContext, imageRef storageReference)

Source from the content-addressed store, hash-verified

140// newImageDestination sets us up to write a new image, caching blobs in a temporary directory until
141// it's time to Commit() the image
142func newImageDestination(sys *types.SystemContext, imageRef storageReference) (*storageImageDestination, error) {
143 directory, err := tmpdir.MkDirBigFileTemp(sys, "storage")
144 if err != nil {
145 return nil, fmt.Errorf("creating a temporary directory: %w", err)
146 }
147 dest := &storageImageDestination{
148 PropertyMethodsInitialize: impl.PropertyMethods(impl.Properties{
149 SupportedManifestMIMETypes: []string{
150 imgspecv1.MediaTypeImageManifest,
151 manifest.DockerV2Schema2MediaType,
152 manifest.DockerV2Schema1SignedMediaType,
153 manifest.DockerV2Schema1MediaType,
154 },
155 // We ultimately have to decompress layers to populate trees on disk
156 // and need to explicitly ask for it here, so that the layers' MIME
157 // types can be set accordingly.
158 DesiredLayerCompression: types.PreserveOriginal,
159 AcceptsForeignLayerURLs: false,
160 MustMatchRuntimeOS: true,
161 IgnoresEmbeddedDockerReference: true, // Yes, we want the unmodified manifest
162 HasThreadSafePutBlob: true,
163 }),
164
165 imageRef: imageRef,
166 directory: directory,
167 signatureses: make(map[digest.Digest][]byte),
168 metadata: storageImageMetadata{
169 SignatureSizes: []int{},
170 SignaturesSizes: make(map[digest.Digest][]int),
171 },
172 indexToStorageID: make(map[int]string),
173 lockProtected: storageImageDestinationLockProtected{
174 indexToAddedLayerInfo: make(map[int]addedLayerInfo),
175
176 indexToDiffID: make(map[int]digest.Digest),
177 indexToTOCDigest: make(map[int]digest.Digest),
178 blobDiffIDs: make(map[digest.Digest]digest.Digest),
179
180 diffOutputs: make(map[int]*graphdriver.DriverWithDifferOutput),
181 indexToAdditionalLayer: make(map[int]storage.AdditionalLayer),
182 filenames: make(map[digest.Digest]string),
183 fileSizes: make(map[digest.Digest]int64),
184 },
185 }
186 dest.Compat = impl.AddCompat(dest)
187 return dest, nil
188}
189
190// Reference returns the reference used to set up this destination. Note that this should directly correspond to user's intent,
191// e.g. it should use the public hostname instead of the result of resolving CNAMEs or following redirects.

Callers 1

NewImageDestinationMethod · 0.70

Calls 3

MkDirBigFileTempFunction · 0.92
PropertyMethodsFunction · 0.92
AddCompatFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…