Skip to content

Commit dd0fe06

Browse files
authored
Updating docs for selectManyFrom() functor (#11637)
1 parent a9e0efc commit dd0fe06

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

docs/platform/variables-and-expressions/runtime-input-usage.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Pipelines fails if a variable's default value starts with `*`. This includes run
176176
Use allowed values to provide a fixed range of acceptable values for a runtime input.
177177

178178
<Tabs>
179-
<TabItem value="Visual" label="Visual">
179+
<TabItem value="Visual" label="Visual" default>
180180

181181
1. In the Pipeline Studio's Visual Editor, use the **Value type selector** to select **Runtime Input**.
182182

@@ -200,24 +200,40 @@ Use allowed values to provide a fixed range of acceptable values for a runtime i
200200
6. If you also specify a [default value](#default-values), you must include the default value in your allowed values.
201201
7. Select **Submit**.
202202

203+
If you are having any trouble resolving allowed values in runtime inputs ( e.g., if you are using JSON in allowed values and are unable to resolve them, or with array-type fields such as file paths), please check how the allowed values are configured in the YAML section of [set allowed values](#set-allowed-values).
204+
203205
</TabItem>
204-
<TabItem value="YAML" label="YAML" default>
206+
<TabItem value="YAML" label="YAML" >
207+
208+
:::caution Deprecated Method
209+
210+
We have introduced a new functor [`.selectManyFrom()`](#multi-selection), which is mapped to multi-selection for runtime inputs. The release of the new functor has deprecated the `.allowedValues()` functor.
211+
212+
Exactly as before, the allowed values method still behaves like [`.selectOneFrom()`](#single-selection) (single selection) unless the feature flag `PIE_MULTISELECT_AND_COMMA_IN_ALLOWED_VALUES` is enabled, in which case it is used to perform multi selection.
213+
214+
With this update:
215+
- Use [`.selectManyFrom()`](#multi-selection) for selecting multiple values
216+
- Use [`.selectOneFrom()`](#single-selection) for selecting a single value
217+
218+
219+
**Existing pipelines using `.allowedValues()` will continue to work, but editing runtime inputs in Pipeline Studio will update the YAML to use the new functors, which may affect automation and testing.**
220+
:::
205221

206-
When writing pipelines in YAML, define allowed values by appending the `.allowedValues()` method to `<+input>`. For example: `<+input>.allowedValues(bengaluru,newyork)`.
222+
When writing pipelines in YAML, define allowed values by appending the `.selectOneFrom()` or `selectManyFrom()` method to `<+input>`. For example: `<+input>.selectOneFrom(bengaluru,newyork,california)` or `<+input>.selectManyFrom(bengaluru,newyork,california)` depending upon whether you want to allow [single selection](#single-selection) or [multi selection](#multi-selection).
207223

208-
If your values include commas, you must escape the value strings using the format `\'VALUE\'`. For example: `<+input>.allowedValues(\'bengaluru,india\',\'newyork,usa\',\'london,uk\')`.
224+
Please note that `.allowedValues(bengaluru,newyork,california)` will work as well, but it is a deprecated method and therefore we recommend using [`.selectManyFrom()`](#multi-selection) or [`.selectOneFrom()`](#single-selection) functors.
209225

210-
If you specify allowed values *and* a [default value](#default-values), the default value must be present in the list of allowed values. To specify both an allowed value and a default value, append both the `.default()` and `.allowedValues()` methods to `<+input>`, and make sure the list of allowed values includes the default value. For example: `<+input>.default(london).allowedValues(bengaluru,newyork,london)`.
226+
If your values include commas, you must escape the value strings using the format `\'VALUE\'`. For example: `<+input>.selectManyFrom(\'bengaluru,india\',\'newyork,usa\',\'london,uk\')`.
211227

212-
In order to allow empty values to be included in the allowed values list, add a comma followed by nothing. For example: `<+input>.allowedValues(bengaluru,newyork,)` will allow an empty value to be an input for this variable.
228+
If you want to specify allowed values and a [default value](#default-values), the default value must be present in the list of allowed values. To specify both an allowed value and a default value, append both the `.default()` and `.selectOneFrom()` or `.selectManyFrom()` methods to `<+input>`, and make sure the list of allowed values includes the default value. For example: `<+input>.default(london).selectManyFrom(bengaluru,newyork,london)`.
229+
230+
In order to allow empty values to be included in the allowed values list, add a comma followed by nothing. For example: `<+input>.selectManyFrom(bengaluru,newyork,)` will allow an empty value to be an input for this variable.
213231

214232
:::info
215233

216234
The option to allow empty values is behind the feature flag `CDS_INCLUDE_EMPTY_VALUE`. Contact [Harness Support](mailto:[email protected]) to enable it.
217235

218236
:::
219-
</TabItem>
220-
</Tabs>
221237

222238
---
223239

@@ -228,51 +244,54 @@ If you use runtime input with allowed values in JSON, use double quotes as neces
228244
For example, these expressions both resolve to `{x:y}`:
229245

230246
```
231-
<+input>.allowedValues({"x":"y"})
232-
"<+input>.allowedValues({x:y})"
247+
<+input>.selectOneFrom({"x":"y"})
248+
"<+input>.selectOneFrom({x:y})"
233249
```
234250

235251
If you needed the allowed values to include quotes, such as `{"x": "y"}`, then you need to escape the quotes in the allowed values. For example:
236252

237253
```
238-
"<+input>.allowedValues({\\\"x\\\": \\\"y\\\"})"
254+
"<+input>.selectOneFrom({\\\"x\\\": \\\"y\\\"})"
239255
```
240256

241257
:::
242258

243259

244260
:::info note
245261

246-
When using `allowedValues` with runtime inputs in array-type fields (e.g., file paths), errors may occur during deployment as the system might not correctly process these inputs.
262+
When using `allowedValues` , `selectManyFrom` or `selectOneFrom` with runtime inputs in array-type fields (e.g., file paths), errors may occur during deployment as the system might not correctly process these inputs.
247263

248-
Fields like paths in ECS Task Definitions and valuesPaths in Kubernetes services do not support runtime inputs in array format. Expressions like `<+input>.allowedValues(<+variable1>, <+variable2>)` can lead to deployment failures
264+
Fields like paths in ECS Task Definitions and valuesPaths in Kubernetes services do not support runtime inputs in array format. Expressions like `<+input>.selectManyFrom(<+variable1>, <+variable2>)` can lead to deployment failures
249265

250266
**Workaround:-**
251-
Define a variable (e.g., FILE_PATH_VAR) at the pipeline or service level, assign it a value using `allowedValues`, and reference this variable in the configuration. This approach ensures the input is treated as a string.
267+
Define a variable (e.g., FILE_PATH_VAR) at the pipeline or service level, assign it a value using `allowedValues`, `selectManyFrom` or `selectOneFrom`, and reference this variable in the configuration. This approach ensures the input is treated as a string.
252268

253269
**Recommendation:-**
254-
Avoid using `allowedValues` with runtime inputs in list fields and use the suggested workaround to ensure proper functionality
270+
Avoid using `allowedValues` , `selectManyFrom` or `selectOneFrom` with runtime inputs in list fields and use the suggested workaround to ensure proper functionality
255271

256272
:::
257273

274+
</TabItem>
275+
</Tabs>
276+
258277
## Allow Multi Selection and Single selection
259278

260279

261-
You can select a **Mode** of selection while creating allowed values in Runtime Input:-
280+
You can select a **Mode** of selection while creating allowed values in Runtime Input
262281

263282
![](./static/mode_of_Selection_allowed_value.png)
264283

265284
### Multi Selection
266285

267-
:::note
268-
Currently, multiple selection for runtime inputs is behind the feature flag `PIE_MULTISELECT_AND_COMMA_IN_ALLOWED_VALUES`. Contact [Harness Support](mailto:[email protected]) to enable the feature.
286+
:::info note
287+
Multi Selection mode now by default maps to the `.selectManyFrom()` functor. This feature update is not behind a feature flag and is generally available.
269288
:::
270289

271-
You can use Multi Selection if you want to choose one or more values from the list of [allowed values](#set-allowed-values). Multi Selection maps to the `.allowedValues()` functor, and Single Selection maps to the
272-
`.selectOneFrom()` functor. You can use multiple selection for runtime inputs in pipelines, stages, and shell script variables only. Multiple selection is an extension of allowed values, so you must specify allowed values to use it.
290+
:::caution DEPRECATED
291+
Multiple selection for runtime inputs by leveraging the `.allowedValues()` which is behind the feature flag `PIE_MULTISELECT_AND_COMMA_IN_ALLOWED_VALUES` is **deprecated**.
292+
:::
273293

274-
For users who want to migrate to single selection, you can implement
275-
`.selectOneFrom()` even before the FF `PIE_MULTISELECT_AND_COMMA_IN_ALLOWED_VALUES` is turned on.
294+
You can use Multi Selection if you want to choose one or more values from the list of [allowed values](#set-allowed-values). Multi Selection by default maps to the `.selectManyFrom()` functor and Single Selection maps to the [`.selectOneFrom()`](#single-selection) functor. You can use multiple selection for runtime inputs in pipelines, stages, and shell script variables only. You must specify multiple allowed values to use it.
276295

277296
![](./static/runtime-inputs-11.png)
278297

0 commit comments

Comments
 (0)