node.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package swarm // import "github.com/docker/docker/api/types/swarm"
  2. // Node represents a node.
  3. type Node struct {
  4. ID string
  5. Meta
  6. // Spec defines the desired state of the node as specified by the user.
  7. // The system will honor this and will *never* modify it.
  8. Spec NodeSpec `json:",omitempty"`
  9. // Description encapsulates the properties of the Node as reported by the
  10. // agent.
  11. Description NodeDescription `json:",omitempty"`
  12. // Status provides the current status of the node, as seen by the manager.
  13. Status NodeStatus `json:",omitempty"`
  14. // ManagerStatus provides the current status of the node's manager
  15. // component, if the node is a manager.
  16. ManagerStatus *ManagerStatus `json:",omitempty"`
  17. }
  18. // NodeSpec represents the spec of a node.
  19. type NodeSpec struct {
  20. Annotations
  21. Role NodeRole `json:",omitempty"`
  22. Availability NodeAvailability `json:",omitempty"`
  23. }
  24. // NodeRole represents the role of a node.
  25. type NodeRole string
  26. const (
  27. // NodeRoleWorker WORKER
  28. NodeRoleWorker NodeRole = "worker"
  29. // NodeRoleManager MANAGER
  30. NodeRoleManager NodeRole = "manager"
  31. )
  32. // NodeAvailability represents the availability of a node.
  33. type NodeAvailability string
  34. const (
  35. // NodeAvailabilityActive ACTIVE
  36. NodeAvailabilityActive NodeAvailability = "active"
  37. // NodeAvailabilityPause PAUSE
  38. NodeAvailabilityPause NodeAvailability = "pause"
  39. // NodeAvailabilityDrain DRAIN
  40. NodeAvailabilityDrain NodeAvailability = "drain"
  41. )
  42. // NodeDescription represents the description of a node.
  43. type NodeDescription struct {
  44. Hostname string `json:",omitempty"`
  45. Platform Platform `json:",omitempty"`
  46. Resources Resources `json:",omitempty"`
  47. Engine EngineDescription `json:",omitempty"`
  48. TLSInfo TLSInfo `json:",omitempty"`
  49. }
  50. // Platform represents the platform (Arch/OS).
  51. type Platform struct {
  52. Architecture string `json:",omitempty"`
  53. OS string `json:",omitempty"`
  54. }
  55. // EngineDescription represents the description of an engine.
  56. type EngineDescription struct {
  57. EngineVersion string `json:",omitempty"`
  58. Labels map[string]string `json:",omitempty"`
  59. Plugins []PluginDescription `json:",omitempty"`
  60. }
  61. // PluginDescription represents the description of an engine plugin.
  62. type PluginDescription struct {
  63. Type string `json:",omitempty"`
  64. Name string `json:",omitempty"`
  65. }
  66. // NodeStatus represents the status of a node.
  67. type NodeStatus struct {
  68. State NodeState `json:",omitempty"`
  69. Message string `json:",omitempty"`
  70. Addr string `json:",omitempty"`
  71. }
  72. // Reachability represents the reachability of a node.
  73. type Reachability string
  74. const (
  75. // ReachabilityUnknown UNKNOWN
  76. ReachabilityUnknown Reachability = "unknown"
  77. // ReachabilityUnreachable UNREACHABLE
  78. ReachabilityUnreachable Reachability = "unreachable"
  79. // ReachabilityReachable REACHABLE
  80. ReachabilityReachable Reachability = "reachable"
  81. )
  82. // ManagerStatus represents the status of a manager.
  83. type ManagerStatus struct {
  84. Leader bool `json:",omitempty"`
  85. Reachability Reachability `json:",omitempty"`
  86. Addr string `json:",omitempty"`
  87. }
  88. // NodeState represents the state of a node.
  89. type NodeState string
  90. const (
  91. // NodeStateUnknown UNKNOWN
  92. NodeStateUnknown NodeState = "unknown"
  93. // NodeStateDown DOWN
  94. NodeStateDown NodeState = "down"
  95. // NodeStateReady READY
  96. NodeStateReady NodeState = "ready"
  97. // NodeStateDisconnected DISCONNECTED
  98. NodeStateDisconnected NodeState = "disconnected"
  99. )