@@ -72,7 +72,7 @@ func terminalState(state swarm.TaskState) bool {
7272//
7373//nolint:gocyclo
7474func ServiceProgress (ctx context.Context , apiClient client.APIClient , serviceID string , progressWriter io.WriteCloser ) error {
75- defer progressWriter .Close ()
75+ defer func () { _ = progressWriter .Close () } ()
7676
7777 progressOut := streamformatter .NewJSONProgressOutput (progressWriter , false )
7878
@@ -118,7 +118,7 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
118118 return fmt .Errorf ("service update paused: %s" , res .Service .UpdateStatus .Message )
119119 case swarm .UpdateStateRollbackStarted :
120120 if ! rollback && res .Service .UpdateStatus .Message != "" {
121- progressOut .WriteProgress (progress.Progress {
121+ _ = progressOut .WriteProgress (progress.Progress {
122122 ID : "rollback" ,
123123 Action : res .Service .UpdateStatus .Message ,
124124 })
@@ -169,7 +169,7 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
169169 // use the presence of this field to check if the service is a job
170170 // here.
171171 if res .Service .JobStatus != nil {
172- progress .Message ( progressOut , "" , " job complete" )
172+ _ = progressOut . WriteProgress ( progress.Progress { Message : " job complete"} )
173173 return nil
174174 }
175175
@@ -205,8 +205,8 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
205205 case <- time .After (200 * time .Millisecond ):
206206 case <- sigint :
207207 if ! converged {
208- progress .Message ( progressOut , "" , " Operation continuing in background." )
209- progress . Messagef ( progressOut , "" , " Use `docker service ps %s` to check progress." , serviceID )
208+ _ = progressOut . WriteProgress ( progress.Progress { Message : " Operation continuing in background."} )
209+ _ = progressOut . WriteProgress (progress. Progress { Message : fmt . Sprintf ( " Use `docker service ps %s` to check progress." , serviceID )} )
210210 }
211211 return nil
212212 }
@@ -255,13 +255,13 @@ func initializeUpdater(service swarm.Service, progressOut progress.Output) (prog
255255
256256func writeOverallProgress (progressOut progress.Output , numerator , denominator int , rollback bool ) {
257257 if rollback {
258- progressOut .WriteProgress (progress.Progress {
258+ _ = progressOut .WriteProgress (progress.Progress {
259259 ID : "overall progress" ,
260260 Action : fmt .Sprintf ("rolling back update: %d out of %d tasks" , numerator , denominator ),
261261 })
262262 return
263263 }
264- progressOut .WriteProgress (progress.Progress {
264+ _ = progressOut .WriteProgress (progress.Progress {
265265 ID : "overall progress" ,
266266 Action : fmt .Sprintf ("%d out of %d tasks" , numerator , denominator ),
267267 })
@@ -305,7 +305,10 @@ func (u *replicatedProgressUpdater) update(service swarm.Service, tasks []swarm.
305305
306306 if replicas <= maxProgressBars {
307307 for i := uint64 (1 ); i <= replicas ; i ++ {
308- progress .Update (u .progressOut , fmt .Sprintf ("%d/%d" , i , replicas ), " " )
308+ _ = u .progressOut .WriteProgress (progress.Progress {
309+ ID : fmt .Sprintf ("%d/%d" , i , replicas ),
310+ Action : " " ,
311+ })
309312 }
310313 }
311314 u .initialized = true
@@ -388,15 +391,15 @@ func (u *replicatedProgressUpdater) writeTaskProgress(task swarm.Task, mappedSlo
388391 }
389392
390393 if task .Status .Err != "" {
391- u .progressOut .WriteProgress (progress.Progress {
394+ _ = u .progressOut .WriteProgress (progress.Progress {
392395 ID : fmt .Sprintf ("%d/%d" , mappedSlot , replicas ),
393396 Action : truncError (task .Status .Err ),
394397 })
395398 return
396399 }
397400
398401 if ! terminalState (task .DesiredState ) && ! terminalState (task .Status .State ) {
399- u .progressOut .WriteProgress (progress.Progress {
402+ _ = u .progressOut .WriteProgress (progress.Progress {
400403 ID : fmt .Sprintf ("%d/%d" , mappedSlot , replicas ),
401404 Action : fmt .Sprintf ("%-[1]*s" , longestState , task .Status .State ),
402405 Current : numberedStates [task .Status .State ],
@@ -427,7 +430,7 @@ func (u *globalProgressUpdater) update(_ swarm.Service, tasks []swarm.Task, acti
427430 // Two possibilities: either the orchestrator hasn't created
428431 // the tasks yet, or the service doesn't meet constraints for
429432 // any node. Either way, we wait.
430- u .progressOut .WriteProgress (progress.Progress {
433+ _ = u .progressOut .WriteProgress (progress.Progress {
431434 ID : "overall progress" ,
432435 Action : "waiting for new tasks" ,
433436 })
@@ -505,15 +508,15 @@ func (u *globalProgressUpdater) writeTaskProgress(task swarm.Task, nodeCount int
505508 }
506509
507510 if task .Status .Err != "" {
508- u .progressOut .WriteProgress (progress.Progress {
511+ _ = u .progressOut .WriteProgress (progress.Progress {
509512 ID : formatter .TruncateID (task .NodeID ),
510513 Action : truncError (task .Status .Err ),
511514 })
512515 return
513516 }
514517
515518 if ! terminalState (task .DesiredState ) && ! terminalState (task .Status .State ) {
516- u .progressOut .WriteProgress (progress.Progress {
519+ _ = u .progressOut .WriteProgress (progress.Progress {
517520 ID : formatter .TruncateID (task .NodeID ),
518521 Action : fmt .Sprintf ("%-[1]*s" , longestState , task .Status .State ),
519522 Current : numberedStates [task .Status .State ],
@@ -593,7 +596,7 @@ func (u *replicatedJobProgressUpdater) update(_ swarm.Service, tasks []swarm.Tas
593596 // only write out progress bars if there will be less than the maximum
594597 if u .total <= maxProgressBars {
595598 for i := 1 ; i <= u .total ; i ++ {
596- u .progressOut .WriteProgress (progress.Progress {
599+ _ = u .progressOut .WriteProgress (progress.Progress {
597600 ID : fmt .Sprintf ("%d/%d" , i , u .total ),
598601 Action : " " ,
599602 })
0 commit comments