|
1 | 1 | package node |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "bytes" |
4 | 5 | "encoding/base64" |
5 | 6 | "fmt" |
6 | | - "reflect" |
7 | 7 | "strings" |
8 | 8 |
|
9 | 9 | "github.com/docker/cli/cli/command/formatter" |
@@ -170,15 +170,23 @@ func (c *nodeContext) ManagerStatus() string { |
170 | 170 | } |
171 | 171 |
|
172 | 172 | func (c *nodeContext) TLSStatus() string { |
173 | | - if c.info.Cluster == nil || reflect.DeepEqual(c.info.Cluster.TLSInfo, swarm.TLSInfo{}) || reflect.DeepEqual(c.n.Description.TLSInfo, swarm.TLSInfo{}) { |
| 173 | + if c.info.Cluster == nil || isEmptyTLSInfo(c.info.Cluster.TLSInfo) || isEmptyTLSInfo(c.n.Description.TLSInfo) { |
174 | 174 | return "Unknown" |
175 | 175 | } |
176 | | - if reflect.DeepEqual(c.n.Description.TLSInfo, c.info.Cluster.TLSInfo) { |
| 176 | + if equalTLSInfo(c.n.Description.TLSInfo, c.info.Cluster.TLSInfo) { |
177 | 177 | return "Ready" |
178 | 178 | } |
179 | 179 | return "Needs Rotation" |
180 | 180 | } |
181 | 181 |
|
| 182 | +func isEmptyTLSInfo(t swarm.TLSInfo) bool { |
| 183 | + return t.TrustRoot == "" && len(t.CertIssuerSubject) == 0 && len(t.CertIssuerPublicKey) == 0 |
| 184 | +} |
| 185 | + |
| 186 | +func equalTLSInfo(t, o swarm.TLSInfo) bool { |
| 187 | + return t.TrustRoot == o.TrustRoot && bytes.Equal(t.CertIssuerSubject, o.CertIssuerSubject) && bytes.Equal(t.CertIssuerPublicKey, o.CertIssuerPublicKey) |
| 188 | +} |
| 189 | + |
182 | 190 | func (c *nodeContext) EngineVersion() string { |
183 | 191 | return c.n.Description.Engine.EngineVersion |
184 | 192 | } |
@@ -320,8 +328,7 @@ func (ctx *nodeInspectContext) EngineVersion() string { |
320 | 328 | } |
321 | 329 |
|
322 | 330 | func (ctx *nodeInspectContext) HasTLSInfo() bool { |
323 | | - tlsInfo := ctx.Node.Description.TLSInfo |
324 | | - return !reflect.DeepEqual(tlsInfo, swarm.TLSInfo{}) |
| 331 | + return !isEmptyTLSInfo(ctx.Node.Description.TLSInfo) |
325 | 332 | } |
326 | 333 |
|
327 | 334 | func (ctx *nodeInspectContext) TLSInfoTrustRoot() string { |
|
0 commit comments