Provide tips and tricks for includes
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 523
- Forks
- 75
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 24
Description
Summary of the new feature / enhancement
As a user, I don't want to think too much about how the input should be specified whenever using the configurationContent and parameterContent on the Microsoft.DSC/Include resource type.
After experimenting using the new rc.1 version, the only examples available are the ones in the Pester tests. I think most users predominantly will execute dsc.exe through a PowerShell session. Instead of relying on escaping characters, having some tips and tricks available using PowerShell hashtables or using powershell-yaml, will provide benefits for users to see how it should be input correctly.
Here are a few examples of what I mean:
# Example 1 - Using full PowerShell hashtable
$include = [ordered]@{
"`$schema" = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json"
resources = @(
@{
name = "DotNet tool"
type = "Microsoft.DSC/Include"
properties = @{
configurationContent = [ordered]@{
"`$schema" = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json"
parameters = [ordered]@{
PackageId = @{
type = "string"
defaultValue = "powershell"
}
}
resources = @(
[ordered]@{
name = "Use Dotnet tool package"
type = "Microsoft.DSC/PowerShell"
properties = @{
resources = @(
[ordered]@{
name = "Install package by package ID"
type = "Microsoft.DotNet.Dsc/DotNetToolPackage"
properties = @{
PackageId = "[parameters('PackageId')]"
}
}
)
}
}
)
}
}
}
)
}
dsc config get --input ($include | ConvertTo-Json -Depth 10 -Compress)
# Fails with ERROR Parser: Parameter 'PackageId' not found in context
# Example 2 - Split hashtable to get the '\"'
$configDocument = [ordered]@{
"`$schema" = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json"
parameters = [ordered]@{
PackageId = @{
type = "string"
defaultValue = "powershell"
}
}
resources = @(
[ordered]@{
name = "Use Dotnet tool package"
type = "Microsoft.DSC/PowerShell"
properties = @{
resources = @(
[ordered]@{
name = "Install package by package ID"
type = "Microsoft.DotNet.Dsc/DotNetToolPackage"
properties = @{
PackageId = "[parameters('PackageId')]"
}
}
)
}
}
)
}
$resourceInput = $configDocument | ConvertTo-Json -Depth 10 -Compress # <-- Convert it to JSON input
$include = [ordered]@{
"`$schema" = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json"
resources = @(
@{
name = "DotNet tool"
type = "Microsoft.DSC/Include"
properties = @{
configurationContent = $resourceInput
}
}
)
}
dsc config get --input ($include | ConvertTo-Json -Depth 10 -Compress)
# Succeeds
The sample would imply using the example with ConvertTo-Yaml.
Advanced users who are fans of JSON will know that you have to escape the characters. For YAML, it would be the >- multi-string indicator or |.
Proposed technical implementation details (optional)
A tips and tricks article.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Pester tests mentioned in the issue, which currently contain the available Include examples, and review the dsc config get command usage. Add a tips-and-tricks article covering PowerShell hashtables, ConvertTo-Json, powershell-yaml, and JSON/YAML escaping or multiline strings, with examples that show successful input for configurationContent and parameterContent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100