• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang build.UpdateActivation函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/evergreen-ci/evergreen/model/build.UpdateActivation函数的典型用法代码示例。如果您正苦于以下问题:Golang UpdateActivation函数的具体用法?Golang UpdateActivation怎么用?Golang UpdateActivation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了UpdateActivation函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: AbortBuild

// AbortBuild sets the abort flag on all tasks associated with the build which are in an abortable
// state, and marks the build as deactivated.
func AbortBuild(buildId string, caller string) error {
	err := task.AbortBuild(buildId)
	if err != nil {
		return err
	}
	return build.UpdateActivation(buildId, false, caller)
}
开发者ID:sr527,项目名称:evergreen,代码行数:9,代码来源:lifecycle.go


示例2: RestartBuild

// RestartBuild restarts completed tasks associated with a given buildId.
// If abortInProgress is true, it also sets the abort flag on any in-progress tasks.
func RestartBuild(buildId string, taskIds []string, abortInProgress bool, caller string) error {
	// restart all the 'not in-progress' tasks for the build
	allTasks, err := FindAllTasks(
		bson.M{
			TaskIdKey:      bson.M{"$in": taskIds},
			TaskBuildIdKey: buildId,
			TaskStatusKey: bson.M{
				"$in": []string{
					evergreen.TaskSucceeded,
					evergreen.TaskFailed,
				},
			},
		},
		db.NoProjection,
		db.NoSort,
		db.NoSkip,
		db.NoLimit,
	)
	if err != nil && err != mgo.ErrNotFound {
		return err
	}

	for _, task := range allTasks {
		if task.DispatchTime != ZeroTime {
			err = task.reset()
			if err != nil {
				return fmt.Errorf("Restarting build %v failed, could not task.reset on task: %v",
					buildId, task.Id, err)
			}
		}
	}

	if abortInProgress {
		// abort in-progress tasks in this build
		_, err = UpdateAllTasks(
			bson.M{
				TaskBuildIdKey: buildId,
				TaskStatusKey: bson.M{
					"$in": evergreen.AbortableStatuses,
				},
			},
			bson.M{
				"$set": bson.M{
					TaskAbortedKey: true,
				},
			},
		)
		if err != nil {
			return err
		}
	}

	return build.UpdateActivation(buildId, true, caller)
}
开发者ID:pritten,项目名称:evergreen,代码行数:56,代码来源:lifecycle.go


示例3: AbortBuild

// AbortBuild sets the abort flag on all tasks associated with the build which are in an abortable
// state, and marks the build as deactivated.
func AbortBuild(buildId string, caller string) error {
	_, err := UpdateAllTasks(
		bson.M{
			TaskBuildIdKey: buildId,
			TaskStatusKey:  bson.M{"$in": evergreen.AbortableStatuses},
		},
		bson.M{"$set": bson.M{TaskAbortedKey: true}},
	)
	if err != nil {
		return err
	}
	return build.UpdateActivation(buildId, false, caller)
}
开发者ID:pritten,项目名称:evergreen,代码行数:15,代码来源:lifecycle.go


示例4: SetBuildActivation

// SetBuildActivation updates the "active" state of this build and all associated tasks.
// It also updates the task cache for the build document.
func SetBuildActivation(buildId string, active bool) error {
	_, err := UpdateAllTasks(
		bson.M{
			TaskBuildIdKey: buildId,
			TaskStatusKey:  evergreen.TaskUndispatched,
		},
		bson.M{"$set": bson.M{TaskActivatedKey: active}},
	)
	if err != nil {
		return err
	}
	if err = build.UpdateActivation(buildId, active); err != nil {
		return err
	}
	return RefreshTasksCache(buildId)
}
开发者ID:tessavitabile,项目名称:evergreen,代码行数:18,代码来源:lifecycle.go


示例5: SetBuildActivation

