Skip to content

Commit adb11d7

Browse files
committed
implement imagePull
1 parent cbe538e commit adb11d7

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

engine/virt/image.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"io"
8+
"strings"
89

910
virttypes "github.com/projecteru2/libyavirt/types"
1011

@@ -50,7 +51,21 @@ func (v *Virt) ImagesPrune(ctx context.Context) (err error) {
5051

5152
// ImagePull pulls an image to local virt-node.
5253
func (v *Virt) ImagePull(ctx context.Context, ref string, all bool) (rc io.ReadCloser, err error) {
53-
return
54+
// ref is a simple image name without username for now
55+
_, imgName, err := splitUserImage(ref)
56+
if err != nil {
57+
return nil, err
58+
}
59+
60+
msg, err := v.client.PullImage(ctx, imgName, all)
61+
if err != nil {
62+
return nil, err
63+
}
64+
65+
rc = io.NopCloser(strings.NewReader(msg))
66+
defer rc.Close()
67+
68+
return rc, err
5469
}
5570

5671
// ImagePush pushes to central image registry.

go.mod

+4
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ require (
5252
google.golang.org/grpc v1.40.0
5353
google.golang.org/protobuf v1.27.1
5454
)
55+
56+
replace (
57+
github.com/projecteru2/libyavirt => github.com/aceralon/libyavirt v0.0.0-20211214081924-914bb8e63e63
58+
)

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ github.com/Microsoft/hcsshim v0.8.11 h1:qs8+XI1mFA1H/zhXT9qVG/lcJO18p1yCsICIrCjV
2929
github.com/Microsoft/hcsshim v0.8.11/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg=
3030
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
3131
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
32+
github.com/aceralon/libyavirt v0.0.0-20211213100554-b2a6833f0bca h1:BqZvJm7xfsaN4avybNioNbjivAyTXa51/57Ld+W9xW8=
33+
github.com/aceralon/libyavirt v0.0.0-20211213100554-b2a6833f0bca/go.mod h1:FOc+hWBMLsMrmx5p3/moizKeSomedZPNwB6LhS+kEnE=
34+
github.com/aceralon/libyavirt v0.0.0-20211214081924-914bb8e63e63 h1:P6qlWoAZSszKRb5WElhtSda4r4jXoj3NmD+HSc+s6gg=
35+
github.com/aceralon/libyavirt v0.0.0-20211214081924-914bb8e63e63/go.mod h1:FOc+hWBMLsMrmx5p3/moizKeSomedZPNwB6LhS+kEnE=
3236
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
3337
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
3438
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=

0 commit comments

Comments
 (0)