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>
This commit is contained in:
parent
4771abac9e
commit
e88b1939f7
@ -573,16 +573,17 @@ type replicatedJobProgressUpdater struct {
|
||||
}
|
||||
|
||||
func newReplicatedJobProgressUpdater(service swarm.Service, progressOut progress.Output) *replicatedJobProgressUpdater {
|
||||
u := &replicatedJobProgressUpdater{
|
||||
progressOut: progressOut,
|
||||
concurrent: int(*service.Spec.Mode.ReplicatedJob.MaxConcurrent),
|
||||
total: int(*service.Spec.Mode.ReplicatedJob.TotalCompletions),
|
||||
jobIteration: service.JobStatus.JobIteration.Index,
|
||||
}
|
||||
u.progressDigits = len(strconv.Itoa(u.total))
|
||||
u.activeDigits = len(strconv.Itoa(u.concurrent))
|
||||
concurrent := int(*service.Spec.Mode.ReplicatedJob.MaxConcurrent)
|
||||
total := int(*service.Spec.Mode.ReplicatedJob.TotalCompletions)
|
||||
|
||||
return u
|
||||
return &replicatedJobProgressUpdater{
|
||||
progressOut: progressOut,
|
||||
concurrent: concurrent,
|
||||
total: total,
|
||||
jobIteration: service.JobStatus.JobIteration.Index,
|
||||
progressDigits: len(strconv.Itoa(total)),
|
||||
activeDigits: len(strconv.Itoa(concurrent)),
|
||||
}
|
||||
}
|
||||
|
||||
// update writes out the progress of the replicated job.
|
||||
|
Loading…
x
Reference in New Issue
Block a user