configForLayers returns a minimally-plausible config for layers
(t *testing.T, layers []testBlob)
| 315 | |
| 316 | // configForLayers returns a minimally-plausible config for layers |
| 317 | func configForLayers(t *testing.T, layers []testBlob) testBlob { |
| 318 | rootFS := manifest.Schema2RootFS{ |
| 319 | Type: "layers", |
| 320 | DiffIDs: []digest.Digest{}, |
| 321 | } |
| 322 | for _, l := range layers { |
| 323 | rootFS.DiffIDs = append(rootFS.DiffIDs, l.uncompressedDigest) |
| 324 | } |
| 325 | // Add a unique label so that different calls to configForLayers don’t try to use the same image ID. |
| 326 | randomBytes := make([]byte, digest.Canonical.Size()) |
| 327 | _, err := rand.Read(randomBytes) |
| 328 | require.NoError(t, err) |
| 329 | config := manifest.Schema2Image{ |
| 330 | Schema2V1Image: manifest.Schema2V1Image{ |
| 331 | Config: &manifest.Schema2Config{ |
| 332 | Labels: map[string]string{"unique": fmt.Sprintf("%x", randomBytes)}, |
| 333 | }, |
| 334 | Created: time.Now(), |
| 335 | }, |
| 336 | RootFS: &rootFS, |
| 337 | } |
| 338 | configBytes, err := json.Marshal(config) |
| 339 | require.NoError(t, err) |
| 340 | configDigest := digest.Canonical.FromBytes(configBytes) |
| 341 | return testBlob{ |
| 342 | uncompressedDigest: configDigest, |
| 343 | compressedDigest: configDigest, |
| 344 | uncompressedSize: int64(len(configBytes)), |
| 345 | compressedSize: int64(len(configBytes)), |
| 346 | data: configBytes, |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | func createUncommittedImageDest(t *testing.T, ref types.ImageReference, cache types.BlobInfoCache, |
| 351 | layers []testBlob, config *testBlob) (types.ImageDestination, types.UnparsedImage) { |
no test coverage detected
searching dependent graphs…