summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-05-11 12:33:47 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-15 17:08:10 +0000
commitd870c25c012c8f8d39692d3c786c5f3ea0bd7169 (patch)
tree95ec275b645f7a34b0882f58b42ee446c2cae3b0 /pkg/varlinkapi
parent962fde3c6cc62fe60132c6c94d0aa10103a77862 (diff)
downloadpodman-d870c25c012c8f8d39692d3c786c5f3ea0bd7169.tar.gz
podman-d870c25c012c8f8d39692d3c786c5f3ea0bd7169.tar.bz2
podman-d870c25c012c8f8d39692d3c786c5f3ea0bd7169.zip
implement varlink commit
Signed-off-by: baude <bbaude@redhat.com> Closes: #762 Approved by: baude
Diffstat (limited to 'pkg/varlinkapi')
-rw-r--r--pkg/varlinkapi/images.go36
1 files changed, 32 insertions, 4 deletions
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go
index dc246fd7a..045b0f674 100644
--- a/pkg/varlinkapi/images.go
+++ b/pkg/varlinkapi/images.go
@@ -6,8 +6,10 @@ import (
"github.com/containers/image/docker"
"github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/projectatomic/buildah"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
+ "github.com/projectatomic/libpod/libpod"
"github.com/projectatomic/libpod/libpod/image"
sysreg "github.com/projectatomic/libpod/pkg/registries"
"github.com/projectatomic/libpod/pkg/util"
@@ -232,10 +234,36 @@ func (i *LibpodAPI) DeleteUnusedImages(call ioprojectatomicpodman.VarlinkCall) e
return call.ReplyDeleteUnusedImages(deletedImages)
}
-// CreateFromContainer ...
-// TODO This must wait until buildah is properly vendored into libpod
-func (i *LibpodAPI) CreateFromContainer(call ioprojectatomicpodman.VarlinkCall) error {
- return call.ReplyMethodNotImplemented("CreateFromContainer")
+// Commit ...
+func (i *LibpodAPI) Commit(call ioprojectatomicpodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool) error {
+ runtime, err := libpodruntime.GetRuntime(i.Cli)
+ if err != nil {
+ return call.ReplyRuntimeError(err.Error())
+ }
+ ctr, err := runtime.LookupContainer(name)
+ if err != nil {
+ return call.ReplyContainerNotFound(name)
+ }
+ sc := image.GetSystemContext(runtime.GetConfig().SignaturePolicyPath, "", false)
+ coptions := buildah.CommitOptions{
+ SignaturePolicyPath: runtime.GetConfig().SignaturePolicyPath,
+ ReportWriter: nil,
+ SystemContext: sc,
+ PreferredManifestType: buildah.OCIv1ImageManifest,
+ }
+ options := libpod.ContainerCommitOptions{
+ CommitOptions: coptions,
+ Pause: pause,
+ Message: message,
+ Changes: changes,
+ Author: author,
+ }
+
+ newImage, err := ctr.Commit(getContext(), imageName, options)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ return call.ReplyCommit(newImage.ID())
}
// ImportImage imports an image from a tarball to the image store