当前位置: 首页>>代码示例>>Golang>>正文


Golang atc.PlanConfig类代码示例

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


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

示例1: populatePlanLocations

func populatePlanLocations(planConfig *atc.PlanConfig, location *atc.Location) uint {
	var stepCount uint
	var parentID uint

	parentID = location.ID
	switch {
	case planConfig.Put != "":
		planConfig.Location = location
		// offset by one for the dependent get that will be added
		stepCount = stepCount + 1

	case planConfig.Do != nil:
		children := *planConfig.Do
		parentID = location.ID + 1
		for i := 0; i < len(children); i++ {
			child := children[i]
			childLocation := &atc.Location{
				ID:            location.ID + stepCount + 1,
				ParentID:      location.ParentID,
				ParallelGroup: 0,
				Hook:          location.Hook,
			}

			stepCount = stepCount + populatePlanLocations(&child, childLocation)
			children[i] = child
		}

	case planConfig.Try != nil:
		childLocation := &atc.Location{
			ID:            location.ID + stepCount + 1,
			ParentID:      location.ParentID,
			ParallelGroup: 0,
			Hook:          location.Hook,
		}
		stepCount = stepCount + populatePlanLocations(planConfig.Try, childLocation)

	case planConfig.Aggregate != nil:
		parallelGroup := location.ID + 1
		stepCount += 1

		if location.ParallelGroup != 0 {
			location.ParentID = location.ParallelGroup
		}

		children := *planConfig.Aggregate
		for i := 0; i < len(children); i++ {
			child := children[i]
			childLocation := &atc.Location{
				ID:            location.ID + stepCount + 1,
				ParentID:      location.ParentID,
				ParallelGroup: parallelGroup,
			}

			if child.Aggregate == nil {
				childLocation.Hook = location.Hook
			}

			stepCount = stepCount + populatePlanLocations(&child, childLocation)
			children[i] = child
		}

		parentID = parallelGroup
	default:
		planConfig.Location = location
	}

	if planConfig.Failure != nil {
		child := planConfig.Failure
		childLocation := &atc.Location{
			ID:            location.ID + stepCount + 1,
			ParentID:      parentID,
			ParallelGroup: 0,
			Hook:          "failure",
		}
		stepCount = stepCount + populatePlanLocations(child, childLocation)
	}
	if planConfig.Success != nil {
		child := planConfig.Success
		childLocation := &atc.Location{
			ID:            location.ID + stepCount + 1,
			ParentID:      parentID,
			ParallelGroup: 0,
			Hook:          "success",
		}
		stepCount = stepCount + populatePlanLocations(child, childLocation)
	}
	if planConfig.Ensure != nil {
		child := planConfig.Ensure
		childLocation := &atc.Location{
			ID:            location.ID + stepCount + 1,
			ParentID:      parentID,
			ParallelGroup: 0,
			Hook:          "ensure",
		}
		stepCount = stepCount + populatePlanLocations(child, childLocation)
	}
	return stepCount + 1
}
开发者ID:utako,项目名称:atc,代码行数:98,代码来源:build_factory.go

示例2: validatePlan

func validatePlan(c atc.Config, identifier string, plan atc.PlanConfig) []string {
	foundTypes := foundTypes{
		identifier: identifier,
		found:      make(map[string]bool),
	}

	if plan.Get != "" {
		foundTypes.Find("get")
	}

	if plan.Put != "" {
		foundTypes.Find("put")
	}

	if plan.Task != "" {
		foundTypes.Find("task")
	}

	if plan.Do != nil {
		foundTypes.Find("do")
	}

	if plan.Aggregate != nil {
		foundTypes.Find("aggregate")
	}

	if plan.Try != nil {
		foundTypes.Find("try")
	}

	if valid, message := foundTypes.IsValid(); !valid {
		return []string{message}
	}

	errorMessages := []string{}

	switch {
	case plan.Do != nil:
		for i, plan := range *plan.Do {
			subIdentifier := fmt.Sprintf("%s[%d]", identifier, i)
			errorMessages = append(errorMessages, validatePlan(c, subIdentifier, plan)...)
		}

	case plan.Aggregate != nil:
		for i, plan := range *plan.Aggregate {
			subIdentifier := fmt.Sprintf("%s.aggregate[%d]", identifier, i)
			errorMessages = append(errorMessages, validatePlan(c, subIdentifier, plan)...)
		}

	case plan.Get != "":
		subIdentifier := fmt.Sprintf("%s.get.%s", identifier, plan.Get)

		errorMessages = append(errorMessages, validateInapplicableFields(
			[]string{"privileged", "config", "file"},
			plan, subIdentifier)...,
		)

		if plan.Resource != "" {
			_, found := c.Resources.Lookup(plan.Resource)
			if !found {
				errorMessages = append(
					errorMessages,
					fmt.Sprintf(
						"%s refers to a resource that does not exist ('%s')",
						subIdentifier,
						plan.Resource,
					),
				)
			}
		} else {
			_, found := c.Resources.Lookup(plan.Get)
			if !found {
				errorMessages = append(
					errorMessages,
					fmt.Sprintf(
						"%s refers to a resource that does not exist",
						subIdentifier,
					),
				)
			}
		}

		for _, job := range plan.Passed {
			jobConfig, found := c.Jobs.Lookup(job)
			if !found {
				errorMessages = append(
					errorMessages,
					fmt.Sprintf(
						"%s.passed references an unknown job ('%s')",
						subIdentifier,
						job,
					),
				)
			} else {
				foundResource := false

				for _, jobInput := range JobInputs(jobConfig) {
					if jobInput.Resource == plan.ResourceName() {
						foundResource = true
						break
//.........这里部分代码省略.........
开发者ID:ACPK,项目名称:atc,代码行数:101,代码来源:validate.go

示例3: populateLocations

func (l locationPopulator) populateLocations(planConfig *atc.PlanConfig, location *atc.Location) uint {
	var stepCount uint
	var parentID uint

	parentID = location.ID
	switch {
	case planConfig.Put != "":
		planConfig.Location = location
		// offset by one for the dependent get that will be added
		stepCount = stepCount + 1

	case planConfig.Do != nil:
		// TODO: Do we actually need to increment these two here? See aggregate location.
		serialGroup := location.ID + 1
		stepCount += 1

		if location.SerialGroup != 0 {
			location.ParentID = location.SerialGroup
		}

		children := *planConfig.Do
		for i := 0; i < len(children); i++ {
			child := children[i]
			childLocation := &atc.Location{
				ID:            location.ID + stepCount + 1,
				ParentID:      location.ParentID,
				ParallelGroup: location.ParallelGroup,
				SerialGroup:   serialGroup,
			}

			if child.Do == nil {
				childLocation.Hook = location.Hook
			}

			stepCount = stepCount + l.populateLocations(&child, childLocation)
			children[i] = child
		}

		parentID = serialGroup

	case planConfig.Try != nil:
		childLocation := &atc.Location{
			ID:            location.ID + stepCount + 1,
			ParentID:      location.ParentID,
			ParallelGroup: 0,
			Hook:          location.Hook,
		}
		stepCount = stepCount + l.populateLocations(planConfig.Try, childLocation)

	case planConfig.Aggregate != nil:
		// TODO: Do we actually need to increment these two here? See do location.
		parallelGroup := location.ID + 1
		stepCount += 1

		if location.ParallelGroup != 0 {
			location.ParentID = location.ParallelGroup
		}

		children := *planConfig.Aggregate
		for i := 0; i < len(children); i++ {
			child := children[i]
			childLocation := &atc.Location{
				ID:            location.ID + stepCount + 1,
				ParentID:      location.ParentID,
				ParallelGroup: parallelGroup,
				SerialGroup:   location.SerialGroup,
			}

			if child.Aggregate == nil && child.Do == nil {
				childLocation.Hook = location.Hook
			}

			stepCount = stepCount + l.populateLocations(&child, childLocation)
			children[i] = child
		}

		parentID = parallelGroup
	default:
		planConfig.Location = location
	}

	if planConfig.Failure != nil {
		child := planConfig.Failure
		childLocation := &atc.Location{
			ID:            location.ID + stepCount + 1,
			ParentID:      parentID,
			ParallelGroup: 0,
			Hook:          "failure",
		}
		stepCount = stepCount + l.populateLocations(child, childLocation)
	}
	if planConfig.Success != nil {
		child := planConfig.Success
		childLocation := &atc.Location{
			ID:            location.ID + stepCount + 1,
			ParentID:      parentID,
			ParallelGroup: 0,
			Hook:          "success",
		}
		stepCount = stepCount + l.populateLocations(child, childLocation)
//.........这里部分代码省略.........
开发者ID:ACPK,项目名称:atc,代码行数:101,代码来源:location_populator.go


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