-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(DOCS) Document parameters implementation
This change adds documentation to the CLI and schema reference for the parameters support implementation in #291 and #294. It also updates the changelog with the relevant information.
- Loading branch information
1 parent
1fb90f6
commit 57bdcaa
Showing
4 changed files
with
184 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--- | ||
description: Reference for the 'parameters' DSC configuration document function | ||
ms.date: 02/05/2024 | ||
ms.topic: reference | ||
title: parameters | ||
--- | ||
|
||
# parameters | ||
|
||
## Synopsis | ||
|
||
Returns the value of a configuration parameter. | ||
|
||
## Syntax | ||
|
||
```Syntax | ||
parameters('<name>') | ||
``` | ||
|
||
## Description | ||
|
||
The `parameters()` function returns the value of a specific parameter. You must pass the name of | ||
a valid parameter. When using this function for a resource instance, DSC validates the instance | ||
properties after this function runs and before calling the resource for the current operation. If | ||
the referenced parameter value is invalid for the property, DSC raises a validation error. | ||
|
||
For more information about defining parameters in a configuration document, see | ||
[DSC Configuration document parameter schema][01]. | ||
|
||
## Examples | ||
|
||
### Example 1 - Use a parameter as a resource instance property value | ||
|
||
The configuration uses the `parameters()` function to echo the value of the `message` parameter. | ||
|
||
```yaml | ||
# parameters.example.1.dsc.config.yaml | ||
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/10/config/document.json | ||
parameters: | ||
message: | ||
type: string | ||
defaultValue: Hello, world! | ||
resources: | ||
- name: Echo message parameter | ||
type: Test/Echo | ||
properties: | ||
text: "[parameters('message')]" | ||
``` | ||
First, get the current state of the configuration without overriding the parameters with the | ||
[--parameters][02] or [`--parameters_file`][03] options. The output shows the default value for the | ||
`message` parameter. | ||
|
||
```bash | ||
config_file=parameters.example.1.dsc.config.yaml | ||
cat $config_file | dsc config get | ||
``` | ||
|
||
```yaml | ||
results: | ||
- name: Echo message parameter | ||
type: Test/Echo | ||
result: | ||
actualState: | ||
text: Hello, world! | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
Next, override the `message` parameter with the `--parameters` option. | ||
|
||
```bash | ||
params='{"parameters": {"message": "Hi, override."}}' | ||
cat $config_file | dsc config --parameters $params get | ||
``` | ||
|
||
```yaml | ||
results: | ||
- name: Echo message parameter | ||
type: Test/Echo | ||
result: | ||
actualState: | ||
text: Hi, override. | ||
messages: [] | ||
hadErrors: false | ||
``` | ||
|
||
## Parameters | ||
|
||
### name | ||
|
||
The name of the parameter to return. | ||
|
||
```yaml | ||
Type: string | ||
Required: true | ||
MinimumCount: 1 | ||
MaximumCount: 1 | ||
``` | ||
|
||
## Output | ||
|
||
The output of the function is the value of the specified parameter. | ||
|
||
```yaml | ||
Type: [string, int, bool, object, array] | ||
``` | ||
|
||
<!-- Link reference definitions --> | ||
[01]: ../parameter.md | ||
[02]: ../../../cli/config/command.md#-p---parameters | ||
[03]: ../../../cli/config/command.md#-f---parameters_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters