MCPcopy Index your code
hub / github.com/docker/cli / updateProgress

Function updateProgress

cli/command/swarm/progress/root_rotation.go:75–121  ·  view source on GitHub ↗
(progressOut progress.Output, desiredTLSInfo swarm.TLSInfo, nodes []swarm.Node, rootRotationInProgress bool)

Source from the content-addressed store, hash-verified

73}
74
75func updateProgress(progressOut progress.Output, desiredTLSInfo swarm.TLSInfo, nodes []swarm.Node, rootRotationInProgress bool) bool {
76 // write the current desired root cert's digest, because the desired root certs might be too long
77 _ = progressOut.WriteProgress(progress.Progress{
78 ID: "desired root digest",
79 Action: digest.FromBytes([]byte(desiredTLSInfo.TrustRoot)).String(),
80 })
81
82 // If we had reached a converged state, check if we are still converged.
83 var certsRight, trustRootsRight int64
84 for _, n := range nodes {
85 if bytes.Equal(n.Description.TLSInfo.CertIssuerPublicKey, desiredTLSInfo.CertIssuerPublicKey) &&
86 bytes.Equal(n.Description.TLSInfo.CertIssuerSubject, desiredTLSInfo.CertIssuerSubject) {
87 certsRight++
88 }
89
90 if n.Description.TLSInfo.TrustRoot == desiredTLSInfo.TrustRoot {
91 trustRootsRight++
92 }
93 }
94
95 total := int64(len(nodes))
96 _ = progressOut.WriteProgress(progress.Progress{
97 ID: certsRotatedStr,
98 Action: certsAction,
99 Current: certsRight,
100 Total: total,
101 Units: "nodes",
102 })
103
104 rootsProgress := progress.Progress{
105 ID: rootsRotatedStr,
106 Action: rootsAction,
107 Current: trustRootsRight,
108 Total: total,
109 Units: "nodes",
110 }
111
112 if certsRight == total && !rootRotationInProgress {
113 _ = progressOut.WriteProgress(rootsProgress)
114 return certsRight == total && trustRootsRight == total
115 }
116
117 // we still have certs that need renewing, so display that there are zero roots rotated yet
118 rootsProgress.Current = 0
119 _ = progressOut.WriteProgress(rootsProgress)
120 return false
121}

Callers 1

RootRotationProgressFunction · 0.85

Calls 2

StringMethod · 0.65
WriteProgressMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…