github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/api/types/swarm/node.go (about) 1 package swarm // import "github.com/demonoid81/moby/api/types/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 TLSInfo TLSInfo `json:",omitempty"` 56 } 57 58 // Platform represents the platform (Arch/OS). 59 type Platform struct { 60 Architecture string `json:",omitempty"` 61 OS string `json:",omitempty"` 62 } 63 64 // EngineDescription represents the description of an engine. 65 type EngineDescription struct { 66 EngineVersion string `json:",omitempty"` 67 Labels map[string]string `json:",omitempty"` 68 Plugins []PluginDescription `json:",omitempty"` 69 } 70 71 // PluginDescription represents the description of an engine plugin. 72 type PluginDescription struct { 73 Type string `json:",omitempty"` 74 Name string `json:",omitempty"` 75 } 76 77 // NodeStatus represents the status of a node. 78 type NodeStatus struct { 79 State NodeState `json:",omitempty"` 80 Message string `json:",omitempty"` 81 Addr string `json:",omitempty"` 82 } 83 84 // Reachability represents the reachability of a node. 85 type Reachability string 86 87 const ( 88 // ReachabilityUnknown UNKNOWN 89 ReachabilityUnknown Reachability = "unknown" 90 // ReachabilityUnreachable UNREACHABLE 91 ReachabilityUnreachable Reachability = "unreachable" 92 // ReachabilityReachable REACHABLE 93 ReachabilityReachable Reachability = "reachable" 94 ) 95 96 // ManagerStatus represents the status of a manager. 97 type ManagerStatus struct { 98 Leader bool `json:",omitempty"` 99 Reachability Reachability `json:",omitempty"` 100 Addr string `json:",omitempty"` 101 } 102 103 // NodeState represents the state of a node. 104 type NodeState string 105 106 const ( 107 // NodeStateUnknown UNKNOWN 108 NodeStateUnknown NodeState = "unknown" 109 // NodeStateDown DOWN 110 NodeStateDown NodeState = "down" 111 // NodeStateReady READY 112 NodeStateReady NodeState = "ready" 113 // NodeStateDisconnected DISCONNECTED 114 NodeStateDisconnected NodeState = "disconnected" 115 )