@@ -164,10 +164,10 @@ func (wi *WorkflowInclude) ValidateChecksum(contents string) (bool, error) {
164
164
return false , fmt .Errorf ("unsupported algorithm: %s" , algorithm )
165
165
}
166
166
167
- fmt .Printf ("checksum url: %s\n " , wi .ChecksumUrl )
168
- fmt .Printf ("algorithm: %s\n " , algorithm )
169
- fmt .Printf ("hash: %x\n " , hash )
170
- fmt .Printf ("checksum: %s\n " , checksumContents )
167
+ // fmt.Printf("checksum url: %s\n", wi.ChecksumUrl)
168
+ // fmt.Printf("algorithm: %s\n", algorithm)
169
+ // fmt.Printf("hash: %x\n", hash)
170
+ // fmt.Printf("checksum: %s\n", checksumContents)
171
171
172
172
checksumBytes , err := hex .DecodeString (string (checksumContents ))
173
173
if err != nil {
@@ -226,6 +226,15 @@ func (workflow *StackupWorkflow) TaskIdToUuid(id string) string {
226
226
return task .Uuid
227
227
}
228
228
229
+ func (workflow * StackupWorkflow ) reversePreconditions (items []* Precondition ) []* Precondition {
230
+ length := len (items )
231
+ for i := 0 ; i < length / 2 ; i ++ {
232
+ items [i ], items [length - i - 1 ] = items [length - i - 1 ], items [i ]
233
+ }
234
+
235
+ return items
236
+ }
237
+
229
238
func (workflow * StackupWorkflow ) Initialize () {
230
239
// generate uuids for each task as the initial step, as other code below relies on a uuid existing
231
240
for _ , task := range workflow .Tasks {
@@ -323,6 +332,8 @@ func (workflow *StackupWorkflow) ProcessInclude(include *WorkflowInclude) bool {
323
332
324
333
contents , err := utils .GetUrlContents (include .FullUrl ())
325
334
335
+ fmt .Println ("contents: " , contents )
336
+
326
337
if err != nil {
327
338
fmt .Println (err )
328
339
return false
@@ -363,13 +374,22 @@ func (workflow *StackupWorkflow) ProcessInclude(include *WorkflowInclude) bool {
363
374
workflow .Init += "\n \n " + template .Init
364
375
}
365
376
377
+ // prepend the included preconditions; we reverse the order of the preconditions in the included file,
378
+ // then reverse the existing preconditions, append them, then reverse the workflow preconditions again
379
+ // to achieve the correct order.
380
+ App .Workflow .Preconditions = workflow .reversePreconditions (App .Workflow .Preconditions )
381
+ template .Preconditions = workflow .reversePreconditions (template .Preconditions )
382
+
366
383
for _ , p := range template .Preconditions {
367
384
p .FromRemote = true
368
385
App .Workflow .Preconditions = append (App .Workflow .Preconditions , p )
369
386
}
370
387
388
+ App .Workflow .Preconditions = workflow .reversePreconditions (App .Workflow .Preconditions )
389
+
371
390
for _ , t := range template .Tasks {
372
391
t .FromRemote = true
392
+ t .Uuid = utils .GenerateTaskUuid ()
373
393
App .Workflow .Tasks = append (App .Workflow .Tasks , t )
374
394
}
375
395
0 commit comments