本文整理汇总了Golang中github.com/evergreen-ci/evergreen/model/version.FindOne函数的典型用法代码示例。如果您正苦于以下问题:Golang FindOne函数的具体用法?Golang FindOne怎么用?Golang FindOne使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FindOne函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: FindProject
func FindProject(revision string, projectRef *ProjectRef) (*Project, error) {
if projectRef == nil {
return nil, fmt.Errorf("projectRef given is nil")
}
if projectRef.Identifier == "" {
return nil, fmt.Errorf("Invalid project with blank identifier")
}
project := &Project{}
project.Identifier = projectRef.Identifier
// when the revision is empty we find the last known good configuration from the versions
// If the last known good configuration does not exist,
// load the configuration from the local config in the project ref.
if revision == "" {
lastGoodVersion, err := version.FindOne(version.ByLastKnownGoodConfig(projectRef.Identifier))
if err != nil {
return nil, fmt.Errorf("Error finding recent valid version for %v: %v", projectRef.Identifier, err)
}
if lastGoodVersion != nil {
// for new repositories, we don't want to error out when we don't have
// any versions stored in the database so we default to the skeletal
// information we already have from the project file on disk
err = LoadProjectInto([]byte(lastGoodVersion.Config), projectRef.Identifier, project)
if err != nil {
return nil, fmt.Errorf("Error loading project from "+
"last good version for project, %v: %v", lastGoodVersion.Identifier, err)
}
} else {
// Check to see if there is a local configuration in the project ref
if projectRef.LocalConfig != "" {
err = LoadProjectInto([]byte(projectRef.LocalConfig), projectRef.Identifier, project)
if err != nil {
return nil, fmt.Errorf("Error loading local config for project ref, %v : %v", projectRef.Identifier, err)
}
}
}
}
if revision != "" {
// we immediately return an error if the repotracker version isn't found
// for the given project at the given revision
version, err := version.FindOne(version.ByProjectIdAndRevision(projectRef.Identifier, revision))
if err != nil {
return nil, fmt.Errorf("error fetching version for project %v revision %v: %v", projectRef.Identifier, revision, err)
}
if version == nil {
// fall back to the skeletal project
return project, nil
}
project = &Project{}
if err = LoadProjectInto([]byte(version.Config), projectRef.Identifier, project); err != nil {
return nil, fmt.Errorf("Error loading project from version: %v", err)
}
}
return project, nil
}
开发者ID:bjori,项目名称:evergreen,代码行数:57,代码来源:project.go
示例2: TestLastKnownGoodConfig
func TestLastKnownGoodConfig(t *testing.T) {
Convey("When calling LastKnownGoodConfig..", t, func() {
identifier := "identifier"
Convey("no versions should be returned if there're no good "+
"last known configurations", func() {
v := &version.Version{
Identifier: identifier,
Requester: evergreen.RepotrackerVersionRequester,
Errors: []string{"error 1", "error 2"},
}
testutil.HandleTestingErr(v.Insert(), t, "Error inserting test version: %v")
lastGood, err := version.FindOne(version.ByLastKnownGoodConfig(identifier))
testutil.HandleTestingErr(err, t, "error finding last known good: %v")
So(lastGood, ShouldBeNil)
})
Convey("a version should be returned if there is a last known good configuration", func() {
v := &version.Version{
Identifier: identifier,
Requester: evergreen.RepotrackerVersionRequester,
}
testutil.HandleTestingErr(v.Insert(), t, "Error inserting test version: %v")
lastGood, err := version.FindOne(version.ByLastKnownGoodConfig(identifier))
testutil.HandleTestingErr(err, t, "error finding last known good: %v")
So(lastGood, ShouldNotBeNil)
})
Convey("most recent version should be found if there are several recent good configs", func() {
v := &version.Version{
Id: "1",
Identifier: identifier,
Requester: evergreen.RepotrackerVersionRequester,
RevisionOrderNumber: 1,
Config: "1",
}
testutil.HandleTestingErr(v.Insert(), t, "Error inserting test version: %v")
v.Id = "5"
v.RevisionOrderNumber = 5
v.Config = "5"
testutil.HandleTestingErr(v.Insert(), t, "Error inserting test version: %v")
v.Id = "2"
v.RevisionOrderNumber = 2
v.Config = "2"
testutil.HandleTestingErr(v.Insert(), t, "Error inserting test version: %v")
lastGood, err := version.FindOne(version.ByLastKnownGoodConfig(identifier))
testutil.HandleTestingErr(err, t, "error finding last known good: %v")
So(lastGood, ShouldNotBeNil)
So(lastGood.Config, ShouldEqual, "5")
})
Reset(func() {
db.Clear(version.Collection)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:52,代码来源:version_test.go
示例3: getTasksForLatestVersion
// getTasksForLatestVersion sends back the TaskJSON data associated with the latest version.
func getTasksForLatestVersion(w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"]
var jsonTask TaskJSON
projects := []string{}
err := util.ReadJSONInto(r.Body, &projects)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
versionData := []VersionData{}
for _, project := range projects {
err := db.FindOneQ(collection, db.Query(bson.M{NameKey: name,
ProjectIdKey: project}).Sort([]string{"-" + RevisionOrderNumberKey}).WithFields(VersionIdKey), &jsonTask)
if err != nil {
if err != mgo.ErrNotFound {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.Error(w, "{}", http.StatusNotFound)
return
}
if jsonTask.VersionId == "" {
http.Error(w, "{}", http.StatusNotFound)
}
jsonTasks, err := findTasksForVersion(jsonTask.VersionId, name)
if jsonTasks == nil {
http.Error(w, "{}", http.StatusNotFound)
return
}
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// get the version commit info
v, err := version.FindOne(version.ById(jsonTask.VersionId))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if v == nil {
http.Error(w, "{}", http.StatusNotFound)
return
}
commitInfo := CommitInfo{
Author: v.Author,
Message: v.Message,
CreateTime: v.CreateTime,
Revision: v.Revision,
VersionId: jsonTask.VersionId,
}
versionData = append(versionData, VersionData{jsonTasks, commitInfo})
}
plugin.WriteJSON(w, http.StatusOK, versionData)
}
开发者ID:sr527,项目名称:evg-json,代码行数:61,代码来源:version.go
示例4: populatePatch
// populatePatch loads a patch into the project context, using patchId if provided.
// If patchId is blank, will try to infer the patch ID from the version already loaded
// into context, if available.
func (pc *projectContext) populatePatch(patchId string) error {
var err error
if len(patchId) > 0 {
// The patch is explicitly identified in the URL, so fetch it
if !patch.IsValidId(patchId) {
return fmt.Errorf("patch id '%v' is not an object id", patchId)
}
pc.Patch, err = patch.FindOne(patch.ById(patch.NewId(patchId)).Project(patch.ExcludePatchDiff))
} else if pc.Version != nil {
// patch isn't in URL but the version in context has one, get it
pc.Patch, err = patch.FindOne(patch.ByVersion(pc.Version.Id).Project(patch.ExcludePatchDiff))
}
if err != nil {
return err
}
// If there's a finalized patch loaded into context but not a version, load the version
// associated with the patch as the context's version.
if pc.Version == nil && pc.Patch != nil && pc.Patch.Version != "" {
pc.Version, err = version.FindOne(version.ById(pc.Patch.Version))
if err != nil {
return err
}
}
return nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:29,代码来源:middleware.go
示例5: getVersionInfo
// Returns a JSON response with the marshalled output of the version
// specified in the request.
func (restapi restAPI) getVersionInfo(w http.ResponseWriter, r *http.Request) {
versionId := mux.Vars(r)["version_id"]
srcVersion, err := version.FindOne(version.ById(versionId))
if err != nil || srcVersion == nil {
msg := fmt.Sprintf("Error finding version '%v'", versionId)
statusCode := http.StatusNotFound
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "%v: %v", msg, err)
statusCode = http.StatusInternalServerError
}
restapi.WriteJSON(w, statusCode, responseError{Message: msg})
return
}
destVersion := &restVersion{}
// Copy the contents from the database into our local version type
err = angier.TransferByFieldNames(srcVersion, destVersion)
if err != nil {
msg := fmt.Sprintf("Error finding version '%v'", versionId)
evergreen.Logger.Logf(slogger.ERROR, "%v: %v", msg, err)
restapi.WriteJSON(w, http.StatusInternalServerError, responseError{Message: msg})
return
}
for _, buildStatus := range srcVersion.BuildVariants {
destVersion.BuildVariants = append(destVersion.BuildVariants, buildStatus.BuildVariant)
evergreen.Logger.Logf(slogger.ERROR, "adding BuildVariant %v", buildStatus.BuildVariant)
}
restapi.WriteJSON(w, http.StatusOK, destVersion)
return
}
开发者ID:MauroJr,项目名称:evergreen,代码行数:37,代码来源:version.go
示例6: TryMarkPatchBuildFinished
// TryMarkPatchBuildFinished attempts to mark a patch as finished if all
// the builds for the patch are finished as well
func TryMarkPatchBuildFinished(b *build.Build, finishTime time.Time) error {
v, err := version.FindOne(version.ById(b.Version))
if err != nil {
return err
}
if v == nil {
return fmt.Errorf("Cannot find version for build %v with version %v", b.Id, b.Version)
}
// ensure all builds for this patch are finished as well
builds, err := build.Find(build.ByIds(v.BuildIds).WithFields(build.StatusKey))
if err != nil {
return err
}
patchCompleted := true
status := evergreen.PatchSucceeded
for _, build := range builds {
if !build.IsFinished() {
patchCompleted = false
}
if build.Status != evergreen.BuildSucceeded {
status = evergreen.PatchFailed
}
}
// nothing to do if the patch isn't completed
if !patchCompleted {
return nil
}
return patch.TryMarkFinished(v.Id, finishTime, status)
}
开发者ID:pritten,项目名称:evergreen,代码行数:35,代码来源:lifecycle.go
示例7: GetManifest
func (m *ManifestPlugin) GetManifest(w http.ResponseWriter, r *http.Request) {
project := mux.Vars(r)["project_id"]
revision := mux.Vars(r)["revision"]
version, err := version.FindOne(version.ByProjectIdAndRevision(project, revision))
if err != nil {
http.Error(w, fmt.Sprintf("error getting version for project %v with revision %v: %v",
project, revision, err), http.StatusBadRequest)
return
}
if version == nil {
http.Error(w, fmt.Sprintf("version not found for project %v, with revision %v", project, revision),
http.StatusNotFound)
return
}
foundManifest, err := manifest.FindOne(manifest.ById(version.Id))
if err != nil {
http.Error(w, fmt.Sprintf("error getting manifest with version id %v: %v",
version.Id, err), http.StatusBadRequest)
return
}
if foundManifest == nil {
http.Error(w, fmt.Sprintf("manifest not found for version %v", version.Id), http.StatusNotFound)
return
}
plugin.WriteJSON(w, http.StatusOK, foundManifest)
return
}
开发者ID:tychoish,项目名称:evergreen,代码行数:30,代码来源:manifest_plugin.go
示例8: getVersionInfoViaRevision
// Returns a JSON response with the marshalled output of the version
// specified by its revision and project name in the request.
func (restapi restAPI) getVersionInfoViaRevision(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
projectId := vars["project_id"]
revision := vars["revision"]
srcVersion, err := version.FindOne(version.ByProjectIdAndRevision(projectId, revision))
if err != nil || srcVersion == nil {
msg := fmt.Sprintf("Error finding revision '%v' for project '%v'", revision, projectId)
statusCode := http.StatusNotFound
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "%v: %v", msg, err)
statusCode = http.StatusInternalServerError
}
restapi.WriteJSON(w, statusCode, responseError{Message: msg})
return
}
destVersion := &restVersion{}
copyVersion(srcVersion, destVersion)
for _, buildStatus := range srcVersion.BuildVariants {
destVersion.BuildVariants = append(destVersion.BuildVariants, buildStatus.BuildVariant)
evergreen.Logger.Logf(slogger.ERROR, "adding BuildVariant %v", buildStatus.BuildVariant)
}
restapi.WriteJSON(w, http.StatusOK, destVersion)
return
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:33,代码来源:rest_version.go
示例9: createVersionItems
// createVersionItems populates and stores all the tasks and builds for a version according to
// the given project config.
func createVersionItems(v *version.Version, ref *model.ProjectRef, project *model.Project) error {
for _, buildvariant := range project.BuildVariants {
if buildvariant.Disabled {
continue
}
buildId, err := model.CreateBuildFromVersion(project, v, buildvariant.Name, false, nil)
if err != nil {
return err
}
lastActivated, err := version.FindOne(version.ByLastVariantActivation(ref.Identifier, buildvariant.Name))
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Error getting activation time for bv %v", buildvariant.Name)
return err
}
var lastActivation *time.Time
if lastActivated != nil {
for _, buildStatus := range lastActivated.BuildVariants {
if buildStatus.BuildVariant == buildvariant.Name && buildStatus.Activated {
lastActivation = &buildStatus.ActivateAt
break
}
}
}
var activateAt time.Time
var activated bool
if lastActivation == nil {
// if we don't have a last activation time then activate now.
activateAt = time.Now()
activated = true
} else {
activateAt = lastActivation.Add(time.Minute * time.Duration(ref.GetBatchTime(&buildvariant)))
evergreen.Logger.Logf(slogger.INFO, "Going to activate bv %v for project %v, version %v at %v",
buildvariant.Name, ref.Identifier, v.Id, activateAt)
}
v.BuildIds = append(v.BuildIds, buildId)
v.BuildVariants = append(v.BuildVariants, version.BuildStatus{
BuildVariant: buildvariant.Name,
Activated: activated,
ActivateAt: activateAt,
BuildId: buildId,
})
}
if err := v.Insert(); err != nil {
evergreen.Logger.Errorf(slogger.ERROR, "Error inserting version %v: %v", v.Id, err)
for _, buildStatus := range v.BuildVariants {
if buildErr := model.DeleteBuild(buildStatus.BuildId); buildErr != nil {
evergreen.Logger.Errorf(slogger.ERROR, "Error deleting build %v: %v",
buildStatus.BuildId, buildErr)
}
}
return err
}
return nil
}
开发者ID:markbenvenuto,项目名称:evergreen,代码行数:61,代码来源:repotracker.go
示例10: TestUpdateBuildStatusForTask
func TestUpdateBuildStatusForTask(t *testing.T) {
Convey("With two tasks and a build", t, func() {
testutil.HandleTestingErr(db.ClearCollections(task.Collection, build.Collection, version.Collection), t,
"Error clearing task and build collections")
displayName := "testName"
b := &build.Build{
Id: "buildtest",
Status: evergreen.BuildStarted,
Version: "abc",
}
v := &version.Version{
Id: b.Version,
Status: evergreen.VersionStarted,
}
testTask := task.Task{
Id: "testone",
DisplayName: displayName,
Activated: false,
BuildId: b.Id,
Project: "sample",
Status: evergreen.TaskFailed,
}
anotherTask := task.Task{
Id: "two",
DisplayName: displayName,
Activated: true,
BuildId: b.Id,
Project: "sample",
Status: evergreen.TaskFailed,
}
b.Tasks = []build.TaskCache{
{
Id: testTask.Id,
Status: evergreen.TaskSucceeded,
},
{
Id: anotherTask.Id,
Status: evergreen.TaskFailed,
},
}
So(b.Insert(), ShouldBeNil)
So(testTask.Insert(), ShouldBeNil)
So(anotherTask.Insert(), ShouldBeNil)
So(v.Insert(), ShouldBeNil)
Convey("updating the build for a task should update the build's status and the version's status", func() {
So(UpdateBuildAndVersionStatusForTask(testTask.Id), ShouldBeNil)
b, err := build.FindOne(build.ById(b.Id))
So(err, ShouldBeNil)
So(b.Status, ShouldEqual, evergreen.BuildFailed)
v, err := version.FindOne(version.ById(v.Id))
So(v.Status, ShouldEqual, evergreen.VersionFailed)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:57,代码来源:task_lifecycle_test.go
示例11: prependConfigToVersion
// prependConfigToVersion modifies the project config with the given id
func prependConfigToVersion(t *testing.T, versionId, configData string) {
v, err := version.FindOne(version.ById(versionId))
testutil.HandleTestingErr(err, t, "failed to load version")
if v == nil {
err = fmt.Errorf("could not find version to update")
testutil.HandleTestingErr(err, t, "failed to find version")
}
v.Config = configData + v.Config
testutil.HandleTestingErr(dbutil.ClearCollections(version.Collection), t, "couldnt reset version")
testutil.HandleTestingErr(v.Insert(), t, "failed to insert version")
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:12,代码来源:api_integration_test.go
示例12: TestMarkStart
func TestMarkStart(t *testing.T) {
Convey("With a task, build and version", t, func() {
testutil.HandleTestingErr(db.ClearCollections(task.Collection, build.Collection, version.Collection), t,
"Error clearing task and build collections")
displayName := "testName"
b := &build.Build{
Id: "buildtest",
Status: evergreen.BuildCreated,
Version: "abc",
}
v := &version.Version{
Id: b.Version,
Status: evergreen.VersionCreated,
}
testTask := task.Task{
Id: "testTask",
DisplayName: displayName,
Activated: true,
BuildId: b.Id,
Project: "sample",
Status: evergreen.TaskUndispatched,
Version: b.Version,
}
b.Tasks = []build.TaskCache{
{
Id: testTask.Id,
Status: evergreen.TaskUndispatched,
},
}
So(b.Insert(), ShouldBeNil)
So(testTask.Insert(), ShouldBeNil)
So(v.Insert(), ShouldBeNil)
Convey("when calling MarkStart, the task, version and build should be updated", func() {
So(MarkStart(testTask.Id), ShouldBeNil)
testTask, err := task.FindOne(task.ById(testTask.Id))
So(err, ShouldBeNil)
So(testTask.Status, ShouldEqual, evergreen.TaskStarted)
b, err := build.FindOne(build.ById(b.Id))
So(err, ShouldBeNil)
So(b.Status, ShouldEqual, evergreen.BuildStarted)
So(b.Tasks, ShouldNotBeNil)
So(len(b.Tasks), ShouldEqual, 1)
So(b.Tasks[0].Status, ShouldEqual, evergreen.TaskStarted)
v, err := version.FindOne(version.ById(v.Id))
So(err, ShouldBeNil)
So(v.Status, ShouldEqual, evergreen.VersionStarted)
})
})
}
开发者ID:tychoish,项目名称:evergreen,代码行数:50,代码来源:task_lifecycle_test.go
示例13: sanityCheckOrderNum
// Verifies that the given revision order number is higher than the latest number stored for the project.
func sanityCheckOrderNum(revOrderNum int, projectId string) error {
latest, err := version.FindOne(version.ByMostRecentForRequester(projectId, evergreen.RepotrackerVersionRequester))
if err != nil {
return fmt.Errorf("Error getting latest version: %v", err.Error())
}
// When there are no versions in the db yet, sanity check is moot
if latest != nil {
if revOrderNum <= latest.RevisionOrderNumber {
return fmt.Errorf("Commit order number isn't greater than last stored version's: %v <= %v",
revOrderNum, latest.RevisionOrderNumber)
}
}
return nil
}
开发者ID:amidvidy,项目名称:evergreen,代码行数:16,代码来源:repotracker.go
示例14: GetVersion
func (as *APIServer) GetVersion(w http.ResponseWriter, r *http.Request) {
task := MustHaveTask(r)
// Get the version for this task, so we can get its config data
v, err := version.FindOne(version.ById(task.Version))
if err != nil {
as.LoggedError(w, r, http.StatusInternalServerError, err)
return
}
if v == nil {
http.Error(w, "version not found", http.StatusNotFound)
return
}
as.WriteJSON(w, http.StatusOK, v)
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:17,代码来源:api.go
示例15: findProjectBuildVariants
// Construct a map of project names to build variants for that project
func findProjectBuildVariants(configName string) (map[string][]string, error) {
projectNameToBuildVariants := make(map[string][]string)
allProjects, err := model.FindAllTrackedProjectRefs()
if err != nil {
return nil, err
}
for _, projectRef := range allProjects {
if !projectRef.Enabled {
continue
}
var buildVariants []string
var proj *model.Project
var err error
if projectRef.LocalConfig != "" {
proj, err = model.FindProject("", &projectRef)
if err != nil {
return nil, fmt.Errorf("unable to find project file: %v", err)
}
} else {
lastGood, err := version.FindOne(version.ByLastKnownGoodConfig(projectRef.Identifier))
if err != nil {
return nil, fmt.Errorf("unable to find last valid config: %v", err)
}
if lastGood == nil { // brand new project + no valid config yet, just return an empty map
return projectNameToBuildVariants, nil
}
proj = &model.Project{}
err = model.LoadProjectInto([]byte(lastGood.Config), projectRef.Identifier, proj)
if err != nil {
return nil, fmt.Errorf("error loading project '%v' from version: %v", projectRef.Identifier, err)
}
}
for _, buildVariant := range proj.BuildVariants {
buildVariants = append(buildVariants, buildVariant.Name)
}
projectNameToBuildVariants[projectRef.Identifier] = buildVariants
}
return projectNameToBuildVariants, nil
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:46,代码来源:notify.go
示例16: populateTaskBuildVersion
// populateTaskBuildVersion takes a task, build, and version ID and populates a projectContext
// with as many of the task, build, and version documents as possible.
// If any of the provided IDs is blank, they will be inferred from the more selective ones.
// Returns the project ID of the data found, which may be blank if the IDs are empty.
func (pc *projectContext) populateTaskBuildVersion(taskId, buildId, versionId string) (string, error) {
projectId := ""
var err error
// Fetch task if there's a task ID present; if we find one, populate build/version IDs from it
if len(taskId) > 0 {
pc.Task, err = task.FindOne(task.ById(taskId))
if err != nil {
return "", err
}
if pc.Task != nil {
// override build and version ID with the ones this task belongs to
buildId = pc.Task.BuildId
versionId = pc.Task.Version
projectId = pc.Task.Project
}
}
// Fetch build if there's a build ID present; if we find one, populate version ID from it
if len(buildId) > 0 {
pc.Build, err = build.FindOne(build.ById(buildId))
if err != nil {
return "", err
}
if pc.Build != nil {
versionId = pc.Build.Version
projectId = pc.Build.Project
}
}
if len(versionId) > 0 {
pc.Version, err = version.FindOne(version.ById(versionId))
if err != nil {
return "", err
}
if pc.Version != nil {
projectId = pc.Version.Identifier
}
}
return projectId, nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:45,代码来源:middleware.go
示例17: constructChangeInfo
func (self *TaskNotificationHandler) constructChangeInfo(allTasks []task.Task,
key *NotificationKey) ([]ChangeInfo, error) {
changeInfoSlice := make([]ChangeInfo, 0)
for _, task := range allTasks {
// add blamelist information for each task
v, err := version.FindOne(version.ById(task.Version))
if err != nil {
return changeInfoSlice, err
}
if v == nil {
return changeInfoSlice, fmt.Errorf("No version found for task %v with version id %v",
task.Id, task.Version)
}
changeInfo := constructChangeInfo(v, key)
changeInfo.Pushtime = task.PushTime.Format(time.RFC850)
changeInfoSlice = append(changeInfoSlice, *changeInfo)
}
return changeInfoSlice, nil
}
开发者ID:sr527,项目名称:evergreen,代码行数:21,代码来源:task_handler.go
示例18: constructChangeInfo
func (self *BuildNotificationHandler) constructChangeInfo(allBuilds []build.Build,
key *NotificationKey) ([]ChangeInfo, error) {
changeInfoSlice := make([]ChangeInfo, 0)
for _, build := range allBuilds {
// add blamelist information for each build
v, err := version.FindOne(version.ById(build.Version))
if err != nil {
return changeInfoSlice, err
}
if v == nil {
err = fmt.Errorf("No version found for build %v with version id %v",
build.Id, build.Version)
return changeInfoSlice, err
}
changeInfo := constructChangeInfo(v, key)
changeInfo.Pushtime = build.PushTime.Format(time.RFC850)
changeInfoSlice = append(changeInfoSlice, *changeInfo)
}
return changeInfoSlice, nil
}
开发者ID:tychoish,项目名称:evergreen,代码行数:22,代码来源:build_handler.go
示例19: modifyVersionInfo
// Modifies part of the version specified in the request, and returns a
// JSON response with the marshalled output of its new state.
func (restapi restAPI) modifyVersionInfo(w http.ResponseWriter, r *http.Request) {
versionId := mux.Vars(r)["version_id"]
var input struct {
Activated *bool `json:"activated"`
}
json.NewDecoder(r.Body).Decode(&input)
v, err := version.FindOne(version.ById(versionId))
if err != nil || v == nil {
msg := fmt.Sprintf("Error finding version '%v'", versionId)
statusCode := http.StatusNotFound
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "%v: %v", msg, err)
statusCode = http.StatusInternalServerError
}
restapi.WriteJSON(w, statusCode, responseError{Message: msg})
return
}
if input.Activated != nil {
if err = model.SetVersionActivation(v.Id, *input.Activated); err != nil {
state := "inactive"
if *input.Activated {
state = "active"
}
msg := fmt.Sprintf("Error marking version '%v' as %v", versionId, state)
restapi.WriteJSON(w, http.StatusInternalServerError, responseError{Message: msg})
return
}
}
restapi.getVersionInfo(w, r)
}
开发者ID:MauroJr,项目名称:evergreen,代码行数:39,代码来源:version.go
示例20: updateVersionBuildVarMap
// Takes in a version id and a map of "key -> buildvariant" (where "key" is of
// type "versionBuildVariant") and updates the map with an entry for the
// buildvariants associated with "versionStr"
func (self *Scheduler) updateVersionBuildVarMap(versionStr string,
versionBuildVarMap map[versionBuildVariant]model.BuildVariant) (err error) {
version, err := version.FindOne(version.ById(versionStr))
if err != nil {
return
}
if version == nil {
return fmt.Errorf("nil version returned for version id '%v'", versionStr)
}
project := &model.Project{}
err = model.LoadProjectInto([]byte(version.Config), version.Identifier, project)
if err != nil {
return fmt.Errorf("unable to load project config for version %v: "+
"%v", versionStr, err)
}
// create buildvariant map (for accessing purposes)
for _, buildVariant := range project.BuildVariants {
key := versionBuildVariant{versionStr, buildVariant.Name}
versionBuildVarMap[key] = buildVariant
}
return
}
开发者ID:himanshugpt,项目名称:evergreen,代码行数:27,代码来源:scheduler.go
注:本文中的github.com/evergreen-ci/evergreen/model/version.FindOne函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论