// SetBuildActivation updates the "active" state of this build and all associated tasks.
// It also updates the task cache for the build document.
func SetBuildActivation(buildId string, active bool, caller string) error {
	var err error

	// If activating a task, set the ActivatedBy field to be the caller
	if active {
		_, err = UpdateAllTasks(
			bson.M{
				TaskBuildIdKey: buildId,
				TaskStatusKey:  evergreen.TaskUndispatched,
			},
			bson.M{"$set": bson.M{TaskActivatedKey: active, TaskActivatedByKey: caller}},
		)
	} else {

		// if trying to deactivate a task then only deactivate tasks that have not been activated by a user.
		// if the caller is the default task activator,
		// only deactivate tasks that are activated by the default task activator
		if build.IsSystemActivator(caller) {
			_, err = UpdateAllTasks(
				bson.M{
					TaskBuildIdKey:     buildId,
					TaskStatusKey:      evergreen.TaskUndispatched,
					TaskActivatedByKey: caller,
				},
				bson.M{"$set": bson.M{TaskActivatedKey: active, TaskActivatedByKey: caller}},
			)

		} else {
			// update all tasks if the caller is not evergreen.
			_, err = UpdateAllTasks(
				bson.M{
					TaskBuildIdKey: buildId,
					TaskStatusKey:  evergreen.TaskUndispatched,
				},
				bson.M{"$set": bson.M{TaskActivatedKey: active, TaskActivatedByKey: caller}},
			)
		}
	}

	if err != nil {
		return err
	}
	if err = build.UpdateActivation(buildId, active, caller); err != nil {
		return err
	}
	return RefreshTasksCache(buildId)
}
开发者ID:pritten,项目名称:evergreen,代码行数:49,代码来源:lifecycle.go


示例6: RestartBuild

// RestartBuild restarts completed tasks associated with a given buildId.
// If abortInProgress is true, it also sets the abort flag on any in-progress tasks.
func RestartBuild(buildId string, taskIds []string, abortInProgress bool, caller string) error {
	// restart all the 'not in-progress' tasks for the build
	allTasks, err := task.Find(task.ByIdsBuildAndStatus(taskIds, buildId, task.CompletedStatuses))
	if err != nil && err != mgo.ErrNotFound {
		return err
	}

	for _, t := range allTasks {
		if t.DispatchTime != util.ZeroTime {
			err = resetTask(t.Id)
			if err != nil {
				return fmt.Errorf("Restarting build %v failed, could not task.reset on task: %v",
					buildId, t.Id, err)
			}
		}
	}

	if abortInProgress {
		// abort in-progress tasks in this build
		_, err = task.UpdateAll(
			bson.M{
				task.BuildIdKey: buildId,
				task.StatusKey: bson.M{
					"$in": evergreen.AbortableStatuses,
				},
			},
			bson.M{
				"$set": bson.M{
					task.AbortedKey: true,
				},
			},
		)
		if err != nil {
			return err
		}
	}

	return build.UpdateActivation(buildId, true, caller)
}
开发者ID:sr527,项目名称:evergreen,代码行数:41,代码来源:lifecycle.go


示例7: RestartVersion

