(diffID digest.Digest, options types.ImageImportOptions)
| 241 | } |
| 242 | |
| 243 | func buildImageConfig(diffID digest.Digest, options types.ImageImportOptions) ([]byte, digest.Digest, error) { |
| 244 | ociplat := platforms.DefaultSpec() |
| 245 | if options.Platform != "" { |
| 246 | if p, err := platforms.Parse(options.Platform); err == nil { |
| 247 | ociplat = p |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | created := time.Now().UTC() |
| 252 | imgConfig := ocispec.Image{ |
| 253 | Platform: ocispec.Platform{ |
| 254 | Architecture: ociplat.Architecture, |
| 255 | OS: ociplat.OS, |
| 256 | OSVersion: ociplat.OSVersion, |
| 257 | Variant: ociplat.Variant, |
| 258 | }, |
| 259 | Created: &created, |
| 260 | Config: ocispec.ImageConfig{}, |
| 261 | RootFS: ocispec.RootFS{ |
| 262 | Type: "layers", |
| 263 | DiffIDs: []digest.Digest{diffID}, |
| 264 | }, |
| 265 | History: []ocispec.History{{ |
| 266 | Created: &created, |
| 267 | Comment: options.Message, |
| 268 | }}, |
| 269 | } |
| 270 | |
| 271 | configJSON, err := json.Marshal(imgConfig) |
| 272 | if err != nil { |
| 273 | return nil, "", err |
| 274 | } |
| 275 | return configJSON, digest.FromBytes(configJSON), nil |
| 276 | } |
| 277 | |
| 278 | func readLayerContent(ctx context.Context, cs content.Store, layerDigest digest.Digest, size int64) ([]byte, error) { |
| 279 | ra, err := cs.ReaderAt(ctx, ocispec.Descriptor{Digest: layerDigest, Size: size}) |
no test coverage detected
searching dependent graphs…