steal creates an image using createAndPushImage and steals the signature ("sig") or attestation ("att")
(what string)
| 1428 | // steal creates an image using createAndPushImage and steals the signature |
| 1429 | // ("sig") or attestation ("att") |
| 1430 | func steal(what string) func(context.Context, string, string) (context.Context, error) { |
| 1431 | return func(ctx context.Context, imageName string, signatureFrom string) (context.Context, error) { |
| 1432 | ctx, err := CreateAndPushImageWithParent(ctx, imageName) |
| 1433 | if err != nil { |
| 1434 | return ctx, err |
| 1435 | } |
| 1436 | |
| 1437 | fromImg, err := imageFrom(ctx, signatureFrom) |
| 1438 | if err != nil { |
| 1439 | return ctx, err |
| 1440 | } |
| 1441 | |
| 1442 | fromDigest, err := fromImg.Digest() |
| 1443 | if err != nil { |
| 1444 | return ctx, err |
| 1445 | } |
| 1446 | |
| 1447 | fromRef, err := registry.ImageReferenceInStubRegistry(ctx, fmt.Sprintf("%s:%s-%s.%s", signatureFrom, fromDigest.Algorithm, fromDigest.Hex, what)) |
| 1448 | if err != nil { |
| 1449 | return ctx, err |
| 1450 | } |
| 1451 | |
| 1452 | stolen, err := remote.Image(fromRef) |
| 1453 | if err != nil { |
| 1454 | return ctx, err |
| 1455 | } |
| 1456 | |
| 1457 | toImg, err := imageFrom(ctx, imageName) |
| 1458 | if err != nil { |
| 1459 | return ctx, err |
| 1460 | } |
| 1461 | |
| 1462 | toDigest, err := toImg.Digest() |
| 1463 | if err != nil { |
| 1464 | return ctx, err |
| 1465 | } |
| 1466 | |
| 1467 | toRef, err := registry.ImageReferenceInStubRegistry(ctx, fmt.Sprintf("%s:%s-%s.%s", imageName, toDigest.Algorithm, toDigest.Hex, what)) |
| 1468 | if err != nil { |
| 1469 | return ctx, err |
| 1470 | } |
| 1471 | |
| 1472 | return ctx, remote.Write(toRef, stolen) |
| 1473 | } |
| 1474 | } |
| 1475 | |
| 1476 | func copyAllImages(ctx context.Context, source, destination string) (context.Context, error) { |
| 1477 | state := testenv.FetchState[imageState](ctx) |
no test coverage detected