本文整理匯總了Golang中github.com/evergreen-ci/evergreen/model.Project.FindTasksForVariant方法的典型用法代碼示例。如果您正苦於以下問題:Golang Project.FindTasksForVariant方法的具體用法?Golang Project.FindTasksForVariant怎麽用?Golang Project.FindTasksForVariant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/evergreen-ci/evergreen/model.Project
的用法示例。
在下文中一共展示了Project.FindTasksForVariant方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getDeps
// getDeps returns all recursive dependencies of task and their variants.
// If task has a non-patchable dependency, getDeps will return TaskNotPatchableError
// The returned slices may contain duplicates.
func getDeps(task string, variant string, p *model.Project) ([]string, []string, error) {
projectTask := p.FindTaskForVariant(task, variant)
if projectTask == nil {
return nil, nil, fmt.Errorf("Task not found in project: %v", task)
}
if patchable := projectTask.Patchable; (patchable != nil && !*patchable) || task == evergreen.PushStage { //TODO remove PushStage
return nil, nil, TaskNotPatchableError
}
deps := make([]string, 0)
variants := make([]string, 0)
for _, dep := range projectTask.DependsOn {
if dep.Variant == model.AllVariants {
if dep.Name == model.AllDependencies {
// Case: name = *, variant = *
for _, v := range p.FindAllVariants() {
variants = append(variants, v)
for _, t := range p.FindTasksForVariant(v) {
if t == task && v == variant {
continue
}
if depTask := p.FindTaskForVariant(t, v); t == evergreen.PushStage ||
(depTask.Patchable != nil && !*depTask.Patchable) {
return nil, nil, TaskNotPatchableError // TODO remove PushStage
}
deps = append(deps, t)
}
}
} else {
// Case: variant = *, specific name
deps = append(deps, dep.Name)
for _, v := range p.FindAllVariants() {
for _, t := range p.FindTasksForVariant(v) {
if t == dep.Name {
if t == task && v == variant {
continue
}
recDeps, recVariants, err := getDeps(t, v, p)
if err != nil {
return nil, nil, err
}
deps = append(deps, recDeps...)
variants = append(variants, v)
variants = append(variants, recVariants...)
}
}
}
}
} else {
if dep.Name == model.AllDependencies {
// Case: name = *, specific variant
v := dep.Variant
if v == "" {
v = variant
}
variants = append(variants, v)
for _, t := range p.FindTasksForVariant(v) {
if t == task && v == variant {
continue
}
recDeps, recVariants, err := getDeps(t, v, p)
if err != nil {
return nil, nil, err
}
deps = append(deps, t)
deps = append(deps, recDeps...)
variants = append(variants, recVariants...)
}
} else {
// Case: specific name, specific variant
v := dep.Variant
if v == "" {
v = variant
}
recDeps, recVariants, err := getDeps(dep.Name, v, p)
if err != nil {
return nil, nil, err
}
deps = append(deps, dep.Name)
deps = append(deps, recDeps...)
variants = append(variants, v)
variants = append(variants, recVariants...)
}
}
}
return deps, variants, nil
}