1package executehelpers 2 3import ( 4 "github.com/concourse/concourse/atc" 5 "github.com/concourse/concourse/fly/rc" 6) 7 8func CreateBuildPlan( 9 fact atc.PlanFactory, 10 target rc.Target, 11 privileged bool, 12 inputs []Input, 13 inputMappings map[string]string, 14 versionedResourceTypes atc.VersionedResourceTypes, 15 outputs []Output, 16 config atc.TaskConfig, 17 tags []string, 18) (atc.Plan, error) { 19 if err := config.Validate(); err != nil { 20 return atc.Plan{}, err 21 } 22 23 buildInputs := atc.AggregatePlan{} 24 for _, input := range inputs { 25 buildInputs = append(buildInputs, input.Plan) 26 } 27 28 taskPlan := fact.NewPlan(atc.TaskPlan{ 29 Name: "one-off", 30 Privileged: privileged, 31 Config: &config, 32 InputMapping: inputMappings, 33 VersionedResourceTypes: versionedResourceTypes, 34 }) 35 36 if len(tags) != 0 { 37 taskPlan.Task.Tags = tags 38 } 39 40 buildOutputs := atc.AggregatePlan{} 41 for _, output := range outputs { 42 buildOutputs = append(buildOutputs, output.Plan) 43 } 44 45 var plan atc.Plan 46 if len(buildOutputs) == 0 { 47 plan = fact.NewPlan(atc.DoPlan{ 48 fact.NewPlan(buildInputs), 49 taskPlan, 50 }) 51 } else { 52 plan = fact.NewPlan(atc.EnsurePlan{ 53 Step: fact.NewPlan(atc.DoPlan{ 54 fact.NewPlan(buildInputs), 55 taskPlan, 56 }), 57 Next: fact.NewPlan(buildOutputs), 58 }) 59 } 60 61 return plan, nil 62} 63