Skip to content

foreach feature if doing #494

@xx1906

Description

@xx1906

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions