diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-05 09:20:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 09:20:16 -0400 |
commit | a278195af3423f882c1f5bb218792f7c2ce10a3c (patch) | |
tree | 192e52054de2abf0c92d83ecdbc71d498c2ec947 /libpod/container_commit.go | |
parent | 8eefca5a257121b177562742c972e39e1686140d (diff) | |
parent | 0f7d54b0260c1be992ee3b9cee359ef3a9e8bd21 (diff) | |
download | podman-a278195af3423f882c1f5bb218792f7c2ce10a3c.tar.gz podman-a278195af3423f882c1f5bb218792f7c2ce10a3c.tar.bz2 podman-a278195af3423f882c1f5bb218792f7c2ce10a3c.zip |
Merge pull request #10147 from vrothberg/new-image-package
migrate Podman to containers/common/libimage
Diffstat (limited to 'libpod/container_commit.go')
-rw-r--r-- | libpod/container_commit.go | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/libpod/container_commit.go b/libpod/container_commit.go index 22da0c566..c1dd42942 100644 --- a/libpod/container_commit.go +++ b/libpod/container_commit.go @@ -6,12 +6,11 @@ import ( "strings" "github.com/containers/buildah" - "github.com/containers/buildah/util" + "github.com/containers/common/libimage" is "github.com/containers/image/v5/storage" "github.com/containers/image/v5/types" "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/events" - "github.com/containers/podman/v3/libpod/image" libpodutil "github.com/containers/podman/v3/pkg/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -32,11 +31,7 @@ type ContainerCommitOptions struct { // Commit commits the changes between a container and its image, creating a new // image -func (c *Container) Commit(ctx context.Context, destImage string, options ContainerCommitOptions) (*image.Image, error) { - var ( - imageRef types.ImageReference - ) - +func (c *Container) Commit(ctx context.Context, destImage string, options ContainerCommitOptions) (*libimage.Image, error) { if c.config.Rootfs != "" { return nil, errors.Errorf("cannot commit a container that uses an exploded rootfs") } @@ -61,7 +56,6 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai }() } - sc := image.GetSystemContext(options.SignaturePolicyPath, "", false) builderOptions := buildah.ImportOptions{ Container: c.ID(), SignaturePolicyPath: options.SignaturePolicyPath, @@ -69,7 +63,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai commitOptions := buildah.CommitOptions{ SignaturePolicyPath: options.SignaturePolicyPath, ReportWriter: options.ReportWriter, - SystemContext: sc, + SystemContext: c.runtime.imageContext, PreferredManifestType: options.PreferredManifestType, } importBuilder, err := buildah.ImportBuilder(ctx, c.runtime.store, builderOptions) @@ -191,20 +185,28 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai importBuilder.SetOnBuild(onbuild) } - candidates, _, _, err := util.ResolveName(destImage, "", sc, c.runtime.store) - if err != nil { - return nil, errors.Wrapf(err, "error resolving name %q", destImage) - } - if len(candidates) > 0 { - imageRef, err = is.Transport.ParseStoreReference(c.runtime.store, candidates[0]) + var commitRef types.ImageReference + if destImage != "" { + // Now resolve the name. + resolvedImageName, err := c.runtime.LibimageRuntime().ResolveName(destImage) + if err != nil { + return nil, err + } + + imageRef, err := is.Transport.ParseStoreReference(c.runtime.store, resolvedImageName) if err != nil { return nil, errors.Wrapf(err, "error parsing target image name %q", destImage) } + commitRef = imageRef } - id, _, _, err := importBuilder.Commit(ctx, imageRef, commitOptions) + id, _, _, err := importBuilder.Commit(ctx, commitRef, commitOptions) if err != nil { return nil, err } defer c.newContainerEvent(events.Commit) - return c.runtime.imageRuntime.NewFromLocal(id) + img, _, err := c.runtime.libimageRuntime.LookupImage(id, nil) + if err != nil { + return nil, err + } + return img, nil } |