@@ -164,10 +164,10 @@ func (wi *WorkflowInclude) ValidateChecksum(contents string) (bool, error) {
164164 return false , fmt .Errorf ("unsupported algorithm: %s" , algorithm )
165165 }
166166
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)
171171
172172 checksumBytes , err := hex .DecodeString (string (checksumContents ))
173173 if err != nil {
@@ -226,6 +226,15 @@ func (workflow *StackupWorkflow) TaskIdToUuid(id string) string {
226226 return task .Uuid
227227}
228228
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+
229238func (workflow * StackupWorkflow ) Initialize () {
230239 // generate uuids for each task as the initial step, as other code below relies on a uuid existing
231240 for _ , task := range workflow .Tasks {
@@ -323,6 +332,8 @@ func (workflow *StackupWorkflow) ProcessInclude(include *WorkflowInclude) bool {
323332
324333 contents , err := utils .GetUrlContents (include .FullUrl ())
325334
335+ fmt .Println ("contents: " , contents )
336+
326337 if err != nil {
327338 fmt .Println (err )
328339 return false
@@ -363,13 +374,22 @@ func (workflow *StackupWorkflow) ProcessInclude(include *WorkflowInclude) bool {
363374 workflow .Init += "\n \n " + template .Init
364375 }
365376
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+
366383 for _ , p := range template .Preconditions {
367384 p .FromRemote = true
368385 App .Workflow .Preconditions = append (App .Workflow .Preconditions , p )
369386 }
370387
388+ App .Workflow .Preconditions = workflow .reversePreconditions (App .Workflow .Preconditions )
389+
371390 for _ , t := range template .Tasks {
372391 t .FromRemote = true
392+ t .Uuid = utils .GenerateTaskUuid ()
373393 App .Workflow .Tasks = append (App .Workflow .Tasks , t )
374394 }
375395
0 commit comments