from/import: record the base image's digest, if it has one
Record the digest of the base image's manifest, if there is a base image. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #1724 Approved by: rhatdan
This commit is contained in:
parent
5da3c8cdb7
commit
d7dec37df7
|
@ -119,6 +119,9 @@ type Builder struct {
|
|||
// FromImageID is the ID of the source image which was used to create
|
||||
// the container, if one was used. It should not be modified.
|
||||
FromImageID string `json:"image-id"`
|
||||
// FromImageDigest is the digest of the source image which was used to
|
||||
// create the container, if one was used. It should not be modified.
|
||||
FromImageDigest string `json:"image-digest"`
|
||||
// Config is the source image's configuration. It should not be
|
||||
// modified.
|
||||
Config []byte `json:"config,omitempty"`
|
||||
|
@ -200,6 +203,7 @@ type BuilderInfo struct {
|
|||
Type string
|
||||
FromImage string
|
||||
FromImageID string
|
||||
FromImageDigest string
|
||||
Config string
|
||||
Manifest string
|
||||
Container string
|
||||
|
@ -243,6 +247,7 @@ func GetBuildInfo(b *Builder) BuilderInfo {
|
|||
Type: b.Type,
|
||||
FromImage: b.FromImage,
|
||||
FromImageID: b.FromImageID,
|
||||
FromImageDigest: b.FromImageDigest,
|
||||
Config: string(b.Config),
|
||||
Manifest: string(b.Manifest),
|
||||
Container: b.Container,
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/containers/buildah/docker"
|
||||
"github.com/containers/buildah/util"
|
||||
"github.com/containers/image/manifest"
|
||||
is "github.com/containers/image/storage"
|
||||
"github.com/containers/image/types"
|
||||
"github.com/containers/storage"
|
||||
|
@ -47,6 +48,13 @@ func importBuilderDataFromImage(ctx context.Context, store storage.Store, system
|
|||
}
|
||||
}
|
||||
|
||||
imageDigest := ""
|
||||
if manifestBytes, _, err := src.Manifest(ctx); err == nil {
|
||||
if manifestDigest, err := manifest.Digest(manifestBytes); err == nil {
|
||||
imageDigest = manifestDigest.String()
|
||||
}
|
||||
}
|
||||
|
||||
defaultNamespaceOptions, err := DefaultNamespaceOptions()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -57,6 +65,7 @@ func importBuilderDataFromImage(ctx context.Context, store storage.Store, system
|
|||
Type: containerType,
|
||||
FromImage: imageName,
|
||||
FromImageID: imageID,
|
||||
FromImageDigest: imageDigest,
|
||||
Container: containerName,
|
||||
ContainerID: containerID,
|
||||
ImageAnnotations: map[string]string{},
|
||||
|
|
8
new.go
8
new.go
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/containers/buildah/util"
|
||||
"github.com/containers/image/manifest"
|
||||
"github.com/containers/image/pkg/sysregistries"
|
||||
is "github.com/containers/image/storage"
|
||||
"github.com/containers/image/transports"
|
||||
|
@ -254,6 +255,7 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
|
|||
}
|
||||
image := options.FromImage
|
||||
imageID := ""
|
||||
imageDigest := ""
|
||||
topLayer := ""
|
||||
if img != nil {
|
||||
image = getImageName(imageNamePrefix(image), img)
|
||||
|
@ -266,6 +268,11 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
|
|||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error instantiating image for %q", transports.ImageName(ref))
|
||||
}
|
||||
if manifestBytes, _, err := src.Manifest(ctx); err == nil {
|
||||
if manifestDigest, err := manifest.Digest(manifestBytes); err == nil {
|
||||
imageDigest = manifestDigest.String()
|
||||
}
|
||||
}
|
||||
defer src.Close()
|
||||
}
|
||||
|
||||
|
@ -327,6 +334,7 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
|
|||
Type: containerType,
|
||||
FromImage: image,
|
||||
FromImageID: imageID,
|
||||
FromImageDigest: imageDigest,
|
||||
Container: name,
|
||||
ContainerID: container.ID,
|
||||
ImageAnnotations: map[string]string{},
|
||||
|
|
Loading…
Reference in New Issue