1package atc 2 3type Plan struct { 4 ID PlanID `json:"id"` 5 Attempts []int `json:"attempts,omitempty"` 6 7 Get *GetPlan `json:"get,omitempty"` 8 Put *PutPlan `json:"put,omitempty"` 9 Check *CheckPlan `json:"check,omitempty"` 10 Task *TaskPlan `json:"task,omitempty"` 11 SetPipeline *SetPipelinePlan `json:"set_pipeline,omitempty"` 12 LoadVar *LoadVarPlan `json:"load_var,omitempty"` 13 14 Do *DoPlan `json:"do,omitempty"` 15 InParallel *InParallelPlan `json:"in_parallel,omitempty"` 16 Aggregate *AggregatePlan `json:"aggregate,omitempty"` 17 Across *AcrossPlan `json:"across,omitempty"` 18 19 OnSuccess *OnSuccessPlan `json:"on_success,omitempty"` 20 OnFailure *OnFailurePlan `json:"on_failure,omitempty"` 21 OnAbort *OnAbortPlan `json:"on_abort,omitempty"` 22 OnError *OnErrorPlan `json:"on_error,omitempty"` 23 Ensure *EnsurePlan `json:"ensure,omitempty"` 24 25 Try *TryPlan `json:"try,omitempty"` 26 Timeout *TimeoutPlan `json:"timeout,omitempty"` 27 Retry *RetryPlan `json:"retry,omitempty"` 28 29 // used for 'fly execute' 30 ArtifactInput *ArtifactInputPlan `json:"artifact_input,omitempty"` 31 ArtifactOutput *ArtifactOutputPlan `json:"artifact_output,omitempty"` 32 33 // deprecated, kept for backwards compatibility to be able to show old builds 34 DependentGet *DependentGetPlan `json:"dependent_get,omitempty"` 35} 36 37func (plan *Plan) Each(f func(*Plan)) { 38 f(plan) 39 40 if plan.Do != nil { 41 for i, p := range *plan.Do { 42 p.Each(f) 43 (*plan.Do)[i] = p 44 } 45 } 46 47 if plan.InParallel != nil { 48 for i, p := range plan.InParallel.Steps { 49 p.Each(f) 50 plan.InParallel.Steps[i] = p 51 } 52 } 53 54 if plan.Aggregate != nil { 55 for i, p := range *plan.Aggregate { 56 p.Each(f) 57 (*plan.Aggregate)[i] = p 58 } 59 } 60 61 if plan.Across != nil { 62 for i, p := range plan.Across.Steps { 63 p.Step.Each(f) 64 plan.Across.Steps[i] = p 65 } 66 } 67 68 if plan.OnSuccess != nil { 69 plan.OnSuccess.Step.Each(f) 70 plan.OnSuccess.Next.Each(f) 71 } 72 73 if plan.OnFailure != nil { 74 plan.OnFailure.Step.Each(f) 75 plan.OnFailure.Next.Each(f) 76 } 77 78 if plan.OnAbort != nil { 79 plan.OnAbort.Step.Each(f) 80 plan.OnAbort.Next.Each(f) 81 } 82 83 if plan.OnError != nil { 84 plan.OnError.Step.Each(f) 85 plan.OnError.Next.Each(f) 86 } 87 88 if plan.Ensure != nil { 89 plan.Ensure.Step.Each(f) 90 plan.Ensure.Next.Each(f) 91 } 92 93 if plan.Try != nil { 94 plan.Try.Step.Each(f) 95 } 96 97 if plan.Timeout != nil { 98 plan.Timeout.Step.Each(f) 99 } 100 101 if plan.Retry != nil { 102 for i, p := range *plan.Retry { 103 p.Each(f) 104 (*plan.Retry)[i] = p 105 } 106 } 107} 108 109type PlanID string 110 111type ArtifactInputPlan struct { 112 ArtifactID int `json:"artifact_id"` 113 Name string `json:"name"` 114} 115 116type ArtifactOutputPlan struct { 117 Name string `json:"name"` 118} 119 120type OnAbortPlan struct { 121 Step Plan `json:"step"` 122 Next Plan `json:"on_abort"` 123} 124 125type OnErrorPlan struct { 126 Step Plan `json:"step"` 127 Next Plan `json:"on_error"` 128} 129 130type OnFailurePlan struct { 131 Step Plan `json:"step"` 132 Next Plan `json:"on_failure"` 133} 134 135type EnsurePlan struct { 136 Step Plan `json:"step"` 137 Next Plan `json:"ensure"` 138} 139 140type OnSuccessPlan struct { 141 Step Plan `json:"step"` 142 Next Plan `json:"on_success"` 143} 144 145type TimeoutPlan struct { 146 Step Plan `json:"step"` 147 Duration string `json:"duration"` 148} 149 150type TryPlan struct { 151 Step Plan `json:"step"` 152} 153 154type AggregatePlan []Plan 155 156type InParallelPlan struct { 157 Steps []Plan `json:"steps"` 158 Limit int `json:"limit,omitempty"` 159 FailFast bool `json:"fail_fast,omitempty"` 160} 161 162type AcrossPlan struct { 163 Vars []AcrossVar `json:"vars"` 164 Steps []VarScopedPlan `json:"steps"` 165 FailFast bool `json:"fail_fast,omitempty"` 166} 167 168type AcrossVar struct { 169 Var string `json:"name"` 170 Values []interface{} `json:"values"` 171 MaxInFlight int `json:"max_in_flight"` 172} 173 174type VarScopedPlan struct { 175 Step Plan `json:"step"` 176 Values []interface{} `json:"values"` 177} 178 179type DoPlan []Plan 180 181type GetPlan struct { 182 Name string `json:"name,omitempty"` 183 184 Type string `json:"type"` 185 Resource string `json:"resource"` 186 Source Source `json:"source"` 187 Params Params `json:"params,omitempty"` 188 Version *Version `json:"version,omitempty"` 189 VersionFrom *PlanID `json:"version_from,omitempty"` 190 Tags Tags `json:"tags,omitempty"` 191 192 VersionedResourceTypes VersionedResourceTypes `json:"resource_types,omitempty"` 193} 194 195type PutPlan struct { 196 Type string `json:"type"` 197 Name string `json:"name,omitempty"` 198 Resource string `json:"resource"` 199 Source Source `json:"source"` 200 Params Params `json:"params,omitempty"` 201 Tags Tags `json:"tags,omitempty"` 202 Inputs *InputsConfig `json:"inputs,omitempty"` 203 204 VersionedResourceTypes VersionedResourceTypes `json:"resource_types,omitempty"` 205} 206 207type CheckPlan struct { 208 Type string `json:"type"` 209 Name string `json:"name,omitempty"` 210 Source Source `json:"source"` 211 Tags Tags `json:"tags,omitempty"` 212 Timeout string `json:"timeout,omitempty"` 213 FromVersion Version `json:"from_version,omitempty"` 214 215 VersionedResourceTypes VersionedResourceTypes `json:"resource_types,omitempty"` 216} 217 218type TaskPlan struct { 219 Name string `json:"name,omitempty"` 220 221 Privileged bool `json:"privileged"` 222 Tags Tags `json:"tags,omitempty"` 223 224 ConfigPath string `json:"config_path,omitempty"` 225 Config *TaskConfig `json:"config,omitempty"` 226 Vars Params `json:"vars,omitempty"` 227 228 Params TaskEnv `json:"params,omitempty"` 229 InputMapping map[string]string `json:"input_mapping,omitempty"` 230 OutputMapping map[string]string `json:"output_mapping,omitempty"` 231 ImageArtifactName string `json:"image,omitempty"` 232 233 VersionedResourceTypes VersionedResourceTypes `json:"resource_types,omitempty"` 234} 235 236type SetPipelinePlan struct { 237 Name string `json:"name"` 238 File string `json:"file"` 239 Team string `json:"team,omitempty"` 240 Vars map[string]interface{} `json:"vars,omitempty"` 241 VarFiles []string `json:"var_files,omitempty"` 242} 243 244type LoadVarPlan struct { 245 Name string `json:"name"` 246 File string `json:"file"` 247 Format string `json:"format,omitempty"` 248 Reveal bool `json:"reveal,omitempty"` 249} 250 251type RetryPlan []Plan 252 253type DependentGetPlan struct { 254 Type string `json:"type"` 255 Name string `json:"name,omitempty"` 256 Resource string `json:"resource"` 257} 258