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
383 stars 16 forks source link

Variable Validation #832

Open graza-io opened 7 months ago

graza-io commented 7 months ago

Context

When composing pipelines with variable inputs, sometimes we want to only support a limited number of options for the variable.

A simple example may be var.route which we may limit to wanting to be one of:

As we use this variable to decide which child pipeline to initiate.

However, at the current time in order to achieve this, we have to run tests to cater for each potential value and then have another step that contains an if to check that the value isn't one we allow:

step "<pipeline/message/whatever>" "bad_route" {
  if = var.route != "a" && var.route != "b" && var.route != "c"

  ...
  // potentially throw here to end the pipeline
}

This approach comes with a few issues:

Desired Solution

We do currently validate the type of the variable at parse time to ensure that a string is a string, etc. It would be beneficial if we could also validate the contents of the value against a "rule" at parse time also.

This would reduce complexity around having to have the pipelines themselves handle/cater for invalid inputs as well as highlight these issues when loading the mod with vars/var-files.

Looking at HCL variables in Terraform, they have a clear and useful approach to variable validations: docs

Alternative Solution

We could implement a different approach to variable validation, but this would be custom and differentiate from the expectations of anyone who has used variable validation with Terraform may be expecting.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 4 weeks ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.