Skip to content

Commit

Permalink
merge vmimage pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
aajkl committed Jul 3, 2024
1 parent 99561d5 commit 9a321ae
Show file tree
Hide file tree
Showing 31 changed files with 1,111 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ yavirt
.idea/
.vscode
/tmp
.secrets
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mock: deps
mockery --dir pkg/sh --output pkg/sh/mocks --name Shell
mockery --dir pkg/store --output pkg/store/mocks --name Store
mockery --dir pkg/utils --output pkg/utils/mocks --name Locker
mockery --dir pkg/vmimage --output mocks --name Manager
mockery --dir internal/virt/agent --output internal/virt/agent/mocks --all
mockery --dir internal/virt/domain --output internal/virt/domain/mocks --name Domain
mockery --dir internal/virt/guest --output internal/virt/guest/mocks --name Bot
Expand Down
4 changes: 2 additions & 2 deletions cmd/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/projecteru2/yavirt/cmd/run"
"github.com/projecteru2/yavirt/configs"
"github.com/projecteru2/yavirt/internal/utils"
vmiFact "github.com/yuyang0/vmimage/factory"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
)

// Command .
Expand Down Expand Up @@ -144,7 +144,7 @@ func add(c *cli.Context, _ run.Runtime) error {
return err
}
fmt.Printf("*** Prepare image\n")
if rc, err := vmiFact.Prepare(filePath, img); err != nil {
if rc, err := vmiFact.Prepare(c.Context, filePath, img); err != nil {
return errors.Wrap(err, "")
} else { //nolint
defer rc.Close()
Expand Down
2 changes: 1 addition & 1 deletion configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/urfave/cli/v2"

coretypes "github.com/projecteru2/core/types"
vmitypes "github.com/yuyang0/vmimage/types"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
)

var (
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/deckarep/golang-set/v2 v2.3.1
github.com/digitalocean/go-libvirt v0.0.0-20221205150000-2939327a8519
github.com/docker/docker v24.0.9+incompatible
github.com/dustin/go-humanize v1.0.1
github.com/emirpasic/gods v1.18.1
github.com/florianl/go-tc v0.4.2
Expand All @@ -38,6 +39,7 @@ require (
github.com/projecteru2/core v0.0.0-20240614132727-08e4fbc219d1
github.com/projecteru2/libyavirt v0.0.0-20231128023216-96fef06a6ca4
github.com/projecteru2/resource-storage v0.0.0-20230206062354-d828802f6b96
github.com/projecteru2/vmihub v0.0.0-20240702045253-4fa15dba054f
github.com/prometheus-community/pro-bing v0.4.0
github.com/prometheus/client_golang v1.16.0
github.com/robfig/cron/v3 v3.0.1
Expand All @@ -52,7 +54,6 @@ require (
github.com/yuyang0/resource-bandwidth v0.0.0-20231102113253-8e47795c92e5
github.com/yuyang0/resource-gpu v0.0.0-20231026065700-1577d804efa8
github.com/yuyang0/resource-rbd v0.0.2-0.20230701090628-cb86da0f60b9
github.com/yuyang0/vmimage v0.0.0-20240628091041-9f45a357a3ae
go.etcd.io/etcd v3.3.27+incompatible
go.etcd.io/etcd/client/v3 v3.5.12
go.etcd.io/etcd/tests/v3 v3.5.12
Expand Down Expand Up @@ -90,7 +91,6 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v24.0.9+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
Expand Down Expand Up @@ -150,7 +150,6 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/projectcalico/go-json v0.0.0-20161128004156-6219dc7339ba // indirect
github.com/projectcalico/go-yaml-wrapper v0.0.0-20191112210931-090425220c54 // indirect
github.com/projecteru2/vmihub v0.0.0-20240702045253-4fa15dba054f // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,6 @@ github.com/yuyang0/resource-gpu v0.0.0-20231026065700-1577d804efa8 h1:U1GBBWRCG0
github.com/yuyang0/resource-gpu v0.0.0-20231026065700-1577d804efa8/go.mod h1:oggnae33QHkm9k2Xd0J4BFjdIV1VhPdpm4VUujYUvo0=
github.com/yuyang0/resource-rbd v0.0.2-0.20230701090628-cb86da0f60b9 h1:2La8T7mqVy98jyAkwxIN9gB+Akx3qbLGmVEtleaxND4=
github.com/yuyang0/resource-rbd v0.0.2-0.20230701090628-cb86da0f60b9/go.mod h1:ANjyr7r+YfKtpWiIsZPzF7+krI55Uf84R9AvbNr5WAg=
github.com/yuyang0/vmimage v0.0.0-20240628091041-9f45a357a3ae h1:qsuhmk0vb2uNRdWsI+23DaOODto0/fG8tmEnqwHmjCA=
github.com/yuyang0/vmimage v0.0.0-20240628091041-9f45a357a3ae/go.mod h1:sx0f5ijzfuwsxQnDlU8CpRbEzAoQu6TxpEKN6gozBAw=
go.etcd.io/etcd v3.3.27+incompatible h1:5hMrpf6REqTHV2LW2OclNpRtxI0k9ZplMemJsMSWju0=
go.etcd.io/etcd v3.3.27+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
go.etcd.io/etcd/api/v3 v3.5.12 h1:W4sw5ZoU2Juc9gBWuLk5U6fHfNVyY1WC5g9uiXZio/c=
Expand Down
4 changes: 2 additions & 2 deletions internal/models/guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"github.com/projecteru2/yavirt/pkg/store"
"github.com/projecteru2/yavirt/pkg/terrors"
"github.com/projecteru2/yavirt/pkg/utils"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
bdtypes "github.com/yuyang0/resource-bandwidth/bandwidth/types"
gputypes "github.com/yuyang0/resource-gpu/gpu/types"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
)

// Guest indicates a virtual machine.
Expand Down
2 changes: 1 addition & 1 deletion internal/rpc/grpc_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/projecteru2/yavirt/internal/service"
intertypes "github.com/projecteru2/yavirt/internal/types"
"github.com/projecteru2/yavirt/internal/utils"
vmiFact "github.com/yuyang0/vmimage/factory"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
)

// GRPCYavirtd .
Expand Down
4 changes: 2 additions & 2 deletions internal/service/boar/boar.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/projecteru2/yavirt/pkg/notify/bison"
"github.com/projecteru2/yavirt/pkg/store"
"github.com/projecteru2/yavirt/pkg/utils"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
)

// Boar .
Expand Down
4 changes: 2 additions & 2 deletions internal/service/boar/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strings"

"github.com/cockroachdb/errors"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
)

