Skip to content

Commit

Permalink
Implement copyTo guest function (#476)
Browse files Browse the repository at this point in the history
* Implement copyto

* Fix typo

* minor change in copyTo

* remove replace

* update go.mod
  • Loading branch information
Aceralon authored Sep 20, 2021
1 parent 6f45ac0 commit 6cff36d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 34 deletions.
2 changes: 1 addition & 1 deletion cluster/calcium/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/pkg/errors"
)

// Send send files to workload
// Send files to workload
func (c *Calcium) Send(ctx context.Context, opts *types.SendOptions) (chan *types.SendMessage, error) {
logger := log.WithField("Calcium", "Send").WithField("opts", opts)
if err := opts.Validate(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion engine/mocks/API.go

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

11 changes: 5 additions & 6 deletions engine/virt/virt.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ func (v *Virt) VirtualizationResourceRemap(ctx context.Context, opts *enginetype
}

// VirtualizationCopyTo copies one.
func (v *Virt) VirtualizationCopyTo(ctx context.Context, ID, target string, content io.Reader, AllowOverwriteDirWithFile, CopyUIDGID bool) (err error) {
log.Warnf(ctx, "VirtualizationCopyTo does not implement")
return
func (v *Virt) VirtualizationCopyTo(ctx context.Context, ID, dest string, content io.Reader, AllowOverwriteDirWithFile, CopyUIDGID bool) error {
return v.client.CopyToGuest(ctx, ID, dest, content, AllowOverwriteDirWithFile, CopyUIDGID)
}

// VirtualizationStart boots a guest.
Expand Down Expand Up @@ -209,7 +208,7 @@ func (v *Virt) VirtualizationInspect(ctx context.Context, ID string) (*enginetyp
return nil, err
}

bytes, err := json.Marshal(coretypes.LabelMeta{Publish: []string{"PORT"}})
content, err := json.Marshal(coretypes.LabelMeta{Publish: []string{"PORT"}})
if err != nil {
return nil, err
}
Expand All @@ -219,7 +218,7 @@ func (v *Virt) VirtualizationInspect(ctx context.Context, ID string) (*enginetyp
Image: guest.ImageName,
Running: guest.Status == "running",
Networks: guest.Networks,
Labels: map[string]string{cluster.LabelMeta: string(bytes), cluster.ERUMark: "1"},
Labels: map[string]string{cluster.LabelMeta: string(content), cluster.ERUMark: "1"},
}, nil
}

Expand Down Expand Up @@ -277,6 +276,6 @@ func (v *Virt) VirtualizationExecute(ctx context.Context, ID string, commands, e

// ResourceValidate validate resource usage
func (v *Virt) ResourceValidate(ctx context.Context, cpu float64, cpumap map[string]int64, memory, storage int64) error {
// TODO list all workloads, calcuate resource
// TODO list all workloads, calculate resource
return nil
}
8 changes: 5 additions & 3 deletions 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-20210514093713-959b2e232319
github.com/projecteru2/libyavirt v0.0.0-20210920022816-abc7aa0cf6ae
github.com/prometheus/client_golang v1.11.0
github.com/sanity-io/litter v1.5.1
github.com/sirupsen/logrus v1.7.0
Expand All @@ -43,10 +43,12 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.5.0
go.etcd.io/etcd/client/v3 v3.5.0
go.etcd.io/etcd/tests/v3 v3.5.0
go.opencensus.io v0.22.1 // indirect
go.uber.org/automaxprocs v1.3.0
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.26.0
google.golang.org/appengine v1.6.3 // indirect
google.golang.org/grpc v1.40.0
google.golang.org/protobuf v1.27.1
)
Loading

0 comments on commit 6cff36d

Please sign in to comment.