mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
build: support more variations on context and dockerfile + iidfile
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
55
vendor/github.com/moby/buildkit/session/upload/upload.go
generated
vendored
Normal file
55
vendor/github.com/moby/buildkit/session/upload/upload.go
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
package upload
|
||||
|
||||
import (
|
||||
"context"
|
||||
io "io"
|
||||
"net/url"
|
||||
|
||||
"github.com/moby/buildkit/session"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
const (
|
||||
keyPath = "urlpath"
|
||||
keyHost = "urlhost"
|
||||
)
|
||||
|
||||
func New(ctx context.Context, c session.Caller, url *url.URL) (*Upload, error) {
|
||||
opts := map[string][]string{
|
||||
keyPath: {url.Path},
|
||||
keyHost: {url.Host},
|
||||
}
|
||||
|
||||
client := NewUploadClient(c.Conn())
|
||||
|
||||
ctx = metadata.NewOutgoingContext(ctx, opts)
|
||||
|
||||
cc, err := client.Pull(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Upload{cc: cc}, nil
|
||||
}
|
||||
|
||||
type Upload struct {
|
||||
cc Upload_PullClient
|
||||
}
|
||||
|
||||
func (u *Upload) WriteTo(w io.Writer) (int, error) {
|
||||
n := 0
|
||||
for {
|
||||
var bm BytesMessage
|
||||
if err := u.cc.RecvMsg(&bm); err != nil {
|
||||
if err == io.EOF {
|
||||
return n, nil
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
nn, err := w.Write(bm.Data)
|
||||
n += nn
|
||||
if err != nil {
|
||||
return n, err
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user