summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-02-13 18:42:00 +0100
committerGitHub <noreply@github.com>2019-02-13 18:42:00 +0100
commit62d88558e7637b72ea9ef53d1b3a2d08f2c6a51e (patch)
tree94834334f7b22ae6e914a3cfabe68c9bf5bde968 /pkg/varlinkapi
parentdf52dac1e70ea04dc3de8e7372e23c47f06291d6 (diff)
parent7dcc21f21311ee1ff3fe6974d5926bec7d181e5c (diff)
downloadpodman-62d88558e7637b72ea9ef53d1b3a2d08f2c6a51e.tar.gz
podman-62d88558e7637b72ea9ef53d1b3a2d08f2c6a51e.tar.bz2
podman-62d88558e7637b72ea9ef53d1b3a2d08f2c6a51e.zip
Merge pull request #2322 from baude/remotepush
podman-remote push
Diffstat (limited to 'pkg/varlinkapi')
-rw-r--r--pkg/varlinkapi/images.go61
1 files changed, 55 insertions, 6 deletions
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go
index 9dfc9db03..ca920dfeb 100644
--- a/pkg/varlinkapi/images.go
+++ b/pkg/varlinkapi/images.go
@@ -28,6 +28,7 @@ import (
"github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
)
// ListImages lists all the images in the store
@@ -240,7 +241,7 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI
time.Sleep(1 * time.Second)
break
}
- br := iopodman.BuildResponse{
+ br := iopodman.MoreResponse{
Logs: log,
}
call.ReplyBuildImage(br)
@@ -258,7 +259,7 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
- br := iopodman.BuildResponse{
+ br := iopodman.MoreResponse{
Logs: log,
Id: newImage.ID(),
}
@@ -326,7 +327,6 @@ func (i *LibpodAPI) PushImage(call iopodman.VarlinkCall, name, tag string, tlsVe
registryCreds *types.DockerAuthConfig
manifestType string
)
-
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
if err != nil {
return call.ReplyImageNotFound(err.Error())
@@ -366,10 +366,59 @@ func (i *LibpodAPI) PushImage(call iopodman.VarlinkCall, name, tag string, tlsVe
SignBy: signBy,
}
- if err := newImage.PushImageToHeuristicDestination(getContext(), destname, manifestType, "", signaturePolicy, nil, compress, so, &dockerRegistryOptions, nil); err != nil {
- return call.ReplyErrorOccurred(err.Error())
+ if call.WantsMore() {
+ call.Continues = true
+ }
+
+ output := bytes.NewBuffer([]byte{})
+ c := make(chan error)
+ go func() {
+ err := newImage.PushImageToHeuristicDestination(getContext(), destname, manifestType, "", signaturePolicy, output, compress, so, &dockerRegistryOptions, nil)
+ c <- err
+ close(c)
+ }()
+
+ // TODO When pull output gets fixed for the remote client, we need to look into how we can turn below
+ // into something re-usable. it is in build too
+ var log []string
+ done := false
+ for {
+ line, err := output.ReadString('\n')
+ if err == nil {
+ log = append(log, line)
+ continue
+ } else if err == io.EOF {
+ select {
+ case err := <-c:
+ if err != nil {
+ logrus.Errorf("reading of output during push failed for %s", newImage.ID())
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ done = true
+ default:
+ if !call.WantsMore() {
+ time.Sleep(1 * time.Second)
+ break
+ }
+ br := iopodman.MoreResponse{
+ Logs: log,
+ }
+ call.ReplyPushImage(br)
+ log = []string{}
+ }
+ } else {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ if done {
+ break
+ }
+ }
+ call.Continues = false
+
+ br := iopodman.MoreResponse{
+ Logs: log,
}
- return call.ReplyPushImage(newImage.ID())
+ return call.ReplyPushImage(br)
}
// TagImage accepts an image name and tag as strings and tags an image in the local store.