gofmt -w -r '"github.com/docker/docker/client/session" -> "github.com/moby/buildkit/session"'
gofmt -w -r '"github.com/docker/docker/client/session/filesync" -> "github.com/moby/buildkit/session/filesync"'
Signed-off-by: Tibor Vass <tibor@docker.com>
| ... | ... |
@@ -18,13 +18,13 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/builder/dockerfile/parser" |
| 19 | 19 |
"github.com/docker/docker/builder/fscache" |
| 20 | 20 |
"github.com/docker/docker/builder/remotecontext" |
| 21 |
- "github.com/docker/docker/client/session" |
|
| 22 | 21 |
"github.com/docker/docker/pkg/archive" |
| 23 | 22 |
"github.com/docker/docker/pkg/chrootarchive" |
| 24 | 23 |
"github.com/docker/docker/pkg/idtools" |
| 25 | 24 |
"github.com/docker/docker/pkg/streamformatter" |
| 26 | 25 |
"github.com/docker/docker/pkg/stringid" |
| 27 | 26 |
"github.com/docker/docker/pkg/system" |
| 27 |
+ "github.com/moby/buildkit/session" |
|
| 28 | 28 |
"github.com/pkg/errors" |
| 29 | 29 |
"golang.org/x/net/context" |
| 30 | 30 |
"golang.org/x/sync/syncmap" |
| ... | ... |
@@ -5,8 +5,8 @@ import ( |
| 5 | 5 |
|
| 6 | 6 |
"github.com/docker/docker/builder/fscache" |
| 7 | 7 |
"github.com/docker/docker/builder/remotecontext" |
| 8 |
- "github.com/docker/docker/client/session" |
|
| 9 |
- "github.com/docker/docker/client/session/filesync" |
|
| 8 |
+ "github.com/moby/buildkit/session" |
|
| 9 |
+ "github.com/moby/buildkit/session/filesync" |
|
| 10 | 10 |
"github.com/pkg/errors" |
| 11 | 11 |
"golang.org/x/net/context" |
| 12 | 12 |
) |
| ... | ... |
@@ -12,9 +12,9 @@ import ( |
| 12 | 12 |
"github.com/boltdb/bolt" |
| 13 | 13 |
"github.com/docker/docker/builder" |
| 14 | 14 |
"github.com/docker/docker/builder/remotecontext" |
| 15 |
- "github.com/docker/docker/client/session/filesync" |
|
| 16 | 15 |
"github.com/docker/docker/pkg/directory" |
| 17 | 16 |
"github.com/docker/docker/pkg/stringid" |
| 17 |
+ "github.com/moby/buildkit/session/filesync" |
|
| 18 | 18 |
"github.com/pkg/errors" |
| 19 | 19 |
"github.com/tonistiigi/fsutil" |
| 20 | 20 |
"golang.org/x/net/context" |
| 14 | 14 |
deleted file mode 100644 |
| ... | ... |
@@ -1,31 +0,0 @@ |
| 1 |
-package filesync |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "time" |
|
| 5 |
- |
|
| 6 |
- "google.golang.org/grpc" |
|
| 7 |
- |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 |
- "github.com/tonistiigi/fsutil" |
|
| 10 |
-) |
|
| 11 |
- |
|
| 12 |
-func sendDiffCopy(stream grpc.Stream, dir string, includes, excludes []string, progress progressCb) error {
|
|
| 13 |
- return fsutil.Send(stream.Context(), stream, dir, &fsutil.WalkOpt{
|
|
| 14 |
- ExcludePatterns: excludes, |
|
| 15 |
- IncludePaths: includes, // TODO: rename IncludePatterns |
|
| 16 |
- }, progress) |
|
| 17 |
-} |
|
| 18 |
- |
|
| 19 |
-func recvDiffCopy(ds grpc.Stream, dest string, cu CacheUpdater) error {
|
|
| 20 |
- st := time.Now() |
|
| 21 |
- defer func() {
|
|
| 22 |
- logrus.Debugf("diffcopy took: %v", time.Since(st))
|
|
| 23 |
- }() |
|
| 24 |
- var cf fsutil.ChangeFunc |
|
| 25 |
- if cu != nil {
|
|
| 26 |
- cu.MarkSupported(true) |
|
| 27 |
- cf = cu.HandleChange |
|
| 28 |
- } |
|
| 29 |
- |
|
| 30 |
- return fsutil.Receive(ds.Context(), ds, dest, cf) |
|
| 31 |
-} |
| 32 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,183 +0,0 @@ |
| 1 |
-package filesync |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "os" |
|
| 5 |
- "strings" |
|
| 6 |
- |
|
| 7 |
- "github.com/docker/docker/client/session" |
|
| 8 |
- "github.com/pkg/errors" |
|
| 9 |
- "github.com/tonistiigi/fsutil" |
|
| 10 |
- "golang.org/x/net/context" |
|
| 11 |
- "google.golang.org/grpc" |
|
| 12 |
- "google.golang.org/grpc/metadata" |
|
| 13 |
-) |
|
| 14 |
- |
|
| 15 |
-const ( |
|
| 16 |
- keyOverrideExcludes = "override-excludes" |
|
| 17 |
- keyIncludePatterns = "include-patterns" |
|
| 18 |
-) |
|
| 19 |
- |
|
| 20 |
-type fsSyncProvider struct {
|
|
| 21 |
- root string |
|
| 22 |
- excludes []string |
|
| 23 |
- p progressCb |
|
| 24 |
- doneCh chan error |
|
| 25 |
-} |
|
| 26 |
- |
|
| 27 |
-// NewFSSyncProvider creates a new provider for sending files from client |
|
| 28 |
-func NewFSSyncProvider(root string, excludes []string) session.Attachable {
|
|
| 29 |
- p := &fsSyncProvider{
|
|
| 30 |
- root: root, |
|
| 31 |
- excludes: excludes, |
|
| 32 |
- } |
|
| 33 |
- return p |
|
| 34 |
-} |
|
| 35 |
- |
|
| 36 |
-func (sp *fsSyncProvider) Register(server *grpc.Server) {
|
|
| 37 |
- RegisterFileSyncServer(server, sp) |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-func (sp *fsSyncProvider) DiffCopy(stream FileSync_DiffCopyServer) error {
|
|
| 41 |
- return sp.handle("diffcopy", stream)
|
|
| 42 |
-} |
|
| 43 |
-func (sp *fsSyncProvider) TarStream(stream FileSync_TarStreamServer) error {
|
|
| 44 |
- return sp.handle("tarstream", stream)
|
|
| 45 |
-} |
|
| 46 |
- |
|
| 47 |
-func (sp *fsSyncProvider) handle(method string, stream grpc.ServerStream) error {
|
|
| 48 |
- var pr *protocol |
|
| 49 |
- for _, p := range supportedProtocols {
|
|
| 50 |
- if method == p.name && isProtoSupported(p.name) {
|
|
| 51 |
- pr = &p |
|
| 52 |
- break |
|
| 53 |
- } |
|
| 54 |
- } |
|
| 55 |
- if pr == nil {
|
|
| 56 |
- return errors.New("failed to negotiate protocol")
|
|
| 57 |
- } |
|
| 58 |
- |
|
| 59 |
- opts, _ := metadata.FromContext(stream.Context()) // if no metadata continue with empty object |
|
| 60 |
- |
|
| 61 |
- var excludes []string |
|
| 62 |
- if len(opts[keyOverrideExcludes]) == 0 || opts[keyOverrideExcludes][0] != "true" {
|
|
| 63 |
- excludes = sp.excludes |
|
| 64 |
- } |
|
| 65 |
- includes := opts[keyIncludePatterns] |
|
| 66 |
- |
|
| 67 |
- var progress progressCb |
|
| 68 |
- if sp.p != nil {
|
|
| 69 |
- progress = sp.p |
|
| 70 |
- sp.p = nil |
|
| 71 |
- } |
|
| 72 |
- |
|
| 73 |
- var doneCh chan error |
|
| 74 |
- if sp.doneCh != nil {
|
|
| 75 |
- doneCh = sp.doneCh |
|
| 76 |
- sp.doneCh = nil |
|
| 77 |
- } |
|
| 78 |
- err := pr.sendFn(stream, sp.root, includes, excludes, progress) |
|
| 79 |
- if doneCh != nil {
|
|
| 80 |
- if err != nil {
|
|
| 81 |
- doneCh <- err |
|
| 82 |
- } |
|
| 83 |
- close(doneCh) |
|
| 84 |
- } |
|
| 85 |
- return err |
|
| 86 |
-} |
|
| 87 |
- |
|
| 88 |
-func (sp *fsSyncProvider) SetNextProgressCallback(f func(int, bool), doneCh chan error) {
|
|
| 89 |
- sp.p = f |
|
| 90 |
- sp.doneCh = doneCh |
|
| 91 |
-} |
|
| 92 |
- |
|
| 93 |
-type progressCb func(int, bool) |
|
| 94 |
- |
|
| 95 |
-type protocol struct {
|
|
| 96 |
- name string |
|
| 97 |
- sendFn func(stream grpc.Stream, srcDir string, includes, excludes []string, progress progressCb) error |
|
| 98 |
- recvFn func(stream grpc.Stream, destDir string, cu CacheUpdater) error |
|
| 99 |
-} |
|
| 100 |
- |
|
| 101 |
-func isProtoSupported(p string) bool {
|
|
| 102 |
- // TODO: this should be removed after testing if stability is confirmed |
|
| 103 |
- if override := os.Getenv("BUILD_STREAM_PROTOCOL"); override != "" {
|
|
| 104 |
- return strings.EqualFold(p, override) |
|
| 105 |
- } |
|
| 106 |
- return true |
|
| 107 |
-} |
|
| 108 |
- |
|
| 109 |
-var supportedProtocols = []protocol{
|
|
| 110 |
- {
|
|
| 111 |
- name: "diffcopy", |
|
| 112 |
- sendFn: sendDiffCopy, |
|
| 113 |
- recvFn: recvDiffCopy, |
|
| 114 |
- }, |
|
| 115 |
- {
|
|
| 116 |
- name: "tarstream", |
|
| 117 |
- sendFn: sendTarStream, |
|
| 118 |
- recvFn: recvTarStream, |
|
| 119 |
- }, |
|
| 120 |
-} |
|
| 121 |
- |
|
| 122 |
-// FSSendRequestOpt defines options for FSSend request |
|
| 123 |
-type FSSendRequestOpt struct {
|
|
| 124 |
- IncludePatterns []string |
|
| 125 |
- OverrideExcludes bool |
|
| 126 |
- DestDir string |
|
| 127 |
- CacheUpdater CacheUpdater |
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 |
-// CacheUpdater is an object capable of sending notifications for the cache hash changes |
|
| 131 |
-type CacheUpdater interface {
|
|
| 132 |
- MarkSupported(bool) |
|
| 133 |
- HandleChange(fsutil.ChangeKind, string, os.FileInfo, error) error |
|
| 134 |
-} |
|
| 135 |
- |
|
| 136 |
-// FSSync initializes a transfer of files |
|
| 137 |
-func FSSync(ctx context.Context, c session.Caller, opt FSSendRequestOpt) error {
|
|
| 138 |
- var pr *protocol |
|
| 139 |
- for _, p := range supportedProtocols {
|
|
| 140 |
- if isProtoSupported(p.name) && c.Supports(session.MethodURL(_FileSync_serviceDesc.ServiceName, p.name)) {
|
|
| 141 |
- pr = &p |
|
| 142 |
- break |
|
| 143 |
- } |
|
| 144 |
- } |
|
| 145 |
- if pr == nil {
|
|
| 146 |
- return errors.New("no fssync handlers")
|
|
| 147 |
- } |
|
| 148 |
- |
|
| 149 |
- opts := make(map[string][]string) |
|
| 150 |
- if opt.OverrideExcludes {
|
|
| 151 |
- opts[keyOverrideExcludes] = []string{"true"}
|
|
| 152 |
- } |
|
| 153 |
- |
|
| 154 |
- if opt.IncludePatterns != nil {
|
|
| 155 |
- opts[keyIncludePatterns] = opt.IncludePatterns |
|
| 156 |
- } |
|
| 157 |
- |
|
| 158 |
- ctx, cancel := context.WithCancel(ctx) |
|
| 159 |
- defer cancel() |
|
| 160 |
- |
|
| 161 |
- client := NewFileSyncClient(c.Conn()) |
|
| 162 |
- |
|
| 163 |
- var stream grpc.ClientStream |
|
| 164 |
- |
|
| 165 |
- ctx = metadata.NewContext(ctx, opts) |
|
| 166 |
- |
|
| 167 |
- switch pr.name {
|
|
| 168 |
- case "tarstream": |
|
| 169 |
- cc, err := client.TarStream(ctx) |
|
| 170 |
- if err != nil {
|
|
| 171 |
- return err |
|
| 172 |
- } |
|
| 173 |
- stream = cc |
|
| 174 |
- case "diffcopy": |
|
| 175 |
- cc, err := client.DiffCopy(ctx) |
|
| 176 |
- if err != nil {
|
|
| 177 |
- return err |
|
| 178 |
- } |
|
| 179 |
- stream = cc |
|
| 180 |
- } |
|
| 181 |
- |
|
| 182 |
- return pr.recvFn(stream, opt.DestDir, opt.CacheUpdater) |
|
| 183 |
-} |
| 184 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,575 +0,0 @@ |
| 1 |
-// Code generated by protoc-gen-gogo. |
|
| 2 |
-// source: filesync.proto |
|
| 3 |
-// DO NOT EDIT! |
|
| 4 |
- |
|
| 5 |
-/* |
|
| 6 |
-Package filesync is a generated protocol buffer package. |
|
| 7 |
- |
|
| 8 |
-It is generated from these files: |
|
| 9 |
- filesync.proto |
|
| 10 |
- |
|
| 11 |
-It has these top-level messages: |
|
| 12 |
- BytesMessage |
|
| 13 |
-*/ |
|
| 14 |
-package filesync |
|
| 15 |
- |
|
| 16 |
-import proto "github.com/gogo/protobuf/proto" |
|
| 17 |
-import fmt "fmt" |
|
| 18 |
-import math "math" |
|
| 19 |
- |
|
| 20 |
-import bytes "bytes" |
|
| 21 |
- |
|
| 22 |
-import strings "strings" |
|
| 23 |
-import reflect "reflect" |
|
| 24 |
- |
|
| 25 |
-import ( |
|
| 26 |
- context "golang.org/x/net/context" |
|
| 27 |
- grpc "google.golang.org/grpc" |
|
| 28 |
-) |
|
| 29 |
- |
|
| 30 |
-import io "io" |
|
| 31 |
- |
|
| 32 |
-// Reference imports to suppress errors if they are not otherwise used. |
|
| 33 |
-var _ = proto.Marshal |
|
| 34 |
-var _ = fmt.Errorf |
|
| 35 |
-var _ = math.Inf |
|
| 36 |
- |
|
| 37 |
-// This is a compile-time assertion to ensure that this generated file |
|
| 38 |
-// is compatible with the proto package it is being compiled against. |
|
| 39 |
-// A compilation error at this line likely means your copy of the |
|
| 40 |
-// proto package needs to be updated. |
|
| 41 |
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package |
|
| 42 |
- |
|
| 43 |
-// BytesMessage contains a chunk of byte data |
|
| 44 |
-type BytesMessage struct {
|
|
| 45 |
- Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` |
|
| 46 |
-} |
|
| 47 |
- |
|
| 48 |
-func (m *BytesMessage) Reset() { *m = BytesMessage{} }
|
|
| 49 |
-func (*BytesMessage) ProtoMessage() {}
|
|
| 50 |
-func (*BytesMessage) Descriptor() ([]byte, []int) { return fileDescriptorFilesync, []int{0} }
|
|
| 51 |
- |
|
| 52 |
-func (m *BytesMessage) GetData() []byte {
|
|
| 53 |
- if m != nil {
|
|
| 54 |
- return m.Data |
|
| 55 |
- } |
|
| 56 |
- return nil |
|
| 57 |
-} |
|
| 58 |
- |
|
| 59 |
-func init() {
|
|
| 60 |
- proto.RegisterType((*BytesMessage)(nil), "moby.filesync.v1.BytesMessage") |
|
| 61 |
-} |
|
| 62 |
-func (this *BytesMessage) Equal(that interface{}) bool {
|
|
| 63 |
- if that == nil {
|
|
| 64 |
- if this == nil {
|
|
| 65 |
- return true |
|
| 66 |
- } |
|
| 67 |
- return false |
|
| 68 |
- } |
|
| 69 |
- |
|
| 70 |
- that1, ok := that.(*BytesMessage) |
|
| 71 |
- if !ok {
|
|
| 72 |
- that2, ok := that.(BytesMessage) |
|
| 73 |
- if ok {
|
|
| 74 |
- that1 = &that2 |
|
| 75 |
- } else {
|
|
| 76 |
- return false |
|
| 77 |
- } |
|
| 78 |
- } |
|
| 79 |
- if that1 == nil {
|
|
| 80 |
- if this == nil {
|
|
| 81 |
- return true |
|
| 82 |
- } |
|
| 83 |
- return false |
|
| 84 |
- } else if this == nil {
|
|
| 85 |
- return false |
|
| 86 |
- } |
|
| 87 |
- if !bytes.Equal(this.Data, that1.Data) {
|
|
| 88 |
- return false |
|
| 89 |
- } |
|
| 90 |
- return true |
|
| 91 |
-} |
|
| 92 |
-func (this *BytesMessage) GoString() string {
|
|
| 93 |
- if this == nil {
|
|
| 94 |
- return "nil" |
|
| 95 |
- } |
|
| 96 |
- s := make([]string, 0, 5) |
|
| 97 |
- s = append(s, "&filesync.BytesMessage{")
|
|
| 98 |
- s = append(s, "Data: "+fmt.Sprintf("%#v", this.Data)+",\n")
|
|
| 99 |
- s = append(s, "}") |
|
| 100 |
- return strings.Join(s, "") |
|
| 101 |
-} |
|
| 102 |
-func valueToGoStringFilesync(v interface{}, typ string) string {
|
|
| 103 |
- rv := reflect.ValueOf(v) |
|
| 104 |
- if rv.IsNil() {
|
|
| 105 |
- return "nil" |
|
| 106 |
- } |
|
| 107 |
- pv := reflect.Indirect(rv).Interface() |
|
| 108 |
- return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
|
|
| 109 |
-} |
|
| 110 |
- |
|
| 111 |
-// Reference imports to suppress errors if they are not otherwise used. |
|
| 112 |
-var _ context.Context |
|
| 113 |
-var _ grpc.ClientConn |
|
| 114 |
- |
|
| 115 |
-// This is a compile-time assertion to ensure that this generated file |
|
| 116 |
-// is compatible with the grpc package it is being compiled against. |
|
| 117 |
-const _ = grpc.SupportPackageIsVersion4 |
|
| 118 |
- |
|
| 119 |
-// Client API for FileSync service |
|
| 120 |
- |
|
| 121 |
-type FileSyncClient interface {
|
|
| 122 |
- DiffCopy(ctx context.Context, opts ...grpc.CallOption) (FileSync_DiffCopyClient, error) |
|
| 123 |
- TarStream(ctx context.Context, opts ...grpc.CallOption) (FileSync_TarStreamClient, error) |
|
| 124 |
-} |
|
| 125 |
- |
|
| 126 |
-type fileSyncClient struct {
|
|
| 127 |
- cc *grpc.ClientConn |
|
| 128 |
-} |
|
| 129 |
- |
|
| 130 |
-func NewFileSyncClient(cc *grpc.ClientConn) FileSyncClient {
|
|
| 131 |
- return &fileSyncClient{cc}
|
|
| 132 |
-} |
|
| 133 |
- |
|
| 134 |
-func (c *fileSyncClient) DiffCopy(ctx context.Context, opts ...grpc.CallOption) (FileSync_DiffCopyClient, error) {
|
|
| 135 |
- stream, err := grpc.NewClientStream(ctx, &_FileSync_serviceDesc.Streams[0], c.cc, "/moby.filesync.v1.FileSync/DiffCopy", opts...) |
|
| 136 |
- if err != nil {
|
|
| 137 |
- return nil, err |
|
| 138 |
- } |
|
| 139 |
- x := &fileSyncDiffCopyClient{stream}
|
|
| 140 |
- return x, nil |
|
| 141 |
-} |
|
| 142 |
- |
|
| 143 |
-type FileSync_DiffCopyClient interface {
|
|
| 144 |
- Send(*BytesMessage) error |
|
| 145 |
- Recv() (*BytesMessage, error) |
|
| 146 |
- grpc.ClientStream |
|
| 147 |
-} |
|
| 148 |
- |
|
| 149 |
-type fileSyncDiffCopyClient struct {
|
|
| 150 |
- grpc.ClientStream |
|
| 151 |
-} |
|
| 152 |
- |
|
| 153 |
-func (x *fileSyncDiffCopyClient) Send(m *BytesMessage) error {
|
|
| 154 |
- return x.ClientStream.SendMsg(m) |
|
| 155 |
-} |
|
| 156 |
- |
|
| 157 |
-func (x *fileSyncDiffCopyClient) Recv() (*BytesMessage, error) {
|
|
| 158 |
- m := new(BytesMessage) |
|
| 159 |
- if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
| 160 |
- return nil, err |
|
| 161 |
- } |
|
| 162 |
- return m, nil |
|
| 163 |
-} |
|
| 164 |
- |
|
| 165 |
-func (c *fileSyncClient) TarStream(ctx context.Context, opts ...grpc.CallOption) (FileSync_TarStreamClient, error) {
|
|
| 166 |
- stream, err := grpc.NewClientStream(ctx, &_FileSync_serviceDesc.Streams[1], c.cc, "/moby.filesync.v1.FileSync/TarStream", opts...) |
|
| 167 |
- if err != nil {
|
|
| 168 |
- return nil, err |
|
| 169 |
- } |
|
| 170 |
- x := &fileSyncTarStreamClient{stream}
|
|
| 171 |
- return x, nil |
|
| 172 |
-} |
|
| 173 |
- |
|
| 174 |
-type FileSync_TarStreamClient interface {
|
|
| 175 |
- Send(*BytesMessage) error |
|
| 176 |
- Recv() (*BytesMessage, error) |
|
| 177 |
- grpc.ClientStream |
|
| 178 |
-} |
|
| 179 |
- |
|
| 180 |
-type fileSyncTarStreamClient struct {
|
|
| 181 |
- grpc.ClientStream |
|
| 182 |
-} |
|
| 183 |
- |
|
| 184 |
-func (x *fileSyncTarStreamClient) Send(m *BytesMessage) error {
|
|
| 185 |
- return x.ClientStream.SendMsg(m) |
|
| 186 |
-} |
|
| 187 |
- |
|
| 188 |
-func (x *fileSyncTarStreamClient) Recv() (*BytesMessage, error) {
|
|
| 189 |
- m := new(BytesMessage) |
|
| 190 |
- if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
| 191 |
- return nil, err |
|
| 192 |
- } |
|
| 193 |
- return m, nil |
|
| 194 |
-} |
|
| 195 |
- |
|
| 196 |
-// Server API for FileSync service |
|
| 197 |
- |
|
| 198 |
-type FileSyncServer interface {
|
|
| 199 |
- DiffCopy(FileSync_DiffCopyServer) error |
|
| 200 |
- TarStream(FileSync_TarStreamServer) error |
|
| 201 |
-} |
|
| 202 |
- |
|
| 203 |
-func RegisterFileSyncServer(s *grpc.Server, srv FileSyncServer) {
|
|
| 204 |
- s.RegisterService(&_FileSync_serviceDesc, srv) |
|
| 205 |
-} |
|
| 206 |
- |
|
| 207 |
-func _FileSync_DiffCopy_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
| 208 |
- return srv.(FileSyncServer).DiffCopy(&fileSyncDiffCopyServer{stream})
|
|
| 209 |
-} |
|
| 210 |
- |
|
| 211 |
-type FileSync_DiffCopyServer interface {
|
|
| 212 |
- Send(*BytesMessage) error |
|
| 213 |
- Recv() (*BytesMessage, error) |
|
| 214 |
- grpc.ServerStream |
|
| 215 |
-} |
|
| 216 |
- |
|
| 217 |
-type fileSyncDiffCopyServer struct {
|
|
| 218 |
- grpc.ServerStream |
|
| 219 |
-} |
|
| 220 |
- |
|
| 221 |
-func (x *fileSyncDiffCopyServer) Send(m *BytesMessage) error {
|
|
| 222 |
- return x.ServerStream.SendMsg(m) |
|
| 223 |
-} |
|
| 224 |
- |
|
| 225 |
-func (x *fileSyncDiffCopyServer) Recv() (*BytesMessage, error) {
|
|
| 226 |
- m := new(BytesMessage) |
|
| 227 |
- if err := x.ServerStream.RecvMsg(m); err != nil {
|
|
| 228 |
- return nil, err |
|
| 229 |
- } |
|
| 230 |
- return m, nil |
|
| 231 |
-} |
|
| 232 |
- |
|
| 233 |
-func _FileSync_TarStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
| 234 |
- return srv.(FileSyncServer).TarStream(&fileSyncTarStreamServer{stream})
|
|
| 235 |
-} |
|
| 236 |
- |
|
| 237 |
-type FileSync_TarStreamServer interface {
|
|
| 238 |
- Send(*BytesMessage) error |
|
| 239 |
- Recv() (*BytesMessage, error) |
|
| 240 |
- grpc.ServerStream |
|
| 241 |
-} |
|
| 242 |
- |
|
| 243 |
-type fileSyncTarStreamServer struct {
|
|
| 244 |
- grpc.ServerStream |
|
| 245 |
-} |
|
| 246 |
- |
|
| 247 |
-func (x *fileSyncTarStreamServer) Send(m *BytesMessage) error {
|
|
| 248 |
- return x.ServerStream.SendMsg(m) |
|
| 249 |
-} |
|
| 250 |
- |
|
| 251 |
-func (x *fileSyncTarStreamServer) Recv() (*BytesMessage, error) {
|
|
| 252 |
- m := new(BytesMessage) |
|
| 253 |
- if err := x.ServerStream.RecvMsg(m); err != nil {
|
|
| 254 |
- return nil, err |
|
| 255 |
- } |
|
| 256 |
- return m, nil |
|
| 257 |
-} |
|
| 258 |
- |
|
| 259 |
-var _FileSync_serviceDesc = grpc.ServiceDesc{
|
|
| 260 |
- ServiceName: "moby.filesync.v1.FileSync", |
|
| 261 |
- HandlerType: (*FileSyncServer)(nil), |
|
| 262 |
- Methods: []grpc.MethodDesc{},
|
|
| 263 |
- Streams: []grpc.StreamDesc{
|
|
| 264 |
- {
|
|
| 265 |
- StreamName: "DiffCopy", |
|
| 266 |
- Handler: _FileSync_DiffCopy_Handler, |
|
| 267 |
- ServerStreams: true, |
|
| 268 |
- ClientStreams: true, |
|
| 269 |
- }, |
|
| 270 |
- {
|
|
| 271 |
- StreamName: "TarStream", |
|
| 272 |
- Handler: _FileSync_TarStream_Handler, |
|
| 273 |
- ServerStreams: true, |
|
| 274 |
- ClientStreams: true, |
|
| 275 |
- }, |
|
| 276 |
- }, |
|
| 277 |
- Metadata: "filesync.proto", |
|
| 278 |
-} |
|
| 279 |
- |
|
| 280 |
-func (m *BytesMessage) Marshal() (dAtA []byte, err error) {
|
|
| 281 |
- size := m.Size() |
|
| 282 |
- dAtA = make([]byte, size) |
|
| 283 |
- n, err := m.MarshalTo(dAtA) |
|
| 284 |
- if err != nil {
|
|
| 285 |
- return nil, err |
|
| 286 |
- } |
|
| 287 |
- return dAtA[:n], nil |
|
| 288 |
-} |
|
| 289 |
- |
|
| 290 |
-func (m *BytesMessage) MarshalTo(dAtA []byte) (int, error) {
|
|
| 291 |
- var i int |
|
| 292 |
- _ = i |
|
| 293 |
- var l int |
|
| 294 |
- _ = l |
|
| 295 |
- if len(m.Data) > 0 {
|
|
| 296 |
- dAtA[i] = 0xa |
|
| 297 |
- i++ |
|
| 298 |
- i = encodeVarintFilesync(dAtA, i, uint64(len(m.Data))) |
|
| 299 |
- i += copy(dAtA[i:], m.Data) |
|
| 300 |
- } |
|
| 301 |
- return i, nil |
|
| 302 |
-} |
|
| 303 |
- |
|
| 304 |
-func encodeFixed64Filesync(dAtA []byte, offset int, v uint64) int {
|
|
| 305 |
- dAtA[offset] = uint8(v) |
|
| 306 |
- dAtA[offset+1] = uint8(v >> 8) |
|
| 307 |
- dAtA[offset+2] = uint8(v >> 16) |
|
| 308 |
- dAtA[offset+3] = uint8(v >> 24) |
|
| 309 |
- dAtA[offset+4] = uint8(v >> 32) |
|
| 310 |
- dAtA[offset+5] = uint8(v >> 40) |
|
| 311 |
- dAtA[offset+6] = uint8(v >> 48) |
|
| 312 |
- dAtA[offset+7] = uint8(v >> 56) |
|
| 313 |
- return offset + 8 |
|
| 314 |
-} |
|
| 315 |
-func encodeFixed32Filesync(dAtA []byte, offset int, v uint32) int {
|
|
| 316 |
- dAtA[offset] = uint8(v) |
|
| 317 |
- dAtA[offset+1] = uint8(v >> 8) |
|
| 318 |
- dAtA[offset+2] = uint8(v >> 16) |
|
| 319 |
- dAtA[offset+3] = uint8(v >> 24) |
|
| 320 |
- return offset + 4 |
|
| 321 |
-} |
|
| 322 |
-func encodeVarintFilesync(dAtA []byte, offset int, v uint64) int {
|
|
| 323 |
- for v >= 1<<7 {
|
|
| 324 |
- dAtA[offset] = uint8(v&0x7f | 0x80) |
|
| 325 |
- v >>= 7 |
|
| 326 |
- offset++ |
|
| 327 |
- } |
|
| 328 |
- dAtA[offset] = uint8(v) |
|
| 329 |
- return offset + 1 |
|
| 330 |
-} |
|
| 331 |
-func (m *BytesMessage) Size() (n int) {
|
|
| 332 |
- var l int |
|
| 333 |
- _ = l |
|
| 334 |
- l = len(m.Data) |
|
| 335 |
- if l > 0 {
|
|
| 336 |
- n += 1 + l + sovFilesync(uint64(l)) |
|
| 337 |
- } |
|
| 338 |
- return n |
|
| 339 |
-} |
|
| 340 |
- |
|
| 341 |
-func sovFilesync(x uint64) (n int) {
|
|
| 342 |
- for {
|
|
| 343 |
- n++ |
|
| 344 |
- x >>= 7 |
|
| 345 |
- if x == 0 {
|
|
| 346 |
- break |
|
| 347 |
- } |
|
| 348 |
- } |
|
| 349 |
- return n |
|
| 350 |
-} |
|
| 351 |
-func sozFilesync(x uint64) (n int) {
|
|
| 352 |
- return sovFilesync(uint64((x << 1) ^ uint64((int64(x) >> 63)))) |
|
| 353 |
-} |
|
| 354 |
-func (this *BytesMessage) String() string {
|
|
| 355 |
- if this == nil {
|
|
| 356 |
- return "nil" |
|
| 357 |
- } |
|
| 358 |
- s := strings.Join([]string{`&BytesMessage{`,
|
|
| 359 |
- `Data:` + fmt.Sprintf("%v", this.Data) + `,`,
|
|
| 360 |
- `}`, |
|
| 361 |
- }, "") |
|
| 362 |
- return s |
|
| 363 |
-} |
|
| 364 |
-func valueToStringFilesync(v interface{}) string {
|
|
| 365 |
- rv := reflect.ValueOf(v) |
|
| 366 |
- if rv.IsNil() {
|
|
| 367 |
- return "nil" |
|
| 368 |
- } |
|
| 369 |
- pv := reflect.Indirect(rv).Interface() |
|
| 370 |
- return fmt.Sprintf("*%v", pv)
|
|
| 371 |
-} |
|
| 372 |
-func (m *BytesMessage) Unmarshal(dAtA []byte) error {
|
|
| 373 |
- l := len(dAtA) |
|
| 374 |
- iNdEx := 0 |
|
| 375 |
- for iNdEx < l {
|
|
| 376 |
- preIndex := iNdEx |
|
| 377 |
- var wire uint64 |
|
| 378 |
- for shift := uint(0); ; shift += 7 {
|
|
| 379 |
- if shift >= 64 {
|
|
| 380 |
- return ErrIntOverflowFilesync |
|
| 381 |
- } |
|
| 382 |
- if iNdEx >= l {
|
|
| 383 |
- return io.ErrUnexpectedEOF |
|
| 384 |
- } |
|
| 385 |
- b := dAtA[iNdEx] |
|
| 386 |
- iNdEx++ |
|
| 387 |
- wire |= (uint64(b) & 0x7F) << shift |
|
| 388 |
- if b < 0x80 {
|
|
| 389 |
- break |
|
| 390 |
- } |
|
| 391 |
- } |
|
| 392 |
- fieldNum := int32(wire >> 3) |
|
| 393 |
- wireType := int(wire & 0x7) |
|
| 394 |
- if wireType == 4 {
|
|
| 395 |
- return fmt.Errorf("proto: BytesMessage: wiretype end group for non-group")
|
|
| 396 |
- } |
|
| 397 |
- if fieldNum <= 0 {
|
|
| 398 |
- return fmt.Errorf("proto: BytesMessage: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
| 399 |
- } |
|
| 400 |
- switch fieldNum {
|
|
| 401 |
- case 1: |
|
| 402 |
- if wireType != 2 {
|
|
| 403 |
- return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
|
|
| 404 |
- } |
|
| 405 |
- var byteLen int |
|
| 406 |
- for shift := uint(0); ; shift += 7 {
|
|
| 407 |
- if shift >= 64 {
|
|
| 408 |
- return ErrIntOverflowFilesync |
|
| 409 |
- } |
|
| 410 |
- if iNdEx >= l {
|
|
| 411 |
- return io.ErrUnexpectedEOF |
|
| 412 |
- } |
|
| 413 |
- b := dAtA[iNdEx] |
|
| 414 |
- iNdEx++ |
|
| 415 |
- byteLen |= (int(b) & 0x7F) << shift |
|
| 416 |
- if b < 0x80 {
|
|
| 417 |
- break |
|
| 418 |
- } |
|
| 419 |
- } |
|
| 420 |
- if byteLen < 0 {
|
|
| 421 |
- return ErrInvalidLengthFilesync |
|
| 422 |
- } |
|
| 423 |
- postIndex := iNdEx + byteLen |
|
| 424 |
- if postIndex > l {
|
|
| 425 |
- return io.ErrUnexpectedEOF |
|
| 426 |
- } |
|
| 427 |
- m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) |
|
| 428 |
- if m.Data == nil {
|
|
| 429 |
- m.Data = []byte{}
|
|
| 430 |
- } |
|
| 431 |
- iNdEx = postIndex |
|
| 432 |
- default: |
|
| 433 |
- iNdEx = preIndex |
|
| 434 |
- skippy, err := skipFilesync(dAtA[iNdEx:]) |
|
| 435 |
- if err != nil {
|
|
| 436 |
- return err |
|
| 437 |
- } |
|
| 438 |
- if skippy < 0 {
|
|
| 439 |
- return ErrInvalidLengthFilesync |
|
| 440 |
- } |
|
| 441 |
- if (iNdEx + skippy) > l {
|
|
| 442 |
- return io.ErrUnexpectedEOF |
|
| 443 |
- } |
|
| 444 |
- iNdEx += skippy |
|
| 445 |
- } |
|
| 446 |
- } |
|
| 447 |
- |
|
| 448 |
- if iNdEx > l {
|
|
| 449 |
- return io.ErrUnexpectedEOF |
|
| 450 |
- } |
|
| 451 |
- return nil |
|
| 452 |
-} |
|
| 453 |
-func skipFilesync(dAtA []byte) (n int, err error) {
|
|
| 454 |
- l := len(dAtA) |
|
| 455 |
- iNdEx := 0 |
|
| 456 |
- for iNdEx < l {
|
|
| 457 |
- var wire uint64 |
|
| 458 |
- for shift := uint(0); ; shift += 7 {
|
|
| 459 |
- if shift >= 64 {
|
|
| 460 |
- return 0, ErrIntOverflowFilesync |
|
| 461 |
- } |
|
| 462 |
- if iNdEx >= l {
|
|
| 463 |
- return 0, io.ErrUnexpectedEOF |
|
| 464 |
- } |
|
| 465 |
- b := dAtA[iNdEx] |
|
| 466 |
- iNdEx++ |
|
| 467 |
- wire |= (uint64(b) & 0x7F) << shift |
|
| 468 |
- if b < 0x80 {
|
|
| 469 |
- break |
|
| 470 |
- } |
|
| 471 |
- } |
|
| 472 |
- wireType := int(wire & 0x7) |
|
| 473 |
- switch wireType {
|
|
| 474 |
- case 0: |
|
| 475 |
- for shift := uint(0); ; shift += 7 {
|
|
| 476 |
- if shift >= 64 {
|
|
| 477 |
- return 0, ErrIntOverflowFilesync |
|
| 478 |
- } |
|
| 479 |
- if iNdEx >= l {
|
|
| 480 |
- return 0, io.ErrUnexpectedEOF |
|
| 481 |
- } |
|
| 482 |
- iNdEx++ |
|
| 483 |
- if dAtA[iNdEx-1] < 0x80 {
|
|
| 484 |
- break |
|
| 485 |
- } |
|
| 486 |
- } |
|
| 487 |
- return iNdEx, nil |
|
| 488 |
- case 1: |
|
| 489 |
- iNdEx += 8 |
|
| 490 |
- return iNdEx, nil |
|
| 491 |
- case 2: |
|
| 492 |
- var length int |
|
| 493 |
- for shift := uint(0); ; shift += 7 {
|
|
| 494 |
- if shift >= 64 {
|
|
| 495 |
- return 0, ErrIntOverflowFilesync |
|
| 496 |
- } |
|
| 497 |
- if iNdEx >= l {
|
|
| 498 |
- return 0, io.ErrUnexpectedEOF |
|
| 499 |
- } |
|
| 500 |
- b := dAtA[iNdEx] |
|
| 501 |
- iNdEx++ |
|
| 502 |
- length |= (int(b) & 0x7F) << shift |
|
| 503 |
- if b < 0x80 {
|
|
| 504 |
- break |
|
| 505 |
- } |
|
| 506 |
- } |
|
| 507 |
- iNdEx += length |
|
| 508 |
- if length < 0 {
|
|
| 509 |
- return 0, ErrInvalidLengthFilesync |
|
| 510 |
- } |
|
| 511 |
- return iNdEx, nil |
|
| 512 |
- case 3: |
|
| 513 |
- for {
|
|
| 514 |
- var innerWire uint64 |
|
| 515 |
- var start int = iNdEx |
|
| 516 |
- for shift := uint(0); ; shift += 7 {
|
|
| 517 |
- if shift >= 64 {
|
|
| 518 |
- return 0, ErrIntOverflowFilesync |
|
| 519 |
- } |
|
| 520 |
- if iNdEx >= l {
|
|
| 521 |
- return 0, io.ErrUnexpectedEOF |
|
| 522 |
- } |
|
| 523 |
- b := dAtA[iNdEx] |
|
| 524 |
- iNdEx++ |
|
| 525 |
- innerWire |= (uint64(b) & 0x7F) << shift |
|
| 526 |
- if b < 0x80 {
|
|
| 527 |
- break |
|
| 528 |
- } |
|
| 529 |
- } |
|
| 530 |
- innerWireType := int(innerWire & 0x7) |
|
| 531 |
- if innerWireType == 4 {
|
|
| 532 |
- break |
|
| 533 |
- } |
|
| 534 |
- next, err := skipFilesync(dAtA[start:]) |
|
| 535 |
- if err != nil {
|
|
| 536 |
- return 0, err |
|
| 537 |
- } |
|
| 538 |
- iNdEx = start + next |
|
| 539 |
- } |
|
| 540 |
- return iNdEx, nil |
|
| 541 |
- case 4: |
|
| 542 |
- return iNdEx, nil |
|
| 543 |
- case 5: |
|
| 544 |
- iNdEx += 4 |
|
| 545 |
- return iNdEx, nil |
|
| 546 |
- default: |
|
| 547 |
- return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
|
| 548 |
- } |
|
| 549 |
- } |
|
| 550 |
- panic("unreachable")
|
|
| 551 |
-} |
|
| 552 |
- |
|
| 553 |
-var ( |
|
| 554 |
- ErrInvalidLengthFilesync = fmt.Errorf("proto: negative length found during unmarshaling")
|
|
| 555 |
- ErrIntOverflowFilesync = fmt.Errorf("proto: integer overflow")
|
|
| 556 |
-) |
|
| 557 |
- |
|
| 558 |
-func init() { proto.RegisterFile("filesync.proto", fileDescriptorFilesync) }
|
|
| 559 |
- |
|
| 560 |
-var fileDescriptorFilesync = []byte{
|
|
| 561 |
- // 198 bytes of a gzipped FileDescriptorProto |
|
| 562 |
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0xcb, 0xcc, 0x49, |
|
| 563 |
- 0x2d, 0xae, 0xcc, 0x4b, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xc8, 0xcd, 0x4f, 0xaa, |
|
| 564 |
- 0xd4, 0x83, 0x0b, 0x96, 0x19, 0x2a, 0x29, 0x71, 0xf1, 0x38, 0x55, 0x96, 0xa4, 0x16, 0xfb, 0xa6, |
|
| 565 |
- 0x16, 0x17, 0x27, 0xa6, 0xa7, 0x0a, 0x09, 0x71, 0xb1, 0xa4, 0x24, 0x96, 0x24, 0x4a, 0x30, 0x2a, |
|
| 566 |
- 0x30, 0x6a, 0xf0, 0x04, 0x81, 0xd9, 0x46, 0xab, 0x19, 0xb9, 0x38, 0xdc, 0x32, 0x73, 0x52, 0x83, |
|
| 567 |
- 0x2b, 0xf3, 0x92, 0x85, 0xfc, 0xb8, 0x38, 0x5c, 0x32, 0xd3, 0xd2, 0x9c, 0xf3, 0x0b, 0x2a, 0x85, |
|
| 568 |
- 0xe4, 0xf4, 0xd0, 0xcd, 0xd3, 0x43, 0x36, 0x4c, 0x8a, 0x80, 0xbc, 0x06, 0xa3, 0x01, 0xa3, 0x90, |
|
| 569 |
- 0x3f, 0x17, 0x67, 0x48, 0x62, 0x51, 0x70, 0x49, 0x51, 0x6a, 0x62, 0x2e, 0x35, 0x0c, 0x74, 0x32, |
|
| 570 |
- 0xbb, 0xf0, 0x50, 0x8e, 0xe1, 0xc6, 0x43, 0x39, 0x86, 0x0f, 0x0f, 0xe5, 0x18, 0x1b, 0x1e, 0xc9, |
|
| 571 |
- 0x31, 0xae, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, |
|
| 572 |
- 0xc9, 0x31, 0xbe, 0x78, 0x24, 0xc7, 0xf0, 0xe1, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x51, |
|
| 573 |
- 0x1c, 0x30, 0xb3, 0x92, 0xd8, 0xc0, 0x41, 0x64, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x0c, |
|
| 574 |
- 0x8d, 0xc5, 0x34, 0x01, 0x00, 0x00, |
|
| 575 |
-} |
| 576 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,15 +0,0 @@ |
| 1 |
-syntax = "proto3"; |
|
| 2 |
- |
|
| 3 |
-package moby.filesync.v1; |
|
| 4 |
- |
|
| 5 |
-option go_package = "filesync"; |
|
| 6 |
- |
|
| 7 |
-service FileSync{
|
|
| 8 |
- rpc DiffCopy(stream BytesMessage) returns (stream BytesMessage); |
|
| 9 |
- rpc TarStream(stream BytesMessage) returns (stream BytesMessage); |
|
| 10 |
-} |
|
| 11 |
- |
|
| 12 |
-// BytesMessage contains a chunk of byte data |
|
| 13 |
-message BytesMessage{
|
|
| 14 |
- bytes data = 1; |
|
| 15 |
-} |
|
| 16 | 1 |
\ No newline at end of file |
| 17 | 2 |
deleted file mode 100644 |
| ... | ... |
@@ -1,71 +0,0 @@ |
| 1 |
-package filesync |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "context" |
|
| 5 |
- "io/ioutil" |
|
| 6 |
- "path/filepath" |
|
| 7 |
- "testing" |
|
| 8 |
- |
|
| 9 |
- "github.com/docker/docker/client/session" |
|
| 10 |
- "github.com/docker/docker/client/session/testutil" |
|
| 11 |
- "github.com/stretchr/testify/assert" |
|
| 12 |
- "github.com/stretchr/testify/require" |
|
| 13 |
- "golang.org/x/sync/errgroup" |
|
| 14 |
-) |
|
| 15 |
- |
|
| 16 |
-func TestFileSyncIncludePatterns(t *testing.T) {
|
|
| 17 |
- tmpDir, err := ioutil.TempDir("", "fsynctest")
|
|
| 18 |
- require.NoError(t, err) |
|
| 19 |
- |
|
| 20 |
- destDir, err := ioutil.TempDir("", "fsynctest")
|
|
| 21 |
- require.NoError(t, err) |
|
| 22 |
- |
|
| 23 |
- err = ioutil.WriteFile(filepath.Join(tmpDir, "foo"), []byte("content1"), 0600)
|
|
| 24 |
- require.NoError(t, err) |
|
| 25 |
- |
|
| 26 |
- err = ioutil.WriteFile(filepath.Join(tmpDir, "bar"), []byte("content2"), 0600)
|
|
| 27 |
- require.NoError(t, err) |
|
| 28 |
- |
|
| 29 |
- s, err := session.NewSession("foo", "bar")
|
|
| 30 |
- require.NoError(t, err) |
|
| 31 |
- |
|
| 32 |
- m, err := session.NewManager() |
|
| 33 |
- require.NoError(t, err) |
|
| 34 |
- |
|
| 35 |
- fs := NewFSSyncProvider(tmpDir, nil) |
|
| 36 |
- s.Allow(fs) |
|
| 37 |
- |
|
| 38 |
- dialer := session.Dialer(testutil.TestStream(testutil.Handler(m.HandleConn))) |
|
| 39 |
- |
|
| 40 |
- g, ctx := errgroup.WithContext(context.Background()) |
|
| 41 |
- |
|
| 42 |
- g.Go(func() error {
|
|
| 43 |
- return s.Run(ctx, dialer) |
|
| 44 |
- }) |
|
| 45 |
- |
|
| 46 |
- g.Go(func() (reterr error) {
|
|
| 47 |
- c, err := m.Get(ctx, s.UUID()) |
|
| 48 |
- if err != nil {
|
|
| 49 |
- return err |
|
| 50 |
- } |
|
| 51 |
- if err := FSSync(ctx, c, FSSendRequestOpt{
|
|
| 52 |
- DestDir: destDir, |
|
| 53 |
- IncludePatterns: []string{"ba*"},
|
|
| 54 |
- }); err != nil {
|
|
| 55 |
- return err |
|
| 56 |
- } |
|
| 57 |
- |
|
| 58 |
- _, err = ioutil.ReadFile(filepath.Join(destDir, "foo")) |
|
| 59 |
- assert.Error(t, err) |
|
| 60 |
- |
|
| 61 |
- dt, err := ioutil.ReadFile(filepath.Join(destDir, "bar")) |
|
| 62 |
- if err != nil {
|
|
| 63 |
- return err |
|
| 64 |
- } |
|
| 65 |
- assert.Equal(t, "content2", string(dt)) |
|
| 66 |
- return s.Close() |
|
| 67 |
- }) |
|
| 68 |
- |
|
| 69 |
- err = g.Wait() |
|
| 70 |
- require.NoError(t, err) |
|
| 71 |
-} |
| 4 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,83 +0,0 @@ |
| 1 |
-package filesync |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "io" |
|
| 5 |
- |
|
| 6 |
- "github.com/Sirupsen/logrus" |
|
| 7 |
- "github.com/docker/docker/pkg/archive" |
|
| 8 |
- "github.com/docker/docker/pkg/chrootarchive" |
|
| 9 |
- "github.com/pkg/errors" |
|
| 10 |
- "google.golang.org/grpc" |
|
| 11 |
-) |
|
| 12 |
- |
|
| 13 |
-func sendTarStream(stream grpc.Stream, dir string, includes, excludes []string, progress progressCb) error {
|
|
| 14 |
- a, err := archive.TarWithOptions(dir, &archive.TarOptions{
|
|
| 15 |
- ExcludePatterns: excludes, |
|
| 16 |
- }) |
|
| 17 |
- if err != nil {
|
|
| 18 |
- return err |
|
| 19 |
- } |
|
| 20 |
- |
|
| 21 |
- size := 0 |
|
| 22 |
- buf := make([]byte, 1<<15) |
|
| 23 |
- t := new(BytesMessage) |
|
| 24 |
- for {
|
|
| 25 |
- n, err := a.Read(buf) |
|
| 26 |
- if err != nil {
|
|
| 27 |
- if err == io.EOF {
|
|
| 28 |
- break |
|
| 29 |
- } |
|
| 30 |
- return err |
|
| 31 |
- } |
|
| 32 |
- t.Data = buf[:n] |
|
| 33 |
- |
|
| 34 |
- if err := stream.SendMsg(t); err != nil {
|
|
| 35 |
- return err |
|
| 36 |
- } |
|
| 37 |
- size += n |
|
| 38 |
- if progress != nil {
|
|
| 39 |
- progress(size, false) |
|
| 40 |
- } |
|
| 41 |
- } |
|
| 42 |
- if progress != nil {
|
|
| 43 |
- progress(size, true) |
|
| 44 |
- } |
|
| 45 |
- return nil |
|
| 46 |
-} |
|
| 47 |
- |
|
| 48 |
-func recvTarStream(ds grpc.Stream, dest string, cs CacheUpdater) error {
|
|
| 49 |
- |
|
| 50 |
- pr, pw := io.Pipe() |
|
| 51 |
- |
|
| 52 |
- go func() {
|
|
| 53 |
- var ( |
|
| 54 |
- err error |
|
| 55 |
- t = new(BytesMessage) |
|
| 56 |
- ) |
|
| 57 |
- for {
|
|
| 58 |
- if err = ds.RecvMsg(t); err != nil {
|
|
| 59 |
- if err == io.EOF {
|
|
| 60 |
- err = nil |
|
| 61 |
- } |
|
| 62 |
- break |
|
| 63 |
- } |
|
| 64 |
- _, err = pw.Write(t.Data) |
|
| 65 |
- if err != nil {
|
|
| 66 |
- break |
|
| 67 |
- } |
|
| 68 |
- } |
|
| 69 |
- if err = pw.CloseWithError(err); err != nil {
|
|
| 70 |
- logrus.Errorf("failed to close tar transfer pipe")
|
|
| 71 |
- } |
|
| 72 |
- }() |
|
| 73 |
- |
|
| 74 |
- decompressedStream, err := archive.DecompressStream(pr) |
|
| 75 |
- if err != nil {
|
|
| 76 |
- return errors.Wrap(err, "failed to decompress stream") |
|
| 77 |
- } |
|
| 78 |
- |
|
| 79 |
- if err := chrootarchive.Untar(decompressedStream, dest, nil); err != nil {
|
|
| 80 |
- return errors.Wrap(err, "failed to untar context") |
|
| 81 |
- } |
|
| 82 |
- return nil |
|
| 83 |
-} |
| 84 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,62 +0,0 @@ |
| 1 |
-package session |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "net" |
|
| 5 |
- "time" |
|
| 6 |
- |
|
| 7 |
- "github.com/Sirupsen/logrus" |
|
| 8 |
- "github.com/pkg/errors" |
|
| 9 |
- "golang.org/x/net/context" |
|
| 10 |
- "golang.org/x/net/http2" |
|
| 11 |
- "google.golang.org/grpc" |
|
| 12 |
- "google.golang.org/grpc/health/grpc_health_v1" |
|
| 13 |
-) |
|
| 14 |
- |
|
| 15 |
-func serve(ctx context.Context, grpcServer *grpc.Server, conn net.Conn) {
|
|
| 16 |
- go func() {
|
|
| 17 |
- <-ctx.Done() |
|
| 18 |
- conn.Close() |
|
| 19 |
- }() |
|
| 20 |
- logrus.Debugf("serving grpc connection")
|
|
| 21 |
- (&http2.Server{}).ServeConn(conn, &http2.ServeConnOpts{Handler: grpcServer})
|
|
| 22 |
-} |
|
| 23 |
- |
|
| 24 |
-func grpcClientConn(ctx context.Context, conn net.Conn) (context.Context, *grpc.ClientConn, error) {
|
|
| 25 |
- dialOpt := grpc.WithDialer(func(addr string, d time.Duration) (net.Conn, error) {
|
|
| 26 |
- return conn, nil |
|
| 27 |
- }) |
|
| 28 |
- |
|
| 29 |
- cc, err := grpc.DialContext(ctx, "", dialOpt, grpc.WithInsecure()) |
|
| 30 |
- if err != nil {
|
|
| 31 |
- return nil, nil, errors.Wrap(err, "failed to create grpc client") |
|
| 32 |
- } |
|
| 33 |
- |
|
| 34 |
- ctx, cancel := context.WithCancel(ctx) |
|
| 35 |
- go monitorHealth(ctx, cc, cancel) |
|
| 36 |
- |
|
| 37 |
- return ctx, cc, nil |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-func monitorHealth(ctx context.Context, cc *grpc.ClientConn, cancelConn func()) {
|
|
| 41 |
- defer cancelConn() |
|
| 42 |
- defer cc.Close() |
|
| 43 |
- |
|
| 44 |
- ticker := time.NewTicker(500 * time.Millisecond) |
|
| 45 |
- defer ticker.Stop() |
|
| 46 |
- healthClient := grpc_health_v1.NewHealthClient(cc) |
|
| 47 |
- |
|
| 48 |
- for {
|
|
| 49 |
- select {
|
|
| 50 |
- case <-ctx.Done(): |
|
| 51 |
- return |
|
| 52 |
- case <-ticker.C: |
|
| 53 |
- <-ticker.C |
|
| 54 |
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
|
| 55 |
- _, err := healthClient.Check(ctx, &grpc_health_v1.HealthCheckRequest{})
|
|
| 56 |
- cancel() |
|
| 57 |
- if err != nil {
|
|
| 58 |
- return |
|
| 59 |
- } |
|
| 60 |
- } |
|
| 61 |
- } |
|
| 62 |
-} |
| 63 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,202 +0,0 @@ |
| 1 |
-package session |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "net" |
|
| 5 |
- "net/http" |
|
| 6 |
- "strings" |
|
| 7 |
- "sync" |
|
| 8 |
- |
|
| 9 |
- "github.com/pkg/errors" |
|
| 10 |
- "golang.org/x/net/context" |
|
| 11 |
- "google.golang.org/grpc" |
|
| 12 |
-) |
|
| 13 |
- |
|
| 14 |
-// Caller can invoke requests on the session |
|
| 15 |
-type Caller interface {
|
|
| 16 |
- Context() context.Context |
|
| 17 |
- Supports(method string) bool |
|
| 18 |
- Conn() *grpc.ClientConn |
|
| 19 |
- Name() string |
|
| 20 |
- SharedKey() string |
|
| 21 |
-} |
|
| 22 |
- |
|
| 23 |
-type client struct {
|
|
| 24 |
- Session |
|
| 25 |
- cc *grpc.ClientConn |
|
| 26 |
- supported map[string]struct{}
|
|
| 27 |
-} |
|
| 28 |
- |
|
| 29 |
-// Manager is a controller for accessing currently active sessions |
|
| 30 |
-type Manager struct {
|
|
| 31 |
- sessions map[string]*client |
|
| 32 |
- mu sync.Mutex |
|
| 33 |
- updateCondition *sync.Cond |
|
| 34 |
-} |
|
| 35 |
- |
|
| 36 |
-// NewManager returns a new Manager |
|
| 37 |
-func NewManager() (*Manager, error) {
|
|
| 38 |
- sm := &Manager{
|
|
| 39 |
- sessions: make(map[string]*client), |
|
| 40 |
- } |
|
| 41 |
- sm.updateCondition = sync.NewCond(&sm.mu) |
|
| 42 |
- return sm, nil |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 |
-// HandleHTTPRequest handles an incoming HTTP request |
|
| 46 |
-func (sm *Manager) HandleHTTPRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
|
|
| 47 |
- hijacker, ok := w.(http.Hijacker) |
|
| 48 |
- if !ok {
|
|
| 49 |
- return errors.New("handler does not support hijack")
|
|
| 50 |
- } |
|
| 51 |
- |
|
| 52 |
- uuid := r.Header.Get(headerSessionUUID) |
|
| 53 |
- |
|
| 54 |
- proto := r.Header.Get("Upgrade")
|
|
| 55 |
- |
|
| 56 |
- sm.mu.Lock() |
|
| 57 |
- if _, ok := sm.sessions[uuid]; ok {
|
|
| 58 |
- sm.mu.Unlock() |
|
| 59 |
- return errors.Errorf("session %s already exists", uuid)
|
|
| 60 |
- } |
|
| 61 |
- |
|
| 62 |
- if proto == "" {
|
|
| 63 |
- sm.mu.Unlock() |
|
| 64 |
- return errors.New("no upgrade proto in request")
|
|
| 65 |
- } |
|
| 66 |
- |
|
| 67 |
- if proto != "h2c" {
|
|
| 68 |
- sm.mu.Unlock() |
|
| 69 |
- return errors.Errorf("protocol %s not supported", proto)
|
|
| 70 |
- } |
|
| 71 |
- |
|
| 72 |
- conn, _, err := hijacker.Hijack() |
|
| 73 |
- if err != nil {
|
|
| 74 |
- sm.mu.Unlock() |
|
| 75 |
- return errors.Wrap(err, "failed to hijack connection") |
|
| 76 |
- } |
|
| 77 |
- |
|
| 78 |
- resp := &http.Response{
|
|
| 79 |
- StatusCode: http.StatusSwitchingProtocols, |
|
| 80 |
- ProtoMajor: 1, |
|
| 81 |
- ProtoMinor: 1, |
|
| 82 |
- Header: http.Header{},
|
|
| 83 |
- } |
|
| 84 |
- resp.Header.Set("Connection", "Upgrade")
|
|
| 85 |
- resp.Header.Set("Upgrade", proto)
|
|
| 86 |
- |
|
| 87 |
- // set raw mode |
|
| 88 |
- conn.Write([]byte{})
|
|
| 89 |
- resp.Write(conn) |
|
| 90 |
- |
|
| 91 |
- return sm.handleConn(ctx, conn, r.Header) |
|
| 92 |
-} |
|
| 93 |
- |
|
| 94 |
-// HandleConn handles an incoming raw connection |
|
| 95 |
-func (sm *Manager) HandleConn(ctx context.Context, conn net.Conn, opts map[string][]string) error {
|
|
| 96 |
- sm.mu.Lock() |
|
| 97 |
- return sm.handleConn(ctx, conn, opts) |
|
| 98 |
-} |
|
| 99 |
- |
|
| 100 |
-// caller needs to take lock, this function will release it |
|
| 101 |
-func (sm *Manager) handleConn(ctx context.Context, conn net.Conn, opts map[string][]string) error {
|
|
| 102 |
- ctx, cancel := context.WithCancel(ctx) |
|
| 103 |
- defer cancel() |
|
| 104 |
- |
|
| 105 |
- h := http.Header(opts) |
|
| 106 |
- uuid := h.Get(headerSessionUUID) |
|
| 107 |
- name := h.Get(headerSessionName) |
|
| 108 |
- sharedKey := h.Get(headerSessionSharedKey) |
|
| 109 |
- |
|
| 110 |
- ctx, cc, err := grpcClientConn(ctx, conn) |
|
| 111 |
- if err != nil {
|
|
| 112 |
- sm.mu.Unlock() |
|
| 113 |
- return err |
|
| 114 |
- } |
|
| 115 |
- |
|
| 116 |
- c := &client{
|
|
| 117 |
- Session: Session{
|
|
| 118 |
- uuid: uuid, |
|
| 119 |
- name: name, |
|
| 120 |
- sharedKey: sharedKey, |
|
| 121 |
- ctx: ctx, |
|
| 122 |
- cancelCtx: cancel, |
|
| 123 |
- done: make(chan struct{}),
|
|
| 124 |
- }, |
|
| 125 |
- cc: cc, |
|
| 126 |
- supported: make(map[string]struct{}),
|
|
| 127 |
- } |
|
| 128 |
- |
|
| 129 |
- for _, m := range opts[headerSessionMethod] {
|
|
| 130 |
- c.supported[strings.ToLower(m)] = struct{}{}
|
|
| 131 |
- } |
|
| 132 |
- sm.sessions[uuid] = c |
|
| 133 |
- sm.updateCondition.Broadcast() |
|
| 134 |
- sm.mu.Unlock() |
|
| 135 |
- |
|
| 136 |
- defer func() {
|
|
| 137 |
- sm.mu.Lock() |
|
| 138 |
- delete(sm.sessions, uuid) |
|
| 139 |
- sm.mu.Unlock() |
|
| 140 |
- }() |
|
| 141 |
- |
|
| 142 |
- <-c.ctx.Done() |
|
| 143 |
- conn.Close() |
|
| 144 |
- close(c.done) |
|
| 145 |
- |
|
| 146 |
- return nil |
|
| 147 |
-} |
|
| 148 |
- |
|
| 149 |
-// Get returns a session by UUID |
|
| 150 |
-func (sm *Manager) Get(ctx context.Context, uuid string) (Caller, error) {
|
|
| 151 |
- ctx, cancel := context.WithCancel(ctx) |
|
| 152 |
- defer cancel() |
|
| 153 |
- |
|
| 154 |
- go func() {
|
|
| 155 |
- select {
|
|
| 156 |
- case <-ctx.Done(): |
|
| 157 |
- sm.updateCondition.Broadcast() |
|
| 158 |
- } |
|
| 159 |
- }() |
|
| 160 |
- |
|
| 161 |
- var c *client |
|
| 162 |
- |
|
| 163 |
- sm.mu.Lock() |
|
| 164 |
- for {
|
|
| 165 |
- select {
|
|
| 166 |
- case <-ctx.Done(): |
|
| 167 |
- sm.mu.Unlock() |
|
| 168 |
- return nil, errors.Wrapf(ctx.Err(), "no active session for %s", uuid) |
|
| 169 |
- default: |
|
| 170 |
- } |
|
| 171 |
- var ok bool |
|
| 172 |
- c, ok = sm.sessions[uuid] |
|
| 173 |
- if !ok || c.closed() {
|
|
| 174 |
- sm.updateCondition.Wait() |
|
| 175 |
- continue |
|
| 176 |
- } |
|
| 177 |
- sm.mu.Unlock() |
|
| 178 |
- break |
|
| 179 |
- } |
|
| 180 |
- |
|
| 181 |
- return c, nil |
|
| 182 |
-} |
|
| 183 |
- |
|
| 184 |
-func (c *client) Context() context.Context {
|
|
| 185 |
- return c.context() |
|
| 186 |
-} |
|
| 187 |
- |
|
| 188 |
-func (c *client) Name() string {
|
|
| 189 |
- return c.name |
|
| 190 |
-} |
|
| 191 |
- |
|
| 192 |
-func (c *client) SharedKey() string {
|
|
| 193 |
- return c.sharedKey |
|
| 194 |
-} |
|
| 195 |
- |
|
| 196 |
-func (c *client) Supports(url string) bool {
|
|
| 197 |
- _, ok := c.supported[strings.ToLower(url)] |
|
| 198 |
- return ok |
|
| 199 |
-} |
|
| 200 |
-func (c *client) Conn() *grpc.ClientConn {
|
|
| 201 |
- return c.cc |
|
| 202 |
-} |
| 203 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,117 +0,0 @@ |
| 1 |
-package session |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "net" |
|
| 5 |
- |
|
| 6 |
- "github.com/docker/docker/pkg/stringid" |
|
| 7 |
- "github.com/pkg/errors" |
|
| 8 |
- "golang.org/x/net/context" |
|
| 9 |
- "google.golang.org/grpc" |
|
| 10 |
- "google.golang.org/grpc/health" |
|
| 11 |
- "google.golang.org/grpc/health/grpc_health_v1" |
|
| 12 |
-) |
|
| 13 |
- |
|
| 14 |
-const ( |
|
| 15 |
- headerSessionUUID = "X-Docker-Expose-Session-Uuid" |
|
| 16 |
- headerSessionName = "X-Docker-Expose-Session-Name" |
|
| 17 |
- headerSessionSharedKey = "X-Docker-Expose-Session-Sharedkey" |
|
| 18 |
- headerSessionMethod = "X-Docker-Expose-Session-Grpc-Method" |
|
| 19 |
-) |
|
| 20 |
- |
|
| 21 |
-// Dialer returns a connection that can be used by the session |
|
| 22 |
-type Dialer func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) |
|
| 23 |
- |
|
| 24 |
-// Attachable defines a feature that can be expsed on a session |
|
| 25 |
-type Attachable interface {
|
|
| 26 |
- Register(*grpc.Server) |
|
| 27 |
-} |
|
| 28 |
- |
|
| 29 |
-// Session is a long running connection between client and a daemon |
|
| 30 |
-type Session struct {
|
|
| 31 |
- uuid string |
|
| 32 |
- name string |
|
| 33 |
- sharedKey string |
|
| 34 |
- ctx context.Context |
|
| 35 |
- cancelCtx func() |
|
| 36 |
- done chan struct{}
|
|
| 37 |
- grpcServer *grpc.Server |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-// NewSession returns a new long running session |
|
| 41 |
-func NewSession(name, sharedKey string) (*Session, error) {
|
|
| 42 |
- uuid := stringid.GenerateRandomID() |
|
| 43 |
- s := &Session{
|
|
| 44 |
- uuid: uuid, |
|
| 45 |
- name: name, |
|
| 46 |
- sharedKey: sharedKey, |
|
| 47 |
- grpcServer: grpc.NewServer(), |
|
| 48 |
- } |
|
| 49 |
- |
|
| 50 |
- grpc_health_v1.RegisterHealthServer(s.grpcServer, health.NewServer()) |
|
| 51 |
- |
|
| 52 |
- return s, nil |
|
| 53 |
-} |
|
| 54 |
- |
|
| 55 |
-// Allow enable a given service to be reachable through the grpc session |
|
| 56 |
-func (s *Session) Allow(a Attachable) {
|
|
| 57 |
- a.Register(s.grpcServer) |
|
| 58 |
-} |
|
| 59 |
- |
|
| 60 |
-// UUID returns unique identifier for the session |
|
| 61 |
-func (s *Session) UUID() string {
|
|
| 62 |
- return s.uuid |
|
| 63 |
-} |
|
| 64 |
- |
|
| 65 |
-// Run activates the session |
|
| 66 |
-func (s *Session) Run(ctx context.Context, dialer Dialer) error {
|
|
| 67 |
- ctx, cancel := context.WithCancel(ctx) |
|
| 68 |
- s.cancelCtx = cancel |
|
| 69 |
- s.done = make(chan struct{})
|
|
| 70 |
- |
|
| 71 |
- defer cancel() |
|
| 72 |
- defer close(s.done) |
|
| 73 |
- |
|
| 74 |
- meta := make(map[string][]string) |
|
| 75 |
- meta[headerSessionUUID] = []string{s.uuid}
|
|
| 76 |
- meta[headerSessionName] = []string{s.name}
|
|
| 77 |
- meta[headerSessionSharedKey] = []string{s.sharedKey}
|
|
| 78 |
- |
|
| 79 |
- for name, svc := range s.grpcServer.GetServiceInfo() {
|
|
| 80 |
- for _, method := range svc.Methods {
|
|
| 81 |
- meta[headerSessionMethod] = append(meta[headerSessionMethod], MethodURL(name, method.Name)) |
|
| 82 |
- } |
|
| 83 |
- } |
|
| 84 |
- conn, err := dialer(ctx, "h2c", meta) |
|
| 85 |
- if err != nil {
|
|
| 86 |
- return errors.Wrap(err, "failed to dial gRPC") |
|
| 87 |
- } |
|
| 88 |
- serve(ctx, s.grpcServer, conn) |
|
| 89 |
- return nil |
|
| 90 |
-} |
|
| 91 |
- |
|
| 92 |
-// Close closes the session |
|
| 93 |
-func (s *Session) Close() error {
|
|
| 94 |
- if s.cancelCtx != nil && s.done != nil {
|
|
| 95 |
- s.cancelCtx() |
|
| 96 |
- <-s.done |
|
| 97 |
- } |
|
| 98 |
- return nil |
|
| 99 |
-} |
|
| 100 |
- |
|
| 101 |
-func (s *Session) context() context.Context {
|
|
| 102 |
- return s.ctx |
|
| 103 |
-} |
|
| 104 |
- |
|
| 105 |
-func (s *Session) closed() bool {
|
|
| 106 |
- select {
|
|
| 107 |
- case <-s.context().Done(): |
|
| 108 |
- return true |
|
| 109 |
- default: |
|
| 110 |
- return false |
|
| 111 |
- } |
|
| 112 |
-} |
|
| 113 |
- |
|
| 114 |
-// MethodURL returns a gRPC method URL for service and method name |
|
| 115 |
-func MethodURL(s, m string) string {
|
|
| 116 |
- return "/" + s + "/" + m |
|
| 117 |
-} |
| 118 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,70 +0,0 @@ |
| 1 |
-package testutil |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "io" |
|
| 5 |
- "net" |
|
| 6 |
- "time" |
|
| 7 |
- |
|
| 8 |
- "github.com/Sirupsen/logrus" |
|
| 9 |
- "golang.org/x/net/context" |
|
| 10 |
-) |
|
| 11 |
- |
|
| 12 |
-// Handler is function called to handle incoming connection |
|
| 13 |
-type Handler func(ctx context.Context, conn net.Conn, meta map[string][]string) error |
|
| 14 |
- |
|
| 15 |
-// Dialer is a function for dialing an outgoing connection |
|
| 16 |
-type Dialer func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) |
|
| 17 |
- |
|
| 18 |
-// TestStream creates an in memory session dialer for a handler function |
|
| 19 |
-func TestStream(handler Handler) Dialer {
|
|
| 20 |
- s1, s2 := sockPair() |
|
| 21 |
- return func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) {
|
|
| 22 |
- go func() {
|
|
| 23 |
- err := handler(context.TODO(), s1, meta) |
|
| 24 |
- if err != nil {
|
|
| 25 |
- logrus.Error(err) |
|
| 26 |
- } |
|
| 27 |
- s1.Close() |
|
| 28 |
- }() |
|
| 29 |
- return s2, nil |
|
| 30 |
- } |
|
| 31 |
-} |
|
| 32 |
- |
|
| 33 |
-func sockPair() (*sock, *sock) {
|
|
| 34 |
- pr1, pw1 := io.Pipe() |
|
| 35 |
- pr2, pw2 := io.Pipe() |
|
| 36 |
- return &sock{pw1, pr2, pw1}, &sock{pw2, pr1, pw2}
|
|
| 37 |
-} |
|
| 38 |
- |
|
| 39 |
-type sock struct {
|
|
| 40 |
- io.Writer |
|
| 41 |
- io.Reader |
|
| 42 |
- io.Closer |
|
| 43 |
-} |
|
| 44 |
- |
|
| 45 |
-func (s *sock) LocalAddr() net.Addr {
|
|
| 46 |
- return dummyAddr{}
|
|
| 47 |
-} |
|
| 48 |
-func (s *sock) RemoteAddr() net.Addr {
|
|
| 49 |
- return dummyAddr{}
|
|
| 50 |
-} |
|
| 51 |
-func (s *sock) SetDeadline(t time.Time) error {
|
|
| 52 |
- return nil |
|
| 53 |
-} |
|
| 54 |
-func (s *sock) SetReadDeadline(t time.Time) error {
|
|
| 55 |
- return nil |
|
| 56 |
-} |
|
| 57 |
-func (s *sock) SetWriteDeadline(t time.Time) error {
|
|
| 58 |
- return nil |
|
| 59 |
-} |
|
| 60 |
- |
|
| 61 |
-type dummyAddr struct {
|
|
| 62 |
-} |
|
| 63 |
- |
|
| 64 |
-func (d dummyAddr) Network() string {
|
|
| 65 |
- return "tcp" |
|
| 66 |
-} |
|
| 67 |
- |
|
| 68 |
-func (d dummyAddr) String() string {
|
|
| 69 |
- return "localhost" |
|
| 70 |
-} |
| ... | ... |
@@ -30,7 +30,6 @@ import ( |
| 30 | 30 |
"github.com/docker/docker/builder/dockerfile" |
| 31 | 31 |
"github.com/docker/docker/builder/fscache" |
| 32 | 32 |
"github.com/docker/docker/cli/debug" |
| 33 |
- "github.com/docker/docker/client/session" |
|
| 34 | 33 |
"github.com/docker/docker/daemon" |
| 35 | 34 |
"github.com/docker/docker/daemon/cluster" |
| 36 | 35 |
"github.com/docker/docker/daemon/config" |
| ... | ... |
@@ -50,6 +49,7 @@ import ( |
| 50 | 50 |
"github.com/docker/docker/runconfig" |
| 51 | 51 |
"github.com/docker/go-connections/tlsconfig" |
| 52 | 52 |
swarmapi "github.com/docker/swarmkit/api" |
| 53 |
+ "github.com/moby/buildkit/session" |
|
| 53 | 54 |
"github.com/pkg/errors" |
| 54 | 55 |
"github.com/spf13/pflag" |
| 55 | 56 |
) |
| ... | ... |
@@ -12,8 +12,6 @@ import ( |
| 12 | 12 |
"strings" |
| 13 | 13 |
|
| 14 | 14 |
"github.com/docker/docker/api/types" |
| 15 |
- "github.com/docker/docker/client/session" |
|
| 16 |
- "github.com/docker/docker/client/session/filesync" |
|
| 17 | 15 |
"github.com/docker/docker/integration-cli/checker" |
| 18 | 16 |
"github.com/docker/docker/integration-cli/cli/build/fakecontext" |
| 19 | 17 |
"github.com/docker/docker/integration-cli/cli/build/fakegit" |
| ... | ... |
@@ -21,6 +19,8 @@ import ( |
| 21 | 21 |
"github.com/docker/docker/integration-cli/request" |
| 22 | 22 |
"github.com/docker/docker/pkg/testutil" |
| 23 | 23 |
"github.com/go-check/check" |
| 24 |
+ "github.com/moby/buildkit/session" |
|
| 25 |
+ "github.com/moby/buildkit/session/filesync" |
|
| 24 | 26 |
"github.com/stretchr/testify/assert" |
| 25 | 27 |
"github.com/stretchr/testify/require" |
| 26 | 28 |
"golang.org/x/net/context" |