This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Allow limiting pipeline variables to a pre-defined set of values #1
Labels
good first issue
Good for newcomers
Milestone
Comments
JeanMertz
added a commit
that referenced
this issue
Jun 24, 2019
If a `Variable` has its `selection_constraint` value set, then any `VariableValue` that matches the key of that variable will have to have its value match one of the strings in the constraint set. For example, if the selection constraint is ["hello", "world"], then a variable value of "universe" is invalid and will return an error, whereas a value of either "hello" or "world" is valid. Clients can use this information to pro-actively restrict the set of allowed values before submitting them to the server. For example, the web-client can show a select box, instead of an input field, if a selection constraint is set for a variable. See: #1
JeanMertz
added a commit
that referenced
this issue
Jun 24, 2019
If a `Variable` has its `selection_constraint` value set, then any `VariableValue` that matches the key of that variable will have to have its value match one of the strings in the constraint set. For example, if the selection constraint is ["hello", "world"], then a variable value of "universe" is invalid and will return an error, whereas a value of either "hello" or "world" is valid. Clients can use this information to pro-actively restrict the set of allowed values before submitting them to the server. For example, the web-client can show a select box, instead of an input field, if a selection constraint is set for a variable. See: #1
JeanMertz
added a commit
that referenced
this issue
Jun 25, 2019
Pipeline variables can now have a _default value_. This is a purely cosmetic addition. Clients can use this value to pre-fill variable input fields, or select the correct value from a set of selection constraints as the default value. This feature works together with the selection constraints feature (see #1), in that if a default value is provided for a variable, and a selection constraint is provided as well, the default value has to be part of that constraint in order for the variable to be created successfully. See: #3
This has been implemented. Right now, the single value constraint will result in a checkbox that cannot be deselected, since all variables are currently required. Once #25 is implemented, you can actually deselect a single-value constraint, if the variable is marked as optional. (there are still some things to consider with optional values, such as should we add a "none" value to select boxes and radio fields? But we'll tackle those questions when we need to) |
JeanMertz
added a commit
that referenced
this issue
Jun 25, 2019
Pipeline variables can now have a _default value_. This is a purely cosmetic addition. Clients can use this value to pre-fill variable input fields, or select the correct value from a set of selection constraints as the default value. This feature works together with the selection constraints feature (see #1), in that if a default value is provided for a variable, and a selection constraint is provided as well, the default value has to be part of that constraint in order for the variable to be created successfully. See: #3
JeanMertz
added a commit
that referenced
this issue
Jun 25, 2019
Pipeline variables can now have a _default value_. This is a purely cosmetic addition. Clients can use this value to pre-fill variable input fields, or select the correct value from a set of selection constraints as the default value. This feature works together with the selection constraints feature (see #1), in that if a default value is provided for a variable, and a selection constraint is provided as well, the default value has to be part of that constraint in order for the variable to be created successfully. See: #3
JeanMertz
added a commit
that referenced
this issue
Jun 25, 2019
Pipeline variables can now have a _default value_. This is a purely cosmetic addition. Clients can use this value to pre-fill variable input fields, or select the correct value from a set of selection constraints as the default value. This feature works together with the selection constraints feature (see #1), in that if a default value is provided for a variable, and a selection constraint is provided as well, the default value has to be part of that constraint in order for the variable to be created successfully. See: #3
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
A pipeline variable is currently defined as:
I propose changing it to:
By adding a
values
(open to bikeshedding, such asacceptable_values
) field, we can optionally limit the accepted variable values to a pre-determined set of values when constructing a pipeline.This can be useful, for example when you want a pipeline variable that consists of a boolean
yes/no
value, or a set of strings such asdevelopment
,staging
andproduction
.In essence, the value then becomes an untyped enum, checked at runtime.
This information can also be used by the UI to show a
select
field, instead of aninput
field, when the set of acceptable values are finite (and perhaps even dynamically make it a list ofcheckboxes
, if there are three or fewer options to choose from, as that makes the UI more easy to use).Not sure yet if we want to do anything special with a one-value enum, such as using a
hidden
field for the variable value, since only one value is acceptable, or just not accepting it as input when creating the pipeline variables, as I can't see any reason why you'd want to do that. But it's not that important to tackle right now.In an ideal situation, variable values would be more strongly typed, so that more advanced variables become possible (arrays, objects, true enums, integers, etc), but that's still a long way off (and perhaps even undesired, as it adds more complexity to the system), and this will already be an improvement that enables more types of pipelines.
The text was updated successfully, but these errors were encountered: