swagger:operation GET /1.0/cluster cluster cluster_get Get the cluster configuration Gets the current cluster configuration. --- produces: - application/json responses: "200": description: Cluster configuration schema: type: object description: Sync response
(d *Daemon, r *http.Request)
| 111 | // "500": |
| 112 | // $ref: "#/responses/InternalServerError" |
| 113 | func clusterGet(d *Daemon, r *http.Request) response.Response { |
| 114 | s := d.State() |
| 115 | serverName := s.ServerName |
| 116 | |
| 117 | // If the name is set to the hard-coded default node name, then |
| 118 | // clustering is not enabled. |
| 119 | if serverName == "none" { |
| 120 | serverName = "" |
| 121 | } |
| 122 | |
| 123 | memberConfig, err := clusterGetMemberConfig(r.Context(), s.DB.Cluster) |
| 124 | if err != nil { |
| 125 | return response.SmartError(err) |
| 126 | } |
| 127 | |
| 128 | // Sort the member config. |
| 129 | sort.Slice(memberConfig, func(i, j int) bool { |
| 130 | left := memberConfig[i] |
| 131 | right := memberConfig[j] |
| 132 | |
| 133 | if left.Entity != right.Entity { |
| 134 | return left.Entity < right.Entity |
| 135 | } |
| 136 | |
| 137 | if left.Name != right.Name { |
| 138 | return left.Name < right.Name |
| 139 | } |
| 140 | |
| 141 | if left.Key != right.Key { |
| 142 | return left.Key < right.Key |
| 143 | } |
| 144 | |
| 145 | return left.Description < right.Description |
| 146 | }) |
| 147 | |
| 148 | clusterInfo := api.Cluster{ |
| 149 | ServerName: serverName, |
| 150 | Enabled: serverName != "", |
| 151 | MemberConfig: memberConfig, |
| 152 | } |
| 153 | |
| 154 | return response.SyncResponseETag(true, clusterInfo, clusterInfo) |
| 155 | } |
| 156 | |
| 157 | // Fetch information about all node-specific configuration keys set on the |
| 158 | // storage pools and networks of this cluster. |
nothing calls this directly
no test coverage detected
searching dependent graphs…