// RestartVersion restarts completed tasks associated with a given versionId.
// If abortInProgress is true, it also sets the abort flag on any in-progress tasks.
func RestartVersion(versionId string, taskIds []string, abortInProgress bool, caller string) error {
	// restart all the 'not in-progress' tasks for the version
	allTasks, err := FindAllTasks(
		bson.M{
			TaskIdKey:           bson.M{"$in": taskIds},
			TaskVersionKey:      versionId,
			TaskDispatchTimeKey: bson.M{"$ne": ZeroTime},
			TaskStatusKey: bson.M{
				"$in": []string{
					evergreen.TaskSucceeded,
					evergreen.TaskFailed,
				},
			},
		},
		db.NoProjection,
		db.NoSort,
		db.NoSkip,
		db.NoLimit,
	)
	if err != nil && err != mgo.ErrNotFound {
		return err
	}

	// archive all the tasks
	for _, t := range allTasks {
		if err := t.Archive(); err != nil {
			return fmt.Errorf("failed to archive task: %v", err)
		}
	}

	// Set all the task fields to indicate restarted
	_, err = UpdateAllTasks(
		bson.M{TaskIdKey: bson.M{"$in": taskIds}},
		bson.M{
			"$set": bson.M{
				TaskActivatedKey:     true,
				TaskSecretKey:        util.RandomString(),
				TaskStatusKey:        evergreen.TaskUndispatched,
				TaskDispatchTimeKey:  ZeroTime,
				TaskStartTimeKey:     ZeroTime,
				TaskScheduledTimeKey: ZeroTime,
				TaskFinishTimeKey:    ZeroTime,
				TaskTestResultsKey:   []TestResult{},
			},
			"$unset": bson.M{
				TaskDetailsKey: "",
			},
		})
	if err != nil {
		return err
	}

	// TODO figure out a way to coalesce updates for task cache for the same build, so we
	// only need to do one update per-build instead of one per-task here.
	// Doesn't seem to be possible as-is because $ can only apply to one array element matched per
	// document.
	buildIdSet := map[string]bool{}
	for _, t := range allTasks {
		buildIdSet[t.BuildId] = true
		err = build.ResetCachedTask(t.BuildId, t.Id)
		if err != nil {
			return err
		}
	}

	// reset the build statuses, once per build
	buildIdList := make([]string, 0, len(buildIdSet))
	for k, _ := range buildIdSet {
		buildIdList = append(buildIdList, k)
	}

	// Set the build status for all the builds containing the tasks that we touched
	_, err = build.UpdateAllBuilds(
		bson.M{build.IdKey: bson.M{"$in": buildIdList}},
		bson.M{"$set": bson.M{build.StatusKey: evergreen.BuildStarted}},
	)

	if abortInProgress {
		// abort in-progress tasks in this build
		_, err = UpdateAllTasks(
			bson.M{
				TaskVersionKey: versionId,
				TaskIdKey:      bson.M{"$in": taskIds},
				TaskStatusKey:  bson.M{"$in": evergreen.AbortableStatuses},
			},
			bson.M{"$set": bson.M{TaskAbortedKey: true}},
		)
		if err != nil {
			return err
		}
	}

	// update activation for all the builds
	for _, b := range buildIdList {
		err := build.UpdateActivation(b, true, caller)
		if err != nil {
			return err
		}
//.........这里部分代码省略.........
开发者ID:pritten,项目名称:evergreen,代码行数:101,代码来源:lifecycle.go


示例8: RestartVersion

// RestartVersion restarts completed tasks associated with a given versionId.
// If abortInProgress is true, it also sets the abort flag on any in-progress tasks.
func RestartVersion(versionId string, taskIds []string, abortInProgress bool, caller string) error {
	// restart all the 'not in-progress' tasks for the version
	allTasks, err := task.Find(task.ByDispatchedWithIdsVersionAndStatus(taskIds, versionId, task.CompletedStatuses))

	if err != nil && err != mgo.ErrNotFound {
		return err
	}

	// archive all the tasks
	for _, t := range allTasks {
		if err := t.Archive(); err != nil {
			return fmt.Errorf("failed to archive task: %v", err)
		}
	}

	// Set all the task fields to indicate restarted
	err = task.ResetTasks(taskIds)
	if err != nil {
		return err
	}

	// TODO figure out a way to coalesce updates for task cache for the same build, so we
	// only need to do one update per-build instead of one per-task here.
	// Doesn't seem to be possible as-is because $ can only apply to one array element matched per
	// document.
	buildIdSet := map[string]bool{}
	for _, t := range allTasks {
		buildIdSet[t.BuildId] = true
		err = build.ResetCachedTask(t.BuildId, t.Id)
		if err != nil {
			return err
		}
	}

	// reset the build statuses, once per build
	buildIdList := make([]string, 0, len(buildIdSet))
	for k, _ := range buildIdSet {
		buildIdList = append(buildIdList, k)
	}

	// Set the build status for all the builds containing the tasks that we touched
	_, err = build.UpdateAllBuilds(
		bson.M{build.IdKey: bson.M{"$in": buildIdList}},
		bson.M{"$set": bson.M{build.StatusKey: evergreen.BuildStarted}},
	)

	if abortInProgress {
		// abort in-progress tasks in this build
		_, err = task.UpdateAll(
			bson.M{
				task.VersionKey: versionId,
				task.IdKey:      bson.M{"$in": taskIds},
				task.StatusKey:  bson.M{"$in": evergreen.AbortableStatuses},
			},
			bson.M{"$set": bson.M{task.AbortedKey: true}},
		)
		if err != nil {
			return err
		}
	}

	// update activation for all the builds
	for _, b := range buildIdList {
		err := build.UpdateActivation(b, true, caller)
		if err != nil {
			return err
		}
	}
	return nil

}
开发者ID:sr527,项目名称:evergreen,代码行数:73,代码来源:lifecycle.go



注:本文中的github.com/evergreen-ci/evergreen/model/build.UpdateActivation函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang build.Build类代码示例发布时间:2022-05-23
下一篇:
Golang build.Insert函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap