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