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

Function createAndPushKeylessImage

acceptance/image/image.go:1041–1182  ·  view source on GitHub ↗

createAndPushKeylessImage loads an existing image from disk, along its signature and attestation into the docker registry.

(ctx context.Context, imageName string)

Source from the content-addressed store, hash-verified

1039// createAndPushKeylessImage loads an existing image from disk, along its signature and attestation
1040// into the docker registry.
1041func createAndPushKeylessImage(ctx context.Context, imageName string) (context.Context, error) {
1042 ref, err := registry.ImageReferenceInStubRegistry(ctx, imageName)
1043 if err != nil {
1044 return ctx, err
1045 }
1046
1047 cwd, err := os.Getwd()
1048 if err != nil {
1049 return ctx, err
1050 }
1051
1052 imageDir := path.Join(cwd, "acceptance", "image", "testimage")
1053 // get the signed image from disk
1054 sii, err := layout.SignedImageIndex(imageDir)
1055 if err != nil {
1056 return ctx, err
1057 }
1058
1059 if err := cosignRemote.WriteSignedImageIndexImages(ref, sii, ""); err != nil {
1060 return ctx, err
1061 }
1062
1063 var state *imageState
1064 ctx, err = testenv.SetupState(ctx, &state)
1065 if err != nil {
1066 return ctx, err
1067 }
1068
1069 if state.Images == nil {
1070 state.Images = make(map[string]string)
1071 }
1072 state.Images[imageName] = ref.String()
1073
1074 storeSignatureData := func(where map[string]Signature, f func() (oci.Signatures, error)) error {
1075 sigs, err := f()
1076 if err != nil {
1077 return err
1078 }
1079
1080 m, err := sigs.Manifest()
1081 if err != nil {
1082 return err
1083 }
1084
1085 // read the signature from the layer annotations
1086 for _, l := range m.Layers {
1087 // just check for a single annotation
1088 var signature string
1089 var ok bool
1090 if signature, ok = l.Annotations[static.SignatureAnnotationKey]; !ok {
1091 continue
1092 }
1093
1094 sig := Signature{
1095 Signature: signature,
1096 }
1097
1098 if certPEM, ok := l.Annotations[static.CertificateAnnotationKey]; ok {

Callers

nothing calls this directly

Calls 5

SetupStateFunction · 0.92
unmarshallSignaturesFunction · 0.85
StringMethod · 0.45
UncompressedMethod · 0.45

Tested by

no test coverage detected