Skip to content

Commit

Permalink
implement imagePull (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aceralon authored Dec 17, 2021
1 parent d949540 commit 3fb54b0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
github.com/opencontainers/runc v1.0.0-rc95 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/projecteru2/libyavirt v0.0.0-20211213024339-7490368380c0
github.com/projecteru2/libyavirt v0.0.0-20211217082140-493b61aa9b0d
github.com/prometheus/client_golang v1.11.0
github.com/sanity-io/litter v1.5.1
github.com/sirupsen/logrus v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/projecteru2/libyavirt v0.0.0-20211213024339-7490368380c0 h1:Fzx/e/V/GoLdiiqBEhH/srG9003oOBBOgqWsRdWkv6Y=
github.com/projecteru2/libyavirt v0.0.0-20211213024339-7490368380c0/go.mod h1:FOc+hWBMLsMrmx5p3/moizKeSomedZPNwB6LhS+kEnE=
github.com/projecteru2/libyavirt v0.0.0-20211217082140-493b61aa9b0d h1:BMFqsvIB3nmK5l53nz8r2ndK8//T0njciu5nr/kj9A4=
github.com/projecteru2/libyavirt v0.0.0-20211217082140-493b61aa9b0d/go.mod h1:FOc+hWBMLsMrmx5p3/moizKeSomedZPNwB6LhS+kEnE=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
Expand Down

0 comments on commit 3fb54b0

Please sign in to comment.