mirror of
https://github.com/containers/podman.git
synced 2025-05-17 23:26:08 +08:00

This requires updating all import paths throughout, and a matching buildah update to interoperate. I can't figure out the reason for go.mod tracking github.com/containers/image v3.0.2+incompatible // indirect ((go mod graph) lists it as a direct dependency of libpod, but (go list -json -m all) lists it as an indirect dependency), but at least looking at the vendor subdirectory, it doesn't seem to be actually used in the built binaries. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
32 lines
1015 B
Go
32 lines
1015 B
Go
package copy
|
|
|
|
import (
|
|
"github.com/containers/image/v4/signature"
|
|
"github.com/containers/image/v4/transports"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// createSignature creates a new signature of manifest using keyIdentity.
|
|
func (c *copier) createSignature(manifest []byte, keyIdentity string) ([]byte, error) {
|
|
mech, err := signature.NewGPGSigningMechanism()
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "Error initializing GPG")
|
|
}
|
|
defer mech.Close()
|
|
if err := mech.SupportsSigning(); err != nil {
|
|
return nil, errors.Wrap(err, "Signing not supported")
|
|
}
|
|
|
|
dockerReference := c.dest.Reference().DockerReference()
|
|
if dockerReference == nil {
|
|
return nil, errors.Errorf("Cannot determine canonical Docker reference for destination %s", transports.ImageName(c.dest.Reference()))
|
|
}
|
|
|
|
c.Printf("Signing manifest\n")
|
|
newSig, err := signature.SignDockerManifest(manifest, dockerReference.String(), mech, keyIdentity)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "Error creating signature")
|
|
}
|
|
return newSig, nil
|
|
}
|