mirror of
https://github.com/containers/buildah.git
synced 2026-02-05 09:45:38 +01:00
Add --metadata-file
Add a MetadataFile field to BuildOptions, to which we write a dictionary of information about a just-committed image. Pay more attention to sourceDateEpoch than to timestamp when we're tagging an existing image with the intended destination name. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
22
internal/metadata/metadata.go
Normal file
22
internal/metadata/metadata.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"github.com/containers/buildah/docker"
|
||||
"github.com/opencontainers/go-digest"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// Build constructs a map containing the passed-in information about a just-committed or reused-as-cache image.
|
||||
func Build(imageConfigDigest digest.Digest, descriptor v1.Descriptor) (map[string]any, error) {
|
||||
metadata := make(map[string]any)
|
||||
if imageConfigDigest.Validate() == nil {
|
||||
metadata[docker.ExporterImageConfigDigestKey] = imageConfigDigest.String()
|
||||
}
|
||||
if descriptor.MediaType != "" && descriptor.Digest.Validate() == nil && descriptor.Size > 0 {
|
||||
metadata[docker.ExporterImageDescriptorKey] = descriptor
|
||||
}
|
||||
if descriptor.Digest.Validate() == nil {
|
||||
metadata[docker.ExporterImageDigestKey] = descriptor.Digest
|
||||
}
|
||||
return metadata, nil
|
||||
}
|
||||
Reference in New Issue
Block a user