func (svc *Boar) PushImage(ctx context.Context, imgName string, force bool) (rc io.ReadCloser, err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/boar/raw_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
intertypes "github.com/projecteru2/yavirt/internal/types"
"github.com/projecteru2/yavirt/internal/vmcache"
volFact "github.com/projecteru2/yavirt/internal/volume/factory"
vmiFact "github.com/yuyang0/vmimage/factory"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
)

type VMParams struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/service/mocks/Service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/projecteru2/libyavirt/types"
intertypes "github.com/projecteru2/yavirt/internal/types"
"github.com/projecteru2/yavirt/internal/utils"
vmitypes "github.com/yuyang0/vmimage/types"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
)

// Service interface
Expand Down
4 changes: 2 additions & 2 deletions internal/virt/guest/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/projecteru2/yavirt/pkg/libvirt"
"github.com/projecteru2/yavirt/pkg/terrors"
"github.com/projecteru2/yavirt/pkg/utils"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
)

// Bot .
Expand Down
4 changes: 2 additions & 2 deletions internal/virt/guest/guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"github.com/projecteru2/yavirt/pkg/libvirt"
"github.com/projecteru2/yavirt/pkg/terrors"
"github.com/projecteru2/yavirt/pkg/utils"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
gputypes "github.com/yuyang0/resource-gpu/gpu/types"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
)

// Guest .
Expand Down
4 changes: 2 additions & 2 deletions internal/virt/guest/guest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"github.com/projecteru2/yavirt/pkg/test/mock"
"github.com/projecteru2/yavirt/pkg/utils"
utilmocks "github.com/projecteru2/yavirt/pkg/utils/mocks"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
gputypes "github.com/yuyang0/resource-gpu/gpu/types"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/virt/guest/mocks/Bot.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/volume/local/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/projecteru2/yavirt/pkg/sh"
"github.com/projecteru2/yavirt/pkg/terrors"
"github.com/projecteru2/yavirt/pkg/utils"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
)

var (
Expand Down Expand Up @@ -301,7 +301,7 @@ func (v *Volume) CaptureImage(imgName string) (uimg *vmitypes.Image, err error)
if err != nil {
return nil, err
}
rc, err := vmiFact.Prepare(orig, uimg)
rc, err := vmiFact.Prepare(context.TODO(), orig, uimg)
if err != nil {
return nil, errors.Wrap(err, "")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/volume/mocks/Volume.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions internal/volume/rbd/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"github.com/projecteru2/yavirt/internal/virt/guestfs"
"github.com/projecteru2/yavirt/internal/virt/guestfs/gfsx"
"github.com/projecteru2/yavirt/internal/volume/base"
vmiFact "github.com/projecteru2/yavirt/pkg/vmimage/factory"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
libguestfs "github.com/projecteru2/yavirt/third_party/guestfs"
rbdtypes "github.com/yuyang0/resource-rbd/rbd/types"
vmiFact "github.com/yuyang0/vmimage/factory"
vmitypes "github.com/yuyang0/vmimage/types"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/projecteru2/yavirt/internal/meta"
"github.com/projecteru2/yavirt/internal/virt/guestfs"
"github.com/projecteru2/yavirt/internal/volume/base"
vmitypes "github.com/yuyang0/vmimage/types"
vmitypes "github.com/projecteru2/yavirt/pkg/vmimage/types"
)

type Volume interface { //nolint:interfacebloat
Expand Down
Loading

0 comments on commit 9a321ae

Please sign in to comment.