Update c/common to an unreleased version

... to get https://github.com/containers/common/pull/1106 .

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2022-07-28 23:27:42 +02:00
parent b01478044b
commit 63d77da5b9
55 changed files with 5704 additions and 416 deletions

View File

@ -102,6 +102,13 @@ type CopyOptions struct {
// If non-empty, asks for a signature to be added during the copy, and
// specifies a key ID.
SignBy string
// If non-empty, passphrase to use when signing with the key ID from SignBy.
SignPassphrase string
// If non-empty, asks for a signature to be added during the copy, using
// a sigstore private key file at the provided path.
SignBySigstorePrivateKeyFile string
// Passphrase to use when signing with SignBySigstorePrivateKeyFile.
SignSigstorePrivateKeyPassphrase []byte
// Remove any pre-existing signatures. SignBy will still add a new
// signature.
RemoveSignatures bool
@ -293,6 +300,9 @@ func (r *Runtime) newCopier(options *CopyOptions) (*copier, error) {
c.imageCopyOptions.OciDecryptConfig = options.OciDecryptConfig
c.imageCopyOptions.RemoveSignatures = options.RemoveSignatures
c.imageCopyOptions.SignBy = options.SignBy
c.imageCopyOptions.SignPassphrase = options.SignPassphrase
c.imageCopyOptions.SignBySigstorePrivateKeyFile = options.SignBySigstorePrivateKeyFile
c.imageCopyOptions.SignSigstorePrivateKeyPassphrase = options.SignSigstorePrivateKeyPassphrase
c.imageCopyOptions.ReportWriter = options.Writer
defaultContainerConfig, err := config.Default()

View File

@ -13,6 +13,7 @@ import (
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/image/v5/types"
"github.com/containers/storage"
structcopier "github.com/jinzhu/copier"
"github.com/opencontainers/go-digest"
)
@ -39,6 +40,28 @@ type ManifestList struct {
list manifests.List
}
// ManifestListDescriptor references a platform-specific manifest.
// Contains exclusive field like `annotations` which is only present in
// OCI spec and not in docker image spec.
type ManifestListDescriptor struct {
manifest.Schema2Descriptor
Platform manifest.Schema2PlatformSpec `json:"platform"`
// Annotations contains arbitrary metadata for the image index.
Annotations map[string]string `json:"annotations,omitempty"`
}
// ManifestListData is a list of platform-specific manifests, specifically used to
// generate output struct for `podman manifest inspect`. Reason for maintaining and
// having this type is to ensure we can have a common type which contains exclusive
// fields from both Docker manifest format and OCI manifest format.
type ManifestListData struct {
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Manifests []ManifestListDescriptor `json:"manifests"`
// Annotations contains arbitrary metadata for the image index.
Annotations map[string]string `json:"annotations,omitempty"`
}
// ID returns the ID of the manifest list.
func (m *ManifestList) ID() string {
return m.image.ID()
@ -210,8 +233,21 @@ func (i *Image) IsManifestList(ctx context.Context) (bool, error) {
}
// Inspect returns a dockerized version of the manifest list.
func (m *ManifestList) Inspect() (*manifest.Schema2List, error) {
return m.list.Docker(), nil
func (m *ManifestList) Inspect() (*ManifestListData, error) {
inspectList := ManifestListData{}
dockerFormat := m.list.Docker()
err := structcopier.Copy(&inspectList, &dockerFormat)
if err != nil {
return &inspectList, err
}
// Get missing annotation field from OCIv1 Spec
// and populate inspect data.
ociFormat := m.list.OCIv1()
inspectList.Annotations = ociFormat.Annotations
for i, manifest := range ociFormat.Manifests {
inspectList.Manifests[i].Annotations = manifest.Annotations
}
return &inspectList, nil
}
// Options for adding a manifest list.
@ -411,14 +447,17 @@ func (m *ManifestList) Push(ctx context.Context, destination string, options *Ma
defer copier.close()
pushOptions := manifests.PushOptions{
Store: m.image.runtime.store,
SystemContext: copier.systemContext,
ImageListSelection: options.ImageListSelection,
Instances: options.Instances,
ReportWriter: options.Writer,
SignBy: options.SignBy,
RemoveSignatures: options.RemoveSignatures,
ManifestType: options.ManifestMIMEType,
Store: m.image.runtime.store,
SystemContext: copier.systemContext,
ImageListSelection: options.ImageListSelection,
Instances: options.Instances,
ReportWriter: options.Writer,
SignBy: options.SignBy,
SignPassphrase: options.SignPassphrase,
SignBySigstorePrivateKeyFile: options.SignBySigstorePrivateKeyFile,
SignSigstorePrivateKeyPassphrase: options.SignSigstorePrivateKeyPassphrase,
RemoveSignatures: options.RemoveSignatures,
ManifestType: options.ManifestMIMEType,
}
_, d, err := m.list.Push(ctx, dest, pushOptions)

View File

@ -56,15 +56,18 @@ type List interface {
// PushOptions includes various settings which are needed for pushing the
// manifest list and its instances.
type PushOptions struct {
Store storage.Store
SystemContext *types.SystemContext // github.com/containers/image/types.SystemContext
ImageListSelection cp.ImageListSelection // set to either CopySystemImage, CopyAllImages, or CopySpecificImages
Instances []digest.Digest // instances to copy if ImageListSelection == CopySpecificImages
ReportWriter io.Writer // will be used to log the writing of the list and any blobs
SignBy string // fingerprint of GPG key to use to sign images
RemoveSignatures bool // true to discard signatures in images
ManifestType string // the format to use when saving the list - possible options are oci, v2s1, and v2s2
SourceFilter LookupReferenceFunc // filter the list source
Store storage.Store
SystemContext *types.SystemContext // github.com/containers/image/types.SystemContext
ImageListSelection cp.ImageListSelection // set to either CopySystemImage, CopyAllImages, or CopySpecificImages
Instances []digest.Digest // instances to copy if ImageListSelection == CopySpecificImages
ReportWriter io.Writer // will be used to log the writing of the list and any blobs
SignBy string // fingerprint of GPG key to use to sign images
SignPassphrase string // passphrase to use when signing with the key ID from SignBy.
SignBySigstorePrivateKeyFile string // if non-empty, asks for a signature to be added during the copy, using a sigstore private key file at the provided path.
SignSigstorePrivateKeyPassphrase []byte // passphrase to use when signing with SignBySigstorePrivateKeyFile.
RemoveSignatures bool // true to discard signatures in images
ManifestType string // the format to use when saving the list - possible options are oci, v2s1, and v2s2
SourceFilter LookupReferenceFunc // filter the list source
}
// Create creates a new list containing information about the specified image,
@ -235,14 +238,17 @@ func (l *list) Push(ctx context.Context, dest types.ImageReference, options Push
}
}
copyOptions := &cp.Options{
ImageListSelection: options.ImageListSelection,
Instances: options.Instances,
SourceCtx: options.SystemContext,
DestinationCtx: options.SystemContext,
ReportWriter: options.ReportWriter,
RemoveSignatures: options.RemoveSignatures,
SignBy: options.SignBy,
ForceManifestMIMEType: singleImageManifestType,
ImageListSelection: options.ImageListSelection,
Instances: options.Instances,
SourceCtx: options.SystemContext,
DestinationCtx: options.SystemContext,
ReportWriter: options.ReportWriter,
RemoveSignatures: options.RemoveSignatures,
SignBy: options.SignBy,
SignPassphrase: options.SignPassphrase,
SignBySigstorePrivateKeyFile: options.SignBySigstorePrivateKeyFile,
SignSigstorePrivateKeyPassphrase: options.SignSigstorePrivateKeyPassphrase,
ForceManifestMIMEType: singleImageManifestType,
}
// Copy whatever we were asked to copy.

View File

@ -1,4 +1,4 @@
package version
// Version is the version of the build.
const Version = "0.49.0-dev"
const Version = "0.49.1-dev"