utask icon indicating copy to clipboard operation
utask copied to clipboard

foreach feature if doing

Open xx1906 opened this issue 1 year ago • 0 comments

foreach and if section is ambiguous i would like to use foreach like golang as


func foreach() {
    var list = []int{1,2,3,4}
    for _,num:=range list {
      if num % 2 == 0 {
      printX(num)
      }
    }
}

func printX(num int ) {
   println(num)
}

i try this with foreach and conditions but not work

name: "foreach runner......"
description: foreach example
long_description: foreach example
doc_link: http://127.0.0.1:18080/index/examples/network-checker/doc.html

title: "foreach testcase"
title_format: "[test] foreach"


steps:
  foreach_gen_data:
    foreach: '["1","1","1","1"]'
    conditions:
      - type: skip
        if:
          - value: "{{.iterator}}"
            operator: EQ
            expected: a
        then:
          this: PRUNE
      - type: check
        if:
          - value: "{{.iterator}}"
            operator: EQ
            expected: "1"
        then:
          bStep: YIELD_B
    action:
      type: echo
      configuration:
        output:
          foo: "foo-{{.iterator}}"

  bStep:
    description: impacted by concatItems b step
    dependencies: [ foreach_gen_data ]
    custom_states: [ YIELD_B ]
    action:
      type: echo
      configuration:
        output:
          "done"

thanks you for reading this issue, expected for resolution online!

xx1906 avatar Nov 30 '23 02:11 xx1906