summaryrefslogtreecommitdiff
path: root/libpod/container_commit.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/container_commit.go')
-rw-r--r--libpod/container_commit.go36
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
}