MCPcopy Create free account
hub / github.com/conforma/cli / steal

Function steal

acceptance/image/image.go:1430–1474  ·  view source on GitHub ↗

steal creates an image using createAndPushImage and steals the signature ("sig") or attestation ("att")

(what string)

Source from the content-addressed store, hash-verified

1428// steal creates an image using createAndPushImage and steals the signature
1429// ("sig") or attestation ("att")
1430func 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
1476func copyAllImages(ctx context.Context, source, destination string) (context.Context, error) {
1477 state := testenv.FetchState[imageState](ctx)

Callers 1

AddStepsToFunction · 0.85

Calls 6

imageFromFunction · 0.85
ImageMethod · 0.65
DigestMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected