github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/api/types/swarm/swarm.go (about) 1 package swarm 2 3 import "time" 4 5 // ClusterInfo represents info about the cluster for outputing in "info" 6 // it contains the same information as "Swarm", but without the JoinTokens 7 type ClusterInfo struct { 8 ID string 9 Meta 10 Spec Spec 11 } 12 13 // Swarm represents a swarm. 14 type Swarm struct { 15 ClusterInfo 16 JoinTokens JoinTokens 17 } 18 19 // JoinTokens contains the tokens workers and managers need to join the swarm. 20 type JoinTokens struct { 21 // Worker is the join token workers may use to join the swarm. 22 Worker string 23 // Manager is the join token managers may use to join the swarm. 24 Manager string 25 } 26 27 // Spec represents the spec of a swarm. 28 type Spec struct { 29 Annotations 30 31 Orchestration OrchestrationConfig `json:",omitempty"` 32 Raft RaftConfig `json:",omitempty"` 33 Dispatcher DispatcherConfig `json:",omitempty"` 34 CAConfig CAConfig `json:",omitempty"` 35 TaskDefaults TaskDefaults `json:",omitempty"` 36 EncryptionConfig EncryptionConfig `json:",omitempty"` 37 } 38 39 // OrchestrationConfig represents orchestration configuration. 40 type OrchestrationConfig struct { 41 // TaskHistoryRetentionLimit is the number of historic tasks to keep per instance or 42 // node. If negative, never remove completed or failed tasks. 43 TaskHistoryRetentionLimit *int64 `json:",omitempty"` 44 } 45 46 // TaskDefaults parameterizes cluster-level task creation with default values. 47 type TaskDefaults struct { 48 // LogDriver selects the log driver to use for tasks created in the 49 // orchestrator if unspecified by a service. 50 // 51 // Updating this value will only have an affect on new tasks. Old tasks 52 // will continue use their previously configured log driver until 53 // recreated. 54 LogDriver *Driver `json:",omitempty"` 55 } 56 57 // EncryptionConfig controls at-rest encryption of data and keys. 58 type EncryptionConfig struct { 59 // AutoLockManagers specifies whether or not managers TLS keys and raft data 60 // should be encrypted at rest in such a way that they must be unlocked 61 // before the manager node starts up again. 62 AutoLockManagers bool 63 } 64 65 // RaftConfig represents raft configuration. 66 type RaftConfig struct { 67 // SnapshotInterval is the number of log entries between snapshots. 68 SnapshotInterval uint64 `json:",omitempty"` 69 70 // KeepOldSnapshots is the number of snapshots to keep beyond the 71 // current snapshot. 72 KeepOldSnapshots *uint64 `json:",omitempty"` 73 74 // LogEntriesForSlowFollowers is the number of log entries to keep 75 // around to sync up slow followers after a snapshot is created. 76 LogEntriesForSlowFollowers uint64 `json:",omitempty"` 77 78 // ElectionTick is the number of ticks that a follower will wait for a message 79 // from the leader before becoming a candidate and starting an election. 80 // ElectionTick must be greater than HeartbeatTick. 81 // 82 // A tick currently defaults to one second, so these translate directly to 83 // seconds currently, but this is NOT guaranteed. 84 ElectionTick int 85 86 // HeartbeatTick is the number of ticks between heartbeats. Every 87 // HeartbeatTick ticks, the leader will send a heartbeat to the 88 // followers. 89 // 90 // A tick currently defaults to one second, so these translate directly to 91 // seconds currently, but this is NOT guaranteed. 92 HeartbeatTick int 93 } 94 95 // DispatcherConfig represents dispatcher configuration. 96 type DispatcherConfig struct { 97 // HeartbeatPeriod defines how often agent should send heartbeats to 98 // dispatcher. 99 HeartbeatPeriod time.Duration `json:",omitempty"` 100 } 101 102 // CAConfig represents CA configuration. 103 type CAConfig struct { 104 // NodeCertExpiry is the duration certificates should be issued for 105 NodeCertExpiry time.Duration `json:",omitempty"` 106 107 // ExternalCAs is a list of CAs to which a manager node will make 108 // certificate signing requests for node certificates. 109 ExternalCAs []*ExternalCA `json:",omitempty"` 110 } 111 112 // ExternalCAProtocol represents type of external CA. 113 type ExternalCAProtocol string 114 115 // ExternalCAProtocolCFSSL CFSSL 116 const ExternalCAProtocolCFSSL ExternalCAProtocol = "cfssl" 117 118 // ExternalCA defines external CA to be used by the cluster. 119 type ExternalCA struct { 120 // Protocol is the protocol used by this external CA. 121 Protocol ExternalCAProtocol 122 123 // URL is the URL where the external CA can be reached. 124 URL string 125 126 // Options is a set of additional key/value pairs whose interpretation 127 // depends on the specified CA type. 128 Options map[string]string `json:",omitempty"` 129 } 130 131 // InitRequest is the request used to init a swarm. 132 type InitRequest struct { 133 ListenAddr string 134 AdvertiseAddr string 135 ForceNewCluster bool 136 Spec Spec 137 AutoLockManagers bool 138 Availability NodeAvailability 139 } 140 141 // JoinRequest is the request used to join a swarm. 142 type JoinRequest struct { 143 ListenAddr string 144 AdvertiseAddr string 145 RemoteAddrs []string 146 JoinToken string // accept by secret 147 Availability NodeAvailability 148 } 149 150 // UnlockRequest is the request used to unlock a swarm. 151 type UnlockRequest struct { 152 // UnlockKey is the unlock key in ASCII-armored format. 153 UnlockKey string 154 } 155 156 // LocalNodeState represents the state of the local node. 157 type LocalNodeState string 158 159 const ( 160 // LocalNodeStateInactive INACTIVE 161 LocalNodeStateInactive LocalNodeState = "inactive" 162 // LocalNodeStatePending PENDING 163 LocalNodeStatePending LocalNodeState = "pending" 164 // LocalNodeStateActive ACTIVE 165 LocalNodeStateActive LocalNodeState = "active" 166 // LocalNodeStateError ERROR 167 LocalNodeStateError LocalNodeState = "error" 168 // LocalNodeStateLocked LOCKED 169 LocalNodeStateLocked LocalNodeState = "locked" 170 ) 171 172 // Info represents generic information about swarm. 173 type Info struct { 174 NodeID string 175 NodeAddr string 176 177 LocalNodeState LocalNodeState 178 ControlAvailable bool 179 Error string 180 181 RemoteManagers []Peer 182 Nodes int 183 Managers int 184 185 Cluster ClusterInfo 186 } 187 188 // Peer represents a peer. 189 type Peer struct { 190 NodeID string 191 Addr string 192 } 193 194 // UpdateFlags contains flags for SwarmUpdate. 195 type UpdateFlags struct { 196 RotateWorkerToken bool 197 RotateManagerToken bool 198 RotateManagerUnlockKey bool 199 }