Improve synthetic diff array for test operations
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
Direzione di ricerca
L'issue non indica file di implementazione né test. Inizia individuando la generazione dei diff sintetici e la gestione dello schema delle risorse per le operazioni di test DSC, quindi confronta il modo in cui vengono rappresentate le proprietà di sola lettura e di sola scrittura. Il lavoro sarà completato quando i diff dei risultati non segnaleranno più proprietà che non possono essere fornite o restituite, con una copertura per le risorse di script PowerShell transitorie.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary of the new feature / enhancement
As a system administrator using DSC to manage my infrastructure,
I want thedifferingPropertiesandchangedPropertiesfields of results to accurately reflect configurable properties of the resource without substantial noise,
So that I can quickly review result data.
Currently, the synthetic diff array of property names for DSC resource testoperations has insufficient handling for read-only and write-only properties. This problem is most clearly raised for the transitional PowerShell script resources, where you get results like this (tested with 3.4.0-preview.1):
desiredState:
input:
configFilePath: ~/foo/bar/config.toml
settings:
foo: bar
getScript: |-
param($data)
function Get-Config {
[CmdletBinding(DefaultParameterSetName = 'ByPath')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByPath')]
[string]$Path,
[Parameter(Mandatory, ParameterSetName = 'DefaultConfig')]
[switch]$Default
)
# Elided for brevity
}
if ([string]::IsNullOrEmpty($data.configFilePath)) {
Write-Warning "No config file path provided. Using default configuration."
Get-Config -Default
} else {
Get-Config -Path $data.configFilePath
}
testScript: |-
param($data)
function Get-Config {
[CmdletBinding(DefaultParameterSetName = 'ByPath')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByPath')]
[string]$Path,
[Parameter(Mandatory, ParameterSetName = 'DefaultConfig')]
[switch]$Default
)
# Elided for brevity
}
function Test-Config {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[pscustomobject]$actual,
[Parameter(Mandatory)]
[pscustomobject]$desired
)
# Elided for brevity
}
if ($null -eq $data.settings) {
throw "Unable to test configuration without specific settings"
}
if ($data.settings -isnot [System.Management.Automation.PSCustomObject]) {
throw "Unable to test configuration; settings input data must be an object but was [$($data.settings.GetType().FullName)]"
}
$actualState = if ([string]::IsNullOrEmpty($data.configFilePath)) {
Write-Warning "No config file path provided. Using default configuration."
Get-Config -Default
} else {
Get-Config -Path $data.configFilePath
}
Test-Config -Actual $actualState.settings -Desired $data.settings
actualState:
_inDesiredState: false
inDesiredState: false
differingProperties:
- input
- getScript
- testScript
Not only is the result object difficult to read, but the actualState tells the user almost nothing (the _inDesiredState field is hoisted to the top level of the result), but the differing properties field is useless - input and *Script properties are write-only, so the resource will never return them, and output/_inDesiredState are read-only, so the user should never supply them.
The result is a substantial amount of noise with very little information for the user. The only way to more clearly indicate result granularity is for a resource to emit trace messages about how the instance is out-of-state.
Reproducing the output
Run the following command to reproduce the full output noted above:
dsc resource test -r Microsoft.DSC.Transitional/PowerShellScript -i @'
input:
configFilePath: ~/foo/bar/config.toml
settings:
foo: bar
getScript: |-
param($data)
function Get-Config {
[CmdletBinding(DefaultParameterSetName = 'ByPath')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByPath')]
[string]$Path,
[Parameter(Mandatory, ParameterSetName = 'DefaultConfig')]
[switch]$Default
)
if ($Default) {
$Path = "$HOME/.config/default_config.json"
}
[ordered]@{
Path = $Path
settings = [ordered]@{
foo = "baz"
}
}
}
if ([string]::IsNullOrEmpty($data.configFilePath)) {
Write-Warning "No config file path provided. Using default configuration."
Get-Config -Default
} else {
Get-Config -Path $data.configFilePath
}
testScript: |-
param($data)
function Get-Config {
[CmdletBinding(DefaultParameterSetName = 'ByPath')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByPath')]
[string]$Path,
[Parameter(Mandatory, ParameterSetName = 'DefaultConfig')]
[switch]$Default
)
if ($Default) {
$Path = "$HOME/.config/default_config.json"
}
[pscustomobject]@{
path = $Path
settings = [pscustomobject]@{
foo = "baz"
}
}
}
function Test-Config {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[pscustomobject]$actual,
[Parameter(Mandatory)]
[pscustomobject]$desired
)
$inDesiredState = $true
if ($actual.path -ne $desired.path) {
$inDesiredState = $false
}
foreach ($setting in $desired.psobject.Properties.Name) {
if ($actual.$setting -ne $desired.$setting) {
$inDesiredState = $false
}
}
return $inDesiredState
}
if ($null -eq $data.settings) {
throw "Unable to test configuration without specific settings"
}
if ($data.settings -isnot [System.Management.Automation.PSCustomObject]) {
throw "Unable to test configuration; settings input data must be an object but was [$($data.settings.GetType().FullName)]"
}
$actualState = if ([string]::IsNullOrEmpty($data.configFilePath)) {
Write-Warning "No config file path provided. Using default configuration."
Get-Config -Default
} else {
Get-Config -Path $data.configFilePath
}
Test-Config -Actual $actualState.settings -Desired $data.settings
'@
Proposed technical implementation details (optional)
While I don't have a concrete proposal, this issue made me think of two approaches that could help with this problem:
- Introduce special handling for read-only/write-only properties in result data - we probably shouldn't include them in the
differingPropertiesarray, because they'll never match both actual and desired state. - Define a helper keyword for resource schema properties like
x-dsc-hideFromDesiredStateto specifically filter out properties that add a lot of noise to the result object.
- Lingua principale
- Rust
- Stelle
- 526
- Fork
- 76
- Merge medio
- 4g 20h
- PR unite (30g)
- 24
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PowerShell/DSC
-
Issue-Enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
PowerShell/DSC#1729 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Feature Request: Support dsc functions in executable argsForse già presa @SteveL-MSFT l’ha presa 4 giorni fa. ApertaIssue-Enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 62/100
PowerShell/DSC#1722 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Dev-UX Needs Triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
PowerShell/DSC#1694 ·
I maintainer di solito rispondono entro 2 giorni
-
Issue-Enhancement Needs Triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
PowerShell/DSC#1683 · 5 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Issue-Enhancement Needs Triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
PowerShell/DSC#1673 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di PowerShell/DSC
Issue simili
-
area: dogs area: lookout bug security
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 2 giorni
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
OpenDevicePartnership/ina4230#31 ·
I maintainer di solito rispondono entro 1 giorno
-
area:breg criticality:p3 documentation triage:needs-implementation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
registrystack/registry-stack#1713 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
posit-dev/ggsql#565 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno