resource.pb.go 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. // Code generated by protoc-gen-gogo.
  2. // source: github.com/docker/swarmkit/api/resource.proto
  3. // DO NOT EDIT!
  4. package api
  5. import proto "github.com/gogo/protobuf/proto"
  6. import fmt "fmt"
  7. import math "math"
  8. import _ "github.com/gogo/protobuf/gogoproto"
  9. import _ "github.com/docker/swarmkit/protobuf/plugin"
  10. import github_com_docker_swarmkit_api_deepcopy "github.com/docker/swarmkit/api/deepcopy"
  11. import (
  12. context "golang.org/x/net/context"
  13. grpc "google.golang.org/grpc"
  14. )
  15. import raftselector "github.com/docker/swarmkit/manager/raftselector"
  16. import codes "google.golang.org/grpc/codes"
  17. import status "google.golang.org/grpc/status"
  18. import metadata "google.golang.org/grpc/metadata"
  19. import transport "google.golang.org/grpc/transport"
  20. import rafttime "time"
  21. import strings "strings"
  22. import reflect "reflect"
  23. import io "io"
  24. // Reference imports to suppress errors if they are not otherwise used.
  25. var _ = proto.Marshal
  26. var _ = fmt.Errorf
  27. var _ = math.Inf
  28. type AttachNetworkRequest struct {
  29. Config *NetworkAttachmentConfig `protobuf:"bytes,1,opt,name=config" json:"config,omitempty"`
  30. ContainerID string `protobuf:"bytes,2,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
  31. }
  32. func (m *AttachNetworkRequest) Reset() { *m = AttachNetworkRequest{} }
  33. func (*AttachNetworkRequest) ProtoMessage() {}
  34. func (*AttachNetworkRequest) Descriptor() ([]byte, []int) { return fileDescriptorResource, []int{0} }
  35. type AttachNetworkResponse struct {
  36. AttachmentID string `protobuf:"bytes,1,opt,name=attachment_id,json=attachmentId,proto3" json:"attachment_id,omitempty"`
  37. }
  38. func (m *AttachNetworkResponse) Reset() { *m = AttachNetworkResponse{} }
  39. func (*AttachNetworkResponse) ProtoMessage() {}
  40. func (*AttachNetworkResponse) Descriptor() ([]byte, []int) { return fileDescriptorResource, []int{1} }
  41. type DetachNetworkRequest struct {
  42. AttachmentID string `protobuf:"bytes,1,opt,name=attachment_id,json=attachmentId,proto3" json:"attachment_id,omitempty"`
  43. }
  44. func (m *DetachNetworkRequest) Reset() { *m = DetachNetworkRequest{} }
  45. func (*DetachNetworkRequest) ProtoMessage() {}
  46. func (*DetachNetworkRequest) Descriptor() ([]byte, []int) { return fileDescriptorResource, []int{2} }
  47. type DetachNetworkResponse struct {
  48. }
  49. func (m *DetachNetworkResponse) Reset() { *m = DetachNetworkResponse{} }
  50. func (*DetachNetworkResponse) ProtoMessage() {}
  51. func (*DetachNetworkResponse) Descriptor() ([]byte, []int) { return fileDescriptorResource, []int{3} }
  52. func init() {
  53. proto.RegisterType((*AttachNetworkRequest)(nil), "docker.swarmkit.v1.AttachNetworkRequest")
  54. proto.RegisterType((*AttachNetworkResponse)(nil), "docker.swarmkit.v1.AttachNetworkResponse")
  55. proto.RegisterType((*DetachNetworkRequest)(nil), "docker.swarmkit.v1.DetachNetworkRequest")
  56. proto.RegisterType((*DetachNetworkResponse)(nil), "docker.swarmkit.v1.DetachNetworkResponse")
  57. }
  58. type authenticatedWrapperResourceAllocatorServer struct {
  59. local ResourceAllocatorServer
  60. authorize func(context.Context, []string) error
  61. }
  62. func NewAuthenticatedWrapperResourceAllocatorServer(local ResourceAllocatorServer, authorize func(context.Context, []string) error) ResourceAllocatorServer {
  63. return &authenticatedWrapperResourceAllocatorServer{
  64. local: local,
  65. authorize: authorize,
  66. }
  67. }
  68. func (p *authenticatedWrapperResourceAllocatorServer) AttachNetwork(ctx context.Context, r *AttachNetworkRequest) (*AttachNetworkResponse, error) {
  69. if err := p.authorize(ctx, []string{"swarm-worker", "swarm-manager"}); err != nil {
  70. return nil, err
  71. }
  72. return p.local.AttachNetwork(ctx, r)
  73. }
  74. func (p *authenticatedWrapperResourceAllocatorServer) DetachNetwork(ctx context.Context, r *DetachNetworkRequest) (*DetachNetworkResponse, error) {
  75. if err := p.authorize(ctx, []string{"swarm-worker", "swarm-manager"}); err != nil {
  76. return nil, err
  77. }
  78. return p.local.DetachNetwork(ctx, r)
  79. }
  80. func (m *AttachNetworkRequest) Copy() *AttachNetworkRequest {
  81. if m == nil {
  82. return nil
  83. }
  84. o := &AttachNetworkRequest{}
  85. o.CopyFrom(m)
  86. return o
  87. }
  88. func (m *AttachNetworkRequest) CopyFrom(src interface{}) {
  89. o := src.(*AttachNetworkRequest)
  90. *m = *o
  91. if o.Config != nil {
  92. m.Config = &NetworkAttachmentConfig{}
  93. github_com_docker_swarmkit_api_deepcopy.Copy(m.Config, o.Config)
  94. }
  95. }
  96. func (m *AttachNetworkResponse) Copy() *AttachNetworkResponse {
  97. if m == nil {
  98. return nil
  99. }
  100. o := &AttachNetworkResponse{}
  101. o.CopyFrom(m)
  102. return o
  103. }
  104. func (m *AttachNetworkResponse) CopyFrom(src interface{}) {
  105. o := src.(*AttachNetworkResponse)
  106. *m = *o
  107. }
  108. func (m *DetachNetworkRequest) Copy() *DetachNetworkRequest {
  109. if m == nil {
  110. return nil
  111. }
  112. o := &DetachNetworkRequest{}
  113. o.CopyFrom(m)
  114. return o
  115. }
  116. func (m *DetachNetworkRequest) CopyFrom(src interface{}) {
  117. o := src.(*DetachNetworkRequest)
  118. *m = *o
  119. }
  120. func (m *DetachNetworkResponse) Copy() *DetachNetworkResponse {
  121. if m == nil {
  122. return nil
  123. }
  124. o := &DetachNetworkResponse{}
  125. o.CopyFrom(m)
  126. return o
  127. }
  128. func (m *DetachNetworkResponse) CopyFrom(src interface{}) {}
  129. // Reference imports to suppress errors if they are not otherwise used.
  130. var _ context.Context
  131. var _ grpc.ClientConn
  132. // This is a compile-time assertion to ensure that this generated file
  133. // is compatible with the grpc package it is being compiled against.
  134. const _ = grpc.SupportPackageIsVersion4
  135. // Client API for ResourceAllocator service
  136. type ResourceAllocatorClient interface {
  137. AttachNetwork(ctx context.Context, in *AttachNetworkRequest, opts ...grpc.CallOption) (*AttachNetworkResponse, error)
  138. DetachNetwork(ctx context.Context, in *DetachNetworkRequest, opts ...grpc.CallOption) (*DetachNetworkResponse, error)
  139. }
  140. type resourceAllocatorClient struct {
  141. cc *grpc.ClientConn
  142. }
  143. func NewResourceAllocatorClient(cc *grpc.ClientConn) ResourceAllocatorClient {
  144. return &resourceAllocatorClient{cc}
  145. }
  146. func (c *resourceAllocatorClient) AttachNetwork(ctx context.Context, in *AttachNetworkRequest, opts ...grpc.CallOption) (*AttachNetworkResponse, error) {
  147. out := new(AttachNetworkResponse)
  148. err := grpc.Invoke(ctx, "/docker.swarmkit.v1.ResourceAllocator/AttachNetwork", in, out, c.cc, opts...)
  149. if err != nil {
  150. return nil, err
  151. }
  152. return out, nil
  153. }
  154. func (c *resourceAllocatorClient) DetachNetwork(ctx context.Context, in *DetachNetworkRequest, opts ...grpc.CallOption) (*DetachNetworkResponse, error) {
  155. out := new(DetachNetworkResponse)
  156. err := grpc.Invoke(ctx, "/docker.swarmkit.v1.ResourceAllocator/DetachNetwork", in, out, c.cc, opts...)
  157. if err != nil {
  158. return nil, err
  159. }
  160. return out, nil
  161. }
  162. // Server API for ResourceAllocator service
  163. type ResourceAllocatorServer interface {
  164. AttachNetwork(context.Context, *AttachNetworkRequest) (*AttachNetworkResponse, error)
  165. DetachNetwork(context.Context, *DetachNetworkRequest) (*DetachNetworkResponse, error)
  166. }
  167. func RegisterResourceAllocatorServer(s *grpc.Server, srv ResourceAllocatorServer) {
  168. s.RegisterService(&_ResourceAllocator_serviceDesc, srv)
  169. }
  170. func _ResourceAllocator_AttachNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
  171. in := new(AttachNetworkRequest)
  172. if err := dec(in); err != nil {
  173. return nil, err
  174. }
  175. if interceptor == nil {
  176. return srv.(ResourceAllocatorServer).AttachNetwork(ctx, in)
  177. }
  178. info := &grpc.UnaryServerInfo{
  179. Server: srv,
  180. FullMethod: "/docker.swarmkit.v1.ResourceAllocator/AttachNetwork",
  181. }
  182. handler := func(ctx context.Context, req interface{}) (interface{}, error) {
  183. return srv.(ResourceAllocatorServer).AttachNetwork(ctx, req.(*AttachNetworkRequest))
  184. }
  185. return interceptor(ctx, in, info, handler)
  186. }
  187. func _ResourceAllocator_DetachNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
  188. in := new(DetachNetworkRequest)
  189. if err := dec(in); err != nil {
  190. return nil, err
  191. }
  192. if interceptor == nil {
  193. return srv.(ResourceAllocatorServer).DetachNetwork(ctx, in)
  194. }
  195. info := &grpc.UnaryServerInfo{
  196. Server: srv,
  197. FullMethod: "/docker.swarmkit.v1.ResourceAllocator/DetachNetwork",
  198. }
  199. handler := func(ctx context.Context, req interface{}) (interface{}, error) {
  200. return srv.(ResourceAllocatorServer).DetachNetwork(ctx, req.(*DetachNetworkRequest))
  201. }
  202. return interceptor(ctx, in, info, handler)
  203. }
  204. var _ResourceAllocator_serviceDesc = grpc.ServiceDesc{
  205. ServiceName: "docker.swarmkit.v1.ResourceAllocator",
  206. HandlerType: (*ResourceAllocatorServer)(nil),
  207. Methods: []grpc.MethodDesc{
  208. {
  209. MethodName: "AttachNetwork",
  210. Handler: _ResourceAllocator_AttachNetwork_Handler,
  211. },
  212. {
  213. MethodName: "DetachNetwork",
  214. Handler: _ResourceAllocator_DetachNetwork_Handler,
  215. },
  216. },
  217. Streams: []grpc.StreamDesc{},
  218. Metadata: "github.com/docker/swarmkit/api/resource.proto",
  219. }
  220. func (m *AttachNetworkRequest) Marshal() (dAtA []byte, err error) {
  221. size := m.Size()
  222. dAtA = make([]byte, size)
  223. n, err := m.MarshalTo(dAtA)
  224. if err != nil {
  225. return nil, err
  226. }
  227. return dAtA[:n], nil
  228. }
  229. func (m *AttachNetworkRequest) MarshalTo(dAtA []byte) (int, error) {
  230. var i int
  231. _ = i
  232. var l int
  233. _ = l
  234. if m.Config != nil {
  235. dAtA[i] = 0xa
  236. i++
  237. i = encodeVarintResource(dAtA, i, uint64(m.Config.Size()))
  238. n1, err := m.Config.MarshalTo(dAtA[i:])
  239. if err != nil {
  240. return 0, err
  241. }
  242. i += n1
  243. }
  244. if len(m.ContainerID) > 0 {
  245. dAtA[i] = 0x12
  246. i++
  247. i = encodeVarintResource(dAtA, i, uint64(len(m.ContainerID)))
  248. i += copy(dAtA[i:], m.ContainerID)
  249. }
  250. return i, nil
  251. }
  252. func (m *AttachNetworkResponse) Marshal() (dAtA []byte, err error) {
  253. size := m.Size()
  254. dAtA = make([]byte, size)
  255. n, err := m.MarshalTo(dAtA)
  256. if err != nil {
  257. return nil, err
  258. }
  259. return dAtA[:n], nil
  260. }
  261. func (m *AttachNetworkResponse) MarshalTo(dAtA []byte) (int, error) {
  262. var i int
  263. _ = i
  264. var l int
  265. _ = l
  266. if len(m.AttachmentID) > 0 {
  267. dAtA[i] = 0xa
  268. i++
  269. i = encodeVarintResource(dAtA, i, uint64(len(m.AttachmentID)))
  270. i += copy(dAtA[i:], m.AttachmentID)
  271. }
  272. return i, nil
  273. }
  274. func (m *DetachNetworkRequest) Marshal() (dAtA []byte, err error) {
  275. size := m.Size()
  276. dAtA = make([]byte, size)
  277. n, err := m.MarshalTo(dAtA)
  278. if err != nil {
  279. return nil, err
  280. }
  281. return dAtA[:n], nil
  282. }
  283. func (m *DetachNetworkRequest) MarshalTo(dAtA []byte) (int, error) {
  284. var i int
  285. _ = i
  286. var l int
  287. _ = l
  288. if len(m.AttachmentID) > 0 {
  289. dAtA[i] = 0xa
  290. i++
  291. i = encodeVarintResource(dAtA, i, uint64(len(m.AttachmentID)))
  292. i += copy(dAtA[i:], m.AttachmentID)
  293. }
  294. return i, nil
  295. }
  296. func (m *DetachNetworkResponse) Marshal() (dAtA []byte, err error) {
  297. size := m.Size()
  298. dAtA = make([]byte, size)
  299. n, err := m.MarshalTo(dAtA)
  300. if err != nil {
  301. return nil, err
  302. }
  303. return dAtA[:n], nil
  304. }
  305. func (m *DetachNetworkResponse) MarshalTo(dAtA []byte) (int, error) {
  306. var i int
  307. _ = i
  308. var l int
  309. _ = l
  310. return i, nil
  311. }
  312. func encodeFixed64Resource(dAtA []byte, offset int, v uint64) int {
  313. dAtA[offset] = uint8(v)
  314. dAtA[offset+1] = uint8(v >> 8)
  315. dAtA[offset+2] = uint8(v >> 16)
  316. dAtA[offset+3] = uint8(v >> 24)
  317. dAtA[offset+4] = uint8(v >> 32)
  318. dAtA[offset+5] = uint8(v >> 40)
  319. dAtA[offset+6] = uint8(v >> 48)
  320. dAtA[offset+7] = uint8(v >> 56)
  321. return offset + 8
  322. }
  323. func encodeFixed32Resource(dAtA []byte, offset int, v uint32) int {
  324. dAtA[offset] = uint8(v)
  325. dAtA[offset+1] = uint8(v >> 8)
  326. dAtA[offset+2] = uint8(v >> 16)
  327. dAtA[offset+3] = uint8(v >> 24)
  328. return offset + 4
  329. }
  330. func encodeVarintResource(dAtA []byte, offset int, v uint64) int {
  331. for v >= 1<<7 {
  332. dAtA[offset] = uint8(v&0x7f | 0x80)
  333. v >>= 7
  334. offset++
  335. }
  336. dAtA[offset] = uint8(v)
  337. return offset + 1
  338. }
  339. type raftProxyResourceAllocatorServer struct {
  340. local ResourceAllocatorServer
  341. connSelector raftselector.ConnProvider
  342. localCtxMods, remoteCtxMods []func(context.Context) (context.Context, error)
  343. }
  344. func NewRaftProxyResourceAllocatorServer(local ResourceAllocatorServer, connSelector raftselector.ConnProvider, localCtxMod, remoteCtxMod func(context.Context) (context.Context, error)) ResourceAllocatorServer {
  345. redirectChecker := func(ctx context.Context) (context.Context, error) {
  346. s, ok := transport.StreamFromContext(ctx)
  347. if !ok {
  348. return ctx, status.Errorf(codes.InvalidArgument, "remote addr is not found in context")
  349. }
  350. addr := s.ServerTransport().RemoteAddr().String()
  351. md, ok := metadata.FromContext(ctx)
  352. if ok && len(md["redirect"]) != 0 {
  353. return ctx, status.Errorf(codes.ResourceExhausted, "more than one redirect to leader from: %s", md["redirect"])
  354. }
  355. if !ok {
  356. md = metadata.New(map[string]string{})
  357. }
  358. md["redirect"] = append(md["redirect"], addr)
  359. return metadata.NewContext(ctx, md), nil
  360. }
  361. remoteMods := []func(context.Context) (context.Context, error){redirectChecker}
  362. remoteMods = append(remoteMods, remoteCtxMod)
  363. var localMods []func(context.Context) (context.Context, error)
  364. if localCtxMod != nil {
  365. localMods = []func(context.Context) (context.Context, error){localCtxMod}
  366. }
  367. return &raftProxyResourceAllocatorServer{
  368. local: local,
  369. connSelector: connSelector,
  370. localCtxMods: localMods,
  371. remoteCtxMods: remoteMods,
  372. }
  373. }
  374. func (p *raftProxyResourceAllocatorServer) runCtxMods(ctx context.Context, ctxMods []func(context.Context) (context.Context, error)) (context.Context, error) {
  375. var err error
  376. for _, mod := range ctxMods {
  377. ctx, err = mod(ctx)
  378. if err != nil {
  379. return ctx, err
  380. }
  381. }
  382. return ctx, nil
  383. }
  384. func (p *raftProxyResourceAllocatorServer) pollNewLeaderConn(ctx context.Context) (*grpc.ClientConn, error) {
  385. ticker := rafttime.NewTicker(500 * rafttime.Millisecond)
  386. defer ticker.Stop()
  387. for {
  388. select {
  389. case <-ticker.C:
  390. conn, err := p.connSelector.LeaderConn(ctx)
  391. if err != nil {
  392. return nil, err
  393. }
  394. client := NewHealthClient(conn)
  395. resp, err := client.Check(ctx, &HealthCheckRequest{Service: "Raft"})
  396. if err != nil || resp.Status != HealthCheckResponse_SERVING {
  397. continue
  398. }
  399. return conn, nil
  400. case <-ctx.Done():
  401. return nil, ctx.Err()
  402. }
  403. }
  404. }
  405. func (p *raftProxyResourceAllocatorServer) AttachNetwork(ctx context.Context, r *AttachNetworkRequest) (*AttachNetworkResponse, error) {
  406. conn, err := p.connSelector.LeaderConn(ctx)
  407. if err != nil {
  408. if err == raftselector.ErrIsLeader {
  409. ctx, err = p.runCtxMods(ctx, p.localCtxMods)
  410. if err != nil {
  411. return nil, err
  412. }
  413. return p.local.AttachNetwork(ctx, r)
  414. }
  415. return nil, err
  416. }
  417. modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
  418. if err != nil {
  419. return nil, err
  420. }
  421. resp, err := NewResourceAllocatorClient(conn).AttachNetwork(modCtx, r)
  422. if err != nil {
  423. if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
  424. return resp, err
  425. }
  426. conn, err := p.pollNewLeaderConn(ctx)
  427. if err != nil {
  428. if err == raftselector.ErrIsLeader {
  429. return p.local.AttachNetwork(ctx, r)
  430. }
  431. return nil, err
  432. }
  433. return NewResourceAllocatorClient(conn).AttachNetwork(modCtx, r)
  434. }
  435. return resp, err
  436. }
  437. func (p *raftProxyResourceAllocatorServer) DetachNetwork(ctx context.Context, r *DetachNetworkRequest) (*DetachNetworkResponse, error) {
  438. conn, err := p.connSelector.LeaderConn(ctx)
  439. if err != nil {
  440. if err == raftselector.ErrIsLeader {
  441. ctx, err = p.runCtxMods(ctx, p.localCtxMods)
  442. if err != nil {
  443. return nil, err
  444. }
  445. return p.local.DetachNetwork(ctx, r)
  446. }
  447. return nil, err
  448. }
  449. modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
  450. if err != nil {
  451. return nil, err
  452. }
  453. resp, err := NewResourceAllocatorClient(conn).DetachNetwork(modCtx, r)
  454. if err != nil {
  455. if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
  456. return resp, err
  457. }
  458. conn, err := p.pollNewLeaderConn(ctx)
  459. if err != nil {
  460. if err == raftselector.ErrIsLeader {
  461. return p.local.DetachNetwork(ctx, r)
  462. }
  463. return nil, err
  464. }
  465. return NewResourceAllocatorClient(conn).DetachNetwork(modCtx, r)
  466. }
  467. return resp, err
  468. }
  469. func (m *AttachNetworkRequest) Size() (n int) {
  470. var l int
  471. _ = l
  472. if m.Config != nil {
  473. l = m.Config.Size()
  474. n += 1 + l + sovResource(uint64(l))
  475. }
  476. l = len(m.ContainerID)
  477. if l > 0 {
  478. n += 1 + l + sovResource(uint64(l))
  479. }
  480. return n
  481. }
  482. func (m *AttachNetworkResponse) Size() (n int) {
  483. var l int
  484. _ = l
  485. l = len(m.AttachmentID)
  486. if l > 0 {
  487. n += 1 + l + sovResource(uint64(l))
  488. }
  489. return n
  490. }
  491. func (m *DetachNetworkRequest) Size() (n int) {
  492. var l int
  493. _ = l
  494. l = len(m.AttachmentID)
  495. if l > 0 {
  496. n += 1 + l + sovResource(uint64(l))
  497. }
  498. return n
  499. }
  500. func (m *DetachNetworkResponse) Size() (n int) {
  501. var l int
  502. _ = l
  503. return n
  504. }
  505. func sovResource(x uint64) (n int) {
  506. for {
  507. n++
  508. x >>= 7
  509. if x == 0 {
  510. break
  511. }
  512. }
  513. return n
  514. }
  515. func sozResource(x uint64) (n int) {
  516. return sovResource(uint64((x << 1) ^ uint64((int64(x) >> 63))))
  517. }
  518. func (this *AttachNetworkRequest) String() string {
  519. if this == nil {
  520. return "nil"
  521. }
  522. s := strings.Join([]string{`&AttachNetworkRequest{`,
  523. `Config:` + strings.Replace(fmt.Sprintf("%v", this.Config), "NetworkAttachmentConfig", "NetworkAttachmentConfig", 1) + `,`,
  524. `ContainerID:` + fmt.Sprintf("%v", this.ContainerID) + `,`,
  525. `}`,
  526. }, "")
  527. return s
  528. }
  529. func (this *AttachNetworkResponse) String() string {
  530. if this == nil {
  531. return "nil"
  532. }
  533. s := strings.Join([]string{`&AttachNetworkResponse{`,
  534. `AttachmentID:` + fmt.Sprintf("%v", this.AttachmentID) + `,`,
  535. `}`,
  536. }, "")
  537. return s
  538. }
  539. func (this *DetachNetworkRequest) String() string {
  540. if this == nil {
  541. return "nil"
  542. }
  543. s := strings.Join([]string{`&DetachNetworkRequest{`,
  544. `AttachmentID:` + fmt.Sprintf("%v", this.AttachmentID) + `,`,
  545. `}`,
  546. }, "")
  547. return s
  548. }
  549. func (this *DetachNetworkResponse) String() string {
  550. if this == nil {
  551. return "nil"
  552. }
  553. s := strings.Join([]string{`&DetachNetworkResponse{`,
  554. `}`,
  555. }, "")
  556. return s
  557. }
  558. func valueToStringResource(v interface{}) string {
  559. rv := reflect.ValueOf(v)
  560. if rv.IsNil() {
  561. return "nil"
  562. }
  563. pv := reflect.Indirect(rv).Interface()
  564. return fmt.Sprintf("*%v", pv)
  565. }
  566. func (m *AttachNetworkRequest) Unmarshal(dAtA []byte) error {
  567. l := len(dAtA)
  568. iNdEx := 0
  569. for iNdEx < l {
  570. preIndex := iNdEx
  571. var wire uint64
  572. for shift := uint(0); ; shift += 7 {
  573. if shift >= 64 {
  574. return ErrIntOverflowResource
  575. }
  576. if iNdEx >= l {
  577. return io.ErrUnexpectedEOF
  578. }
  579. b := dAtA[iNdEx]
  580. iNdEx++
  581. wire |= (uint64(b) & 0x7F) << shift
  582. if b < 0x80 {
  583. break
  584. }
  585. }
  586. fieldNum := int32(wire >> 3)
  587. wireType := int(wire & 0x7)
  588. if wireType == 4 {
  589. return fmt.Errorf("proto: AttachNetworkRequest: wiretype end group for non-group")
  590. }
  591. if fieldNum <= 0 {
  592. return fmt.Errorf("proto: AttachNetworkRequest: illegal tag %d (wire type %d)", fieldNum, wire)
  593. }
  594. switch fieldNum {
  595. case 1:
  596. if wireType != 2 {
  597. return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType)
  598. }
  599. var msglen int
  600. for shift := uint(0); ; shift += 7 {
  601. if shift >= 64 {
  602. return ErrIntOverflowResource
  603. }
  604. if iNdEx >= l {
  605. return io.ErrUnexpectedEOF
  606. }
  607. b := dAtA[iNdEx]
  608. iNdEx++
  609. msglen |= (int(b) & 0x7F) << shift
  610. if b < 0x80 {
  611. break
  612. }
  613. }
  614. if msglen < 0 {
  615. return ErrInvalidLengthResource
  616. }
  617. postIndex := iNdEx + msglen
  618. if postIndex > l {
  619. return io.ErrUnexpectedEOF
  620. }
  621. if m.Config == nil {
  622. m.Config = &NetworkAttachmentConfig{}
  623. }
  624. if err := m.Config.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
  625. return err
  626. }
  627. iNdEx = postIndex
  628. case 2:
  629. if wireType != 2 {
  630. return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType)
  631. }
  632. var stringLen uint64
  633. for shift := uint(0); ; shift += 7 {
  634. if shift >= 64 {
  635. return ErrIntOverflowResource
  636. }
  637. if iNdEx >= l {
  638. return io.ErrUnexpectedEOF
  639. }
  640. b := dAtA[iNdEx]
  641. iNdEx++
  642. stringLen |= (uint64(b) & 0x7F) << shift
  643. if b < 0x80 {
  644. break
  645. }
  646. }
  647. intStringLen := int(stringLen)
  648. if intStringLen < 0 {
  649. return ErrInvalidLengthResource
  650. }
  651. postIndex := iNdEx + intStringLen
  652. if postIndex > l {
  653. return io.ErrUnexpectedEOF
  654. }
  655. m.ContainerID = string(dAtA[iNdEx:postIndex])
  656. iNdEx = postIndex
  657. default:
  658. iNdEx = preIndex
  659. skippy, err := skipResource(dAtA[iNdEx:])
  660. if err != nil {
  661. return err
  662. }
  663. if skippy < 0 {
  664. return ErrInvalidLengthResource
  665. }
  666. if (iNdEx + skippy) > l {
  667. return io.ErrUnexpectedEOF
  668. }
  669. iNdEx += skippy
  670. }
  671. }
  672. if iNdEx > l {
  673. return io.ErrUnexpectedEOF
  674. }
  675. return nil
  676. }
  677. func (m *AttachNetworkResponse) Unmarshal(dAtA []byte) error {
  678. l := len(dAtA)
  679. iNdEx := 0
  680. for iNdEx < l {
  681. preIndex := iNdEx
  682. var wire uint64
  683. for shift := uint(0); ; shift += 7 {
  684. if shift >= 64 {
  685. return ErrIntOverflowResource
  686. }
  687. if iNdEx >= l {
  688. return io.ErrUnexpectedEOF
  689. }
  690. b := dAtA[iNdEx]
  691. iNdEx++
  692. wire |= (uint64(b) & 0x7F) << shift
  693. if b < 0x80 {
  694. break
  695. }
  696. }
  697. fieldNum := int32(wire >> 3)
  698. wireType := int(wire & 0x7)
  699. if wireType == 4 {
  700. return fmt.Errorf("proto: AttachNetworkResponse: wiretype end group for non-group")
  701. }
  702. if fieldNum <= 0 {
  703. return fmt.Errorf("proto: AttachNetworkResponse: illegal tag %d (wire type %d)", fieldNum, wire)
  704. }
  705. switch fieldNum {
  706. case 1:
  707. if wireType != 2 {
  708. return fmt.Errorf("proto: wrong wireType = %d for field AttachmentID", wireType)
  709. }
  710. var stringLen uint64
  711. for shift := uint(0); ; shift += 7 {
  712. if shift >= 64 {
  713. return ErrIntOverflowResource
  714. }
  715. if iNdEx >= l {
  716. return io.ErrUnexpectedEOF
  717. }
  718. b := dAtA[iNdEx]
  719. iNdEx++
  720. stringLen |= (uint64(b) & 0x7F) << shift
  721. if b < 0x80 {
  722. break
  723. }
  724. }
  725. intStringLen := int(stringLen)
  726. if intStringLen < 0 {
  727. return ErrInvalidLengthResource
  728. }
  729. postIndex := iNdEx + intStringLen
  730. if postIndex > l {
  731. return io.ErrUnexpectedEOF
  732. }
  733. m.AttachmentID = string(dAtA[iNdEx:postIndex])
  734. iNdEx = postIndex
  735. default:
  736. iNdEx = preIndex
  737. skippy, err := skipResource(dAtA[iNdEx:])
  738. if err != nil {
  739. return err
  740. }
  741. if skippy < 0 {
  742. return ErrInvalidLengthResource
  743. }
  744. if (iNdEx + skippy) > l {
  745. return io.ErrUnexpectedEOF
  746. }
  747. iNdEx += skippy
  748. }
  749. }
  750. if iNdEx > l {
  751. return io.ErrUnexpectedEOF
  752. }
  753. return nil
  754. }
  755. func (m *DetachNetworkRequest) Unmarshal(dAtA []byte) error {
  756. l := len(dAtA)
  757. iNdEx := 0
  758. for iNdEx < l {
  759. preIndex := iNdEx
  760. var wire uint64
  761. for shift := uint(0); ; shift += 7 {
  762. if shift >= 64 {
  763. return ErrIntOverflowResource
  764. }
  765. if iNdEx >= l {
  766. return io.ErrUnexpectedEOF
  767. }
  768. b := dAtA[iNdEx]
  769. iNdEx++
  770. wire |= (uint64(b) & 0x7F) << shift
  771. if b < 0x80 {
  772. break
  773. }
  774. }
  775. fieldNum := int32(wire >> 3)
  776. wireType := int(wire & 0x7)
  777. if wireType == 4 {
  778. return fmt.Errorf("proto: DetachNetworkRequest: wiretype end group for non-group")
  779. }
  780. if fieldNum <= 0 {
  781. return fmt.Errorf("proto: DetachNetworkRequest: illegal tag %d (wire type %d)", fieldNum, wire)
  782. }
  783. switch fieldNum {
  784. case 1:
  785. if wireType != 2 {
  786. return fmt.Errorf("proto: wrong wireType = %d for field AttachmentID", wireType)
  787. }
  788. var stringLen uint64
  789. for shift := uint(0); ; shift += 7 {
  790. if shift >= 64 {
  791. return ErrIntOverflowResource
  792. }
  793. if iNdEx >= l {
  794. return io.ErrUnexpectedEOF
  795. }
  796. b := dAtA[iNdEx]
  797. iNdEx++
  798. stringLen |= (uint64(b) & 0x7F) << shift
  799. if b < 0x80 {
  800. break
  801. }
  802. }
  803. intStringLen := int(stringLen)
  804. if intStringLen < 0 {
  805. return ErrInvalidLengthResource
  806. }
  807. postIndex := iNdEx + intStringLen
  808. if postIndex > l {
  809. return io.ErrUnexpectedEOF
  810. }
  811. m.AttachmentID = string(dAtA[iNdEx:postIndex])
  812. iNdEx = postIndex
  813. default:
  814. iNdEx = preIndex
  815. skippy, err := skipResource(dAtA[iNdEx:])
  816. if err != nil {
  817. return err
  818. }
  819. if skippy < 0 {
  820. return ErrInvalidLengthResource
  821. }
  822. if (iNdEx + skippy) > l {
  823. return io.ErrUnexpectedEOF
  824. }
  825. iNdEx += skippy
  826. }
  827. }
  828. if iNdEx > l {
  829. return io.ErrUnexpectedEOF
  830. }
  831. return nil
  832. }
  833. func (m *DetachNetworkResponse) Unmarshal(dAtA []byte) error {
  834. l := len(dAtA)
  835. iNdEx := 0
  836. for iNdEx < l {
  837. preIndex := iNdEx
  838. var wire uint64
  839. for shift := uint(0); ; shift += 7 {
  840. if shift >= 64 {
  841. return ErrIntOverflowResource
  842. }
  843. if iNdEx >= l {
  844. return io.ErrUnexpectedEOF
  845. }
  846. b := dAtA[iNdEx]
  847. iNdEx++
  848. wire |= (uint64(b) & 0x7F) << shift
  849. if b < 0x80 {
  850. break
  851. }
  852. }
  853. fieldNum := int32(wire >> 3)
  854. wireType := int(wire & 0x7)
  855. if wireType == 4 {
  856. return fmt.Errorf("proto: DetachNetworkResponse: wiretype end group for non-group")
  857. }
  858. if fieldNum <= 0 {
  859. return fmt.Errorf("proto: DetachNetworkResponse: illegal tag %d (wire type %d)", fieldNum, wire)
  860. }
  861. switch fieldNum {
  862. default:
  863. iNdEx = preIndex
  864. skippy, err := skipResource(dAtA[iNdEx:])
  865. if err != nil {
  866. return err
  867. }
  868. if skippy < 0 {
  869. return ErrInvalidLengthResource
  870. }
  871. if (iNdEx + skippy) > l {
  872. return io.ErrUnexpectedEOF
  873. }
  874. iNdEx += skippy
  875. }
  876. }
  877. if iNdEx > l {
  878. return io.ErrUnexpectedEOF
  879. }
  880. return nil
  881. }
  882. func skipResource(dAtA []byte) (n int, err error) {
  883. l := len(dAtA)
  884. iNdEx := 0
  885. for iNdEx < l {
  886. var wire uint64
  887. for shift := uint(0); ; shift += 7 {
  888. if shift >= 64 {
  889. return 0, ErrIntOverflowResource
  890. }
  891. if iNdEx >= l {
  892. return 0, io.ErrUnexpectedEOF
  893. }
  894. b := dAtA[iNdEx]
  895. iNdEx++
  896. wire |= (uint64(b) & 0x7F) << shift
  897. if b < 0x80 {
  898. break
  899. }
  900. }
  901. wireType := int(wire & 0x7)
  902. switch wireType {
  903. case 0:
  904. for shift := uint(0); ; shift += 7 {
  905. if shift >= 64 {
  906. return 0, ErrIntOverflowResource
  907. }
  908. if iNdEx >= l {
  909. return 0, io.ErrUnexpectedEOF
  910. }
  911. iNdEx++
  912. if dAtA[iNdEx-1] < 0x80 {
  913. break
  914. }
  915. }
  916. return iNdEx, nil
  917. case 1:
  918. iNdEx += 8
  919. return iNdEx, nil
  920. case 2:
  921. var length int
  922. for shift := uint(0); ; shift += 7 {
  923. if shift >= 64 {
  924. return 0, ErrIntOverflowResource
  925. }
  926. if iNdEx >= l {
  927. return 0, io.ErrUnexpectedEOF
  928. }
  929. b := dAtA[iNdEx]
  930. iNdEx++
  931. length |= (int(b) & 0x7F) << shift
  932. if b < 0x80 {
  933. break
  934. }
  935. }
  936. iNdEx += length
  937. if length < 0 {
  938. return 0, ErrInvalidLengthResource
  939. }
  940. return iNdEx, nil
  941. case 3:
  942. for {
  943. var innerWire uint64
  944. var start int = iNdEx
  945. for shift := uint(0); ; shift += 7 {
  946. if shift >= 64 {
  947. return 0, ErrIntOverflowResource
  948. }
  949. if iNdEx >= l {
  950. return 0, io.ErrUnexpectedEOF
  951. }
  952. b := dAtA[iNdEx]
  953. iNdEx++
  954. innerWire |= (uint64(b) & 0x7F) << shift
  955. if b < 0x80 {
  956. break
  957. }
  958. }
  959. innerWireType := int(innerWire & 0x7)
  960. if innerWireType == 4 {
  961. break
  962. }
  963. next, err := skipResource(dAtA[start:])
  964. if err != nil {
  965. return 0, err
  966. }
  967. iNdEx = start + next
  968. }
  969. return iNdEx, nil
  970. case 4:
  971. return iNdEx, nil
  972. case 5:
  973. iNdEx += 4
  974. return iNdEx, nil
  975. default:
  976. return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  977. }
  978. }
  979. panic("unreachable")
  980. }
  981. var (
  982. ErrInvalidLengthResource = fmt.Errorf("proto: negative length found during unmarshaling")
  983. ErrIntOverflowResource = fmt.Errorf("proto: integer overflow")
  984. )
  985. func init() {
  986. proto.RegisterFile("github.com/docker/swarmkit/api/resource.proto", fileDescriptorResource)
  987. }
  988. var fileDescriptorResource = []byte{
  989. // 397 bytes of a gzipped FileDescriptorProto
  990. 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0x4e, 0xf2, 0x40,
  991. 0x14, 0xc5, 0x19, 0x16, 0x24, 0xdf, 0x50, 0xf2, 0x69, 0x03, 0x91, 0x90, 0x58, 0x48, 0xdd, 0xa0,
  992. 0x86, 0x36, 0x62, 0x8c, 0x6b, 0xfe, 0x6c, 0xba, 0x90, 0x45, 0x5f, 0xc0, 0x0c, 0xed, 0x50, 0x1a,
  993. 0x68, 0xa7, 0x4e, 0xa7, 0x12, 0x77, 0x6e, 0x5d, 0xb9, 0xf5, 0x1d, 0x4c, 0x7c, 0x0e, 0xe2, 0xca,
  994. 0xa5, 0x2b, 0x22, 0x7d, 0x00, 0x9f, 0xc1, 0xd0, 0x29, 0x10, 0x70, 0xa2, 0xc4, 0x55, 0xa7, 0xd3,
  995. 0x73, 0xce, 0xfd, 0xdd, 0x7b, 0x0b, 0x1b, 0x8e, 0xcb, 0x86, 0x51, 0x5f, 0xb3, 0x88, 0xa7, 0xdb,
  996. 0xc4, 0x1a, 0x61, 0xaa, 0x87, 0x13, 0x44, 0xbd, 0x91, 0xcb, 0x74, 0x14, 0xb8, 0x3a, 0xc5, 0x21,
  997. 0x89, 0xa8, 0x85, 0xb5, 0x80, 0x12, 0x46, 0x64, 0x99, 0x6b, 0xb4, 0xa5, 0x46, 0xbb, 0x3d, 0xab,
  998. 0x9c, 0xfc, 0x12, 0xc1, 0xee, 0x02, 0x1c, 0x72, 0x7f, 0xa5, 0xe8, 0x10, 0x87, 0x24, 0x47, 0x7d,
  999. 0x71, 0x4a, 0x6f, 0x2f, 0x7f, 0x48, 0x48, 0x14, 0xfd, 0x68, 0xa0, 0x07, 0xe3, 0xc8, 0x71, 0xfd,
  1000. 0xf4, 0xc1, 0x8d, 0xea, 0x23, 0x80, 0xc5, 0x16, 0x63, 0xc8, 0x1a, 0xf6, 0x30, 0x9b, 0x10, 0x3a,
  1001. 0x32, 0xf1, 0x4d, 0x84, 0x43, 0x26, 0x77, 0x60, 0xce, 0x22, 0xfe, 0xc0, 0x75, 0xca, 0xa0, 0x06,
  1002. 0xea, 0xf9, 0xe6, 0xa9, 0xf6, 0x1d, 0x5c, 0x4b, 0x3d, 0x3c, 0xc0, 0xc3, 0x3e, 0xeb, 0x24, 0x16,
  1003. 0x33, 0xb5, 0xca, 0x4d, 0x28, 0x59, 0xc4, 0x67, 0xc8, 0xf5, 0x31, 0xbd, 0x76, 0xed, 0x72, 0xb6,
  1004. 0x06, 0xea, 0xff, 0xda, 0xff, 0xe3, 0x59, 0x35, 0xdf, 0x59, 0xde, 0x1b, 0x5d, 0x33, 0xbf, 0x12,
  1005. 0x19, 0xb6, 0xda, 0x83, 0xa5, 0x2d, 0xa0, 0x30, 0x20, 0x7e, 0x88, 0xe5, 0x0b, 0x58, 0x40, 0xab,
  1006. 0x42, 0x8b, 0x34, 0x90, 0xa4, 0xed, 0xc5, 0xb3, 0xaa, 0xb4, 0x26, 0x30, 0xba, 0xa6, 0xb4, 0x96,
  1007. 0x19, 0xb6, 0x7a, 0x05, 0x8b, 0x5d, 0x2c, 0x68, 0xf0, 0x8f, 0x71, 0x07, 0xb0, 0xb4, 0x15, 0xc7,
  1008. 0xf1, 0x9a, 0xcf, 0x59, 0xb8, 0x6f, 0xa6, 0xbb, 0x6e, 0x8d, 0xc7, 0xc4, 0x42, 0x8c, 0x50, 0xf9,
  1009. 0x01, 0xc0, 0xc2, 0x46, 0x3b, 0x72, 0x5d, 0x34, 0x48, 0xd1, 0x0a, 0x2a, 0xc7, 0x3b, 0x28, 0x79,
  1010. 0x71, 0xf5, 0xe8, 0xf5, 0xe5, 0xf3, 0x29, 0x7b, 0x08, 0xa5, 0x44, 0xda, 0x58, 0x7c, 0xc3, 0x14,
  1011. 0x16, 0xf8, 0x9b, 0x87, 0x7c, 0xe4, 0x60, 0xce, 0xb2, 0xc1, 0x2e, 0x66, 0x11, 0x4d, 0x4b, 0xcc,
  1012. 0x22, 0x1c, 0xc4, 0x4e, 0x2c, 0xed, 0xf2, 0x74, 0xae, 0x64, 0xde, 0xe7, 0x4a, 0xe6, 0x3e, 0x56,
  1013. 0xc0, 0x34, 0x56, 0xc0, 0x5b, 0xac, 0x80, 0x8f, 0x58, 0x01, 0xfd, 0x5c, 0xf2, 0x63, 0x9e, 0x7f,
  1014. 0x05, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x7a, 0x29, 0xfc, 0x58, 0x03, 0x00, 0x00,
  1015. }