本文整理匯總了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
}
示例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
//.........這裏部分代碼省略.........
示例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)
//.........這裏部分代碼省略.........