本文整理匯總了Golang中github.com/evergreen-ci/evergreen/model.Project.GetVariantMappings方法的典型用法代碼示例。如果您正苦於以下問題:Golang Project.GetVariantMappings方法的具體用法?Golang Project.GetVariantMappings怎麽用?Golang Project.GetVariantMappings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/evergreen-ci/evergreen/model.Project
的用法示例。
在下文中一共展示了Project.GetVariantMappings方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getVersionsAndVariants
// Fetch versions until 'numVersionElements' elements are created, including
// elements consisting of multiple versions rolled-up into one.
// The skip value indicates how many versions back in time should be skipped
// before starting to fetch versions, the project indicates which project the
// returned versions should be a part of.
func getVersionsAndVariants(skip, numVersionElements int, project *model.Project) (versionVariantData, error) {
// the final array of versions to return
finalVersions := []waterfallVersion{}
// keep track of the build variants we see
bvSet := map[string]bool{}
waterfallRows := map[string]waterfallRow{}
// build variant mappings - used so we can store the display name as
// the build variant field of a build
buildVariantMappings := project.GetVariantMappings()
// keep track of the last rolled-up version, so inactive versions can
// be added
var lastRolledUpVersion *waterfallVersion = nil
// loop until we have enough from the db
for len(finalVersions) < numVersionElements {
// fetch the versions and associated builds
versionsFromDB, buildsByVersion, err :=
fetchVersionsAndAssociatedBuilds(project, skip, numVersionElements)
if err != nil {
return versionVariantData{}, fmt.Errorf("error fetching versions and builds:"+
" %v", err)
}
// if we've reached the beginning of all versions
if len(versionsFromDB) == 0 {
break
}
// to fetch started tasks and failed tests for providing additional context
// in a tooltip
failedAndStartedTaskIds := []string{}
// update the amount skipped
skip += len(versionsFromDB)
// create the necessary versions, rolling up inactive ones
for _, versionFromDB := range versionsFromDB {
// if we have hit enough versions, break out
if len(finalVersions) == numVersionElements {
break
}
// the builds for the version
buildsInVersion := buildsByVersion[versionFromDB.Id]
// see if there are any active tasks in the version
versionActive := anyActiveTasks(buildsInVersion)
// add any represented build variants to the set and initialize rows
for _, b := range buildsInVersion {
bvSet[b.BuildVariant] = true
buildVariant := waterfallBuildVariant{
Id: b.BuildVariant,
DisplayName: buildVariantMappings[b.BuildVariant],
}
if buildVariant.DisplayName == "" {
buildVariant.DisplayName = b.BuildVariant +
" (removed)"
}
if _, ok := waterfallRows[b.BuildVariant]; !ok {
waterfallRows[b.BuildVariant] = waterfallRow{
Builds: map[string]waterfallBuild{},
BuildVariant: buildVariant,
}
}
}
// if it is inactive, roll up the version and don't create any
// builds for it
if !versionActive {
if lastRolledUpVersion == nil {
lastRolledUpVersion = &waterfallVersion{RolledUp: true, RevisionOrderNumber: versionFromDB.RevisionOrderNumber}
}
// add the version metadata into the last rolled-up version
lastRolledUpVersion.Ids = append(lastRolledUpVersion.Ids,
versionFromDB.Id)
lastRolledUpVersion.Authors = append(lastRolledUpVersion.Authors,
versionFromDB.Author)
lastRolledUpVersion.Errors = append(
lastRolledUpVersion.Errors, waterfallVersionError{versionFromDB.Errors})
lastRolledUpVersion.Warnings = append(
lastRolledUpVersion.Warnings, waterfallVersionError{versionFromDB.Warnings})
lastRolledUpVersion.Messages = append(
//.........這裏部分代碼省略.........
示例2: getVersionsAndVariants
// Fetch versions until 'numVersionElements' elements are created, including
// elements consisting of multiple versions rolled-up into one.
// The skip value indicates how many versions back in time should be skipped
// before starting to fetch versions, the project indicates which project the
// returned versions should be a part of.
func getVersionsAndVariants(skip int, numVersionElements int, project *model.Project) ([]waterfallVersion, []string, error) {
// the final array of versions to return
finalVersions := []waterfallVersion{}
// keep track of the build variants we see
bvSet := map[string]bool{}
// build variant mappings - used so we can store the display name as
// the build variant field of a build
buildVariantMappings := project.GetVariantMappings()
// keep track of the last rolled-up version, so inactive versions can
// be added
var lastRolledUpVersion *waterfallVersion = nil
// loop until we have enough from the db
for len(finalVersions) < numVersionElements {
// fetch the versions and associated builds
versionsFromDB, buildsByVersion, err :=
fetchVersionsAndAssociatedBuilds(project, skip, numVersionElements)
if err != nil {
return nil, nil, fmt.Errorf("error fetching versions and builds:"+
" %v", err)
}
// if we've reached the beginning of all versions
if len(versionsFromDB) == 0 {
break
}
// update the amount skipped
skip += len(versionsFromDB)
// create the necessary versions, rolling up inactive ones
for _, version := range versionsFromDB {
// if we have hit enough versions, break out
if len(finalVersions) == numVersionElements {
break
}
// the builds for the version
buildsInVersion := buildsByVersion[version.Id]
// see if there are any active tasks in the version
versionActive := anyActiveTasks(buildsInVersion)
// add any represented build variants to the set
for _, build := range buildsInVersion {
bvSet[build.BuildVariant] = true
}
// if it is inactive, roll up the version and don't create any
// builds for it
if !versionActive {
if lastRolledUpVersion == nil {
lastRolledUpVersion = &waterfallVersion{RolledUp: true}
}
// add the version metadata into the last rolled-up version
lastRolledUpVersion.Ids = append(lastRolledUpVersion.Ids,
version.Id)
lastRolledUpVersion.Authors = append(lastRolledUpVersion.Authors,
version.Author)
lastRolledUpVersion.Errors = append(
lastRolledUpVersion.Errors, waterfallVersionError{version.Errors})
lastRolledUpVersion.Warnings = append(
lastRolledUpVersion.Warnings, waterfallVersionError{version.Warnings})
lastRolledUpVersion.Messages = append(
lastRolledUpVersion.Messages, version.Message)
lastRolledUpVersion.CreateTimes = append(
lastRolledUpVersion.CreateTimes, version.CreateTime)
lastRolledUpVersion.Revisions = append(
lastRolledUpVersion.Revisions, version.Revision)
// move on to the next version
continue
}
// add a pending rolled-up version, if it exists
if lastRolledUpVersion != nil {
finalVersions = append(finalVersions, *lastRolledUpVersion)
lastRolledUpVersion = nil
}
// if we have hit enough versions, break out
if len(finalVersions) == numVersionElements {
break
}
// if the version can not be rolled up, create a fully fledged
// version for it
activeVersion := waterfallVersion{
//.........這裏部分代碼省略.........