code complexity of NewPlanExecutor
Signed-off-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
60be2d67c1
commit
9651992584
2 changed files with 15 additions and 9 deletions
|
@ -137,6 +137,20 @@ func (wp *workflowPlanner) GetEvents() []string {
|
||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaxRunNameLen determines the max name length of all jobs
|
||||||
|
func (p *Plan) MaxRunNameLen() int {
|
||||||
|
maxRunNameLen := 0
|
||||||
|
for _, stage := range p.Stages {
|
||||||
|
for _, run := range stage.Runs {
|
||||||
|
runNameLen := len(run.String())
|
||||||
|
if runNameLen > maxRunNameLen {
|
||||||
|
maxRunNameLen = runNameLen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxRunNameLen
|
||||||
|
}
|
||||||
|
|
||||||
// GetJobIDs will get all the job names in the stage
|
// GetJobIDs will get all the job names in the stage
|
||||||
func (s *Stage) GetJobIDs() []string {
|
func (s *Stage) GetJobIDs() []string {
|
||||||
names := make([]string, 0)
|
names := make([]string, 0)
|
||||||
|
|
|
@ -50,15 +50,7 @@ func New(runnerConfig *Config) (Runner, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||||
maxJobNameLen := 0
|
maxJobNameLen := plan.MaxRunNameLen()
|
||||||
for _, stage := range plan.Stages {
|
|
||||||
for _, run := range stage.Runs {
|
|
||||||
jobNameLen := len(run.String())
|
|
||||||
if jobNameLen > maxJobNameLen {
|
|
||||||
maxJobNameLen = jobNameLen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pipeline := make([]common.Executor, 0)
|
pipeline := make([]common.Executor, 0)
|
||||||
for _, stage := range plan.Stages {
|
for _, stage := range plan.Stages {
|
||||||
|
|
Loading…
Reference in a new issue