turbot / flowpipe

Flowpipe is a cloud scripting engine. Automation and workflow to connect your clouds to the people, systems and data that matters.
https://flowpipe.io
GNU Affero General Public License v3.0
361 stars 13 forks source link

Why isn't a loop block supported in the input step? #797

Closed e-gineer closed 6 months ago

e-gineer commented 6 months ago

I have a pipeline that uses an input step with a loop block:

pipeline "multi_step" {

  param "prompt" {
    default = "Do you approve?"
  }

  param "subject" {
    default = "Do you approve?"
  }

  param "notifiers" {
    default = ["default"]
  }

  step "input" "approve" {
    notifier = notifier[keys(param.notifiers)[loop.index]]

    type = "button"

    subject = param.subject

    prompt = param.prompt

    option "approve" {
      label = "Approve"
      style = "ok"
    }

    option "deny" {
      label = "Deny"
      style = "alert"
    }

    loop {
      until = result.value == "deny" || loop.index >= len(param.notifiers)
    }

  }

  output "approved" {
    value = alltrue([for decision in step.input.approve : decision.value == "approve"])
  }

}

But I'm getting this error:

2024-03-15 06:09:54 [flowpipe] error Failed watching workspace for mod mod.approval: failed to reload workspace: Failed to decode mod:
Unsupported block type: Blocks of type "loop" are not expected here.
(/Users/nathan/src/flowpipe-mod-approval/mod.fp:98,5-9)

The docs say that loop { ... } can be used in any step - https://flowpipe.io/docs/flowpipe-hcl/step#loop

Should loop work in input steps?

vhadianto commented 6 months ago

Included in v0.4.2-rc.2: https://github.com/turbot/flowpipe/releases/tag/v0.4.2-rc.2