Improve synthetic diff array for test operations
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Der Issue nennt keine Implementierungsdateien oder Tests. Beginne damit, die Generierung synthetischer Diffs und die Verarbeitung des Ressourcenschemas für DSC-Testoperationen zu lokalisieren, und vergleiche anschließend, wie schreibgeschützte und nur beschreibbare Eigenschaften dargestellt werden. Als erledigt gilt die Aufgabe, wenn Ergebnis-Diffs keine Eigenschaften mehr melden, die nicht angegeben oder zurückgegeben werden können, und die Abdeckung für Ressourcen mit Übergangs-PowerShell-Skripten vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 541
- Forks
- 78
- Ø Merge
- 2 T. 22 Std.
- Gemergte PRs (30 T.)
- 17
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus PowerShell/DSC
-
Failure to parse a resource manifest is logged as INFO instead of WARNEvtl. vergeben @SteveL-MSFT hat das vor 3 Tagen übernommen. OffenIssue-Bug Need-Review
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
PowerShell/DSC#1765 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Tracing categoriesEvtl. vergeben @michaeltlombardi hat das vor 5 Tagen übernommen. OffenArea-OpenTelemetry Issue-Enhancement Needs Triage
PowerShell/DSC#1767 · 1 Reaktion · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Issue-Enhancement Needs Triage
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
PowerShell/DSC#1763 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Issue-Enhancement Needs Triage
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
PowerShell/DSC#1760 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Hardening with dsc 3 ?Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. OffenIssue-Enhancement Needs Triage
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 12/100
PowerShell/DSC#1755 · 7 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 67/100
rust-bitcoin/rust-bitcoin#7089 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 2 Tagen
-
area/tools bug session-analysis
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]: Python OpenTelemetrySectionConfig has no file_sinksEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
NVIDIA/NeMo-Relay#1514 ·
Maintainer antworten meist innerhalb von 1 Tag
-
prompting proposal tool triaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
can1357/oh-my-pi#17041 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
nix-community/fenix#262 ·