Skip to content

Commit

Permalink
implement imagePull
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceralon committed Dec 14, 2021
1 parent cbe538e commit adb11d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
17 changes: 16 additions & 1 deletion engine/virt/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"io"
"strings"

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

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

// ImagePull pulls an image to local virt-node.
func (v *Virt) ImagePull(ctx context.Context, ref string, all bool) (rc io.ReadCloser, err error) {
return
// ref is a simple image name without username for now
_, imgName, err := splitUserImage(ref)
if err != nil {
return nil, err
}

msg, err := v.client.PullImage(ctx, imgName, all)
if err != nil {
return nil, err
}

rc = io.NopCloser(strings.NewReader(msg))
defer rc.Close()

return rc, err
}

// ImagePush pushes to central image registry.
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ require (
google.golang.org/grpc v1.40.0
google.golang.org/protobuf v1.27.1
)

replace (
github.com/projecteru2/libyavirt => github.com/aceralon/libyavirt v0.0.0-20211214081924-914bb8e63e63
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ github.com/Microsoft/hcsshim v0.8.11 h1:qs8+XI1mFA1H/zhXT9qVG/lcJO18p1yCsICIrCjV
github.com/Microsoft/hcsshim v0.8.11/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
github.com/aceralon/libyavirt v0.0.0-20211213100554-b2a6833f0bca h1:BqZvJm7xfsaN4avybNioNbjivAyTXa51/57Ld+W9xW8=
github.com/aceralon/libyavirt v0.0.0-20211213100554-b2a6833f0bca/go.mod h1:FOc+hWBMLsMrmx5p3/moizKeSomedZPNwB6LhS+kEnE=
github.com/aceralon/libyavirt v0.0.0-20211214081924-914bb8e63e63 h1:P6qlWoAZSszKRb5WElhtSda4r4jXoj3NmD+HSc+s6gg=
github.com/aceralon/libyavirt v0.0.0-20211214081924-914bb8e63e63/go.mod h1:FOc+hWBMLsMrmx5p3/moizKeSomedZPNwB6LhS+kEnE=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down

0 comments on commit adb11d7

Please sign in to comment.