resource.pb.go 29 KB

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