Skip to content

Commit 6cff36d

Browse files
authored
Implement copyTo guest function (#476)
* Implement copyto * Fix typo * minor change in copyTo * remove replace * update go.mod
1 parent 6f45ac0 commit 6cff36d

File tree

5 files changed

+20
-34
lines changed

5 files changed

+20
-34
lines changed

cluster/calcium/send.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/pkg/errors"
1515
)
1616

17-
// Send send files to workload
17+
// Send files to workload
1818
func (c *Calcium) Send(ctx context.Context, opts *types.SendOptions) (chan *types.SendMessage, error) {
1919
logger := log.WithField("Calcium", "Send").WithField("opts", opts)
2020
if err := opts.Validate(); err != nil {

engine/mocks/API.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/virt/virt.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ func (v *Virt) VirtualizationResourceRemap(ctx context.Context, opts *enginetype
179179
}
180180

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

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

212-
bytes, err := json.Marshal(coretypes.LabelMeta{Publish: []string{"PORT"}})
211+
content, err := json.Marshal(coretypes.LabelMeta{Publish: []string{"PORT"}})
213212
if err != nil {
214213
return nil, err
215214
}
@@ -219,7 +218,7 @@ func (v *Virt) VirtualizationInspect(ctx context.Context, ID string) (*enginetyp
219218
Image: guest.ImageName,
220219
Running: guest.Status == "running",
221220
Networks: guest.Networks,
222-
Labels: map[string]string{cluster.LabelMeta: string(bytes), cluster.ERUMark: "1"},
221+
Labels: map[string]string{cluster.LabelMeta: string(content), cluster.ERUMark: "1"},
223222
}, nil
224223
}
225224

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

278277
// ResourceValidate validate resource usage
279278
func (v *Virt) ResourceValidate(ctx context.Context, cpu float64, cpumap map[string]int64, memory, storage int64) error {
280-
// TODO list all workloads, calcuate resource
279+
// TODO list all workloads, calculate resource
281280
return nil
282281
}

go.mod

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
github.com/opencontainers/runc v1.0.0-rc95 // indirect
3333
github.com/patrickmn/go-cache v2.1.0+incompatible
3434
github.com/pkg/errors v0.9.1
35-
github.com/projecteru2/libyavirt v0.0.0-20210514093713-959b2e232319
35+
github.com/projecteru2/libyavirt v0.0.0-20210920022816-abc7aa0cf6ae
3636
github.com/prometheus/client_golang v1.11.0
3737
github.com/sanity-io/litter v1.5.1
3838
github.com/sirupsen/logrus v1.7.0
@@ -43,10 +43,12 @@ require (
4343
go.etcd.io/etcd/client/pkg/v3 v3.5.0
4444
go.etcd.io/etcd/client/v3 v3.5.0
4545
go.etcd.io/etcd/tests/v3 v3.5.0
46+
go.opencensus.io v0.22.1 // indirect
4647
go.uber.org/automaxprocs v1.3.0
4748
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
4849
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
4950
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
50-
google.golang.org/grpc v1.38.0
51-
google.golang.org/protobuf v1.26.0
51+
google.golang.org/appengine v1.6.3 // indirect
52+
google.golang.org/grpc v1.40.0
53+
google.golang.org/protobuf v1.27.1
5254
)

0 commit comments

Comments
 (0)