Skip to content

Commit e88b193

Browse files
committed
service/progress: newReplicatedJobProgressUpdater: slight cleanup
Use intermediate vars, so that the replicatedJobProgressUpdater can be created in one go intead of setting some fields after the fact. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 4771aba commit e88b193

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

cli/command/service/progress/progress.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,16 +573,17 @@ type replicatedJobProgressUpdater struct {
573573
}
574574

575575
func newReplicatedJobProgressUpdater(service swarm.Service, progressOut progress.Output) *replicatedJobProgressUpdater {
576-
u := &replicatedJobProgressUpdater{
577-
progressOut: progressOut,
578-
concurrent: int(*service.Spec.Mode.ReplicatedJob.MaxConcurrent),
579-
total: int(*service.Spec.Mode.ReplicatedJob.TotalCompletions),
580-
jobIteration: service.JobStatus.JobIteration.Index,
581-
}
582-
u.progressDigits = len(strconv.Itoa(u.total))
583-
u.activeDigits = len(strconv.Itoa(u.concurrent))
576+
concurrent := int(*service.Spec.Mode.ReplicatedJob.MaxConcurrent)
577+
total := int(*service.Spec.Mode.ReplicatedJob.TotalCompletions)
584578

585-
return u
579+
return &replicatedJobProgressUpdater{
580+
progressOut: progressOut,
581+
concurrent: concurrent,
582+
total: total,
583+
jobIteration: service.JobStatus.JobIteration.Index,
584+
progressDigits: len(strconv.Itoa(total)),
585+
activeDigits: len(strconv.Itoa(concurrent)),
586+
}
586587
}
587588

588589
// update writes out the progress of the replicated job.

0 commit comments

Comments
 (0)