Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable Validation #832

Open
graza-io opened this issue Apr 18, 2024 · 3 comments
Open

Variable Validation #832

graza-io opened this issue Apr 18, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@graza-io
Copy link
Contributor

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:

  • "a"
  • "b"
  • "c"

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:

  • Increased complexity when designing pipelines to cater for these events
  • Issues with the value for variables only become noticed at runtime

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.

@graza-io graza-io added the enhancement New feature or request label Apr 18, 2024
Copy link

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 github-actions bot added the stale label Jun 18, 2024
@graza-io graza-io removed the stale label Jun 18, 2024
Copy link

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 github-actions bot added the stale label Aug 18, 2024
@graza-io graza-io removed the stale label Aug 19, 2024
Copy link

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 github-actions bot added the stale label Oct 19, 2024
@graza-io graza-io removed the stale label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant