Skip to content

Commit

Permalink
Fix empty string nullification
Browse files Browse the repository at this point in the history
  • Loading branch information
Clebam committed Feb 8, 2024
1 parent 9721f08 commit 25efb36
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ Function ConvertTo-CanonicalResult {
if ([string]::IsNullOrEmpty($value)) {
# While PowerShell can happily treat empty strings as valid for returning
# an undefined enum, Puppet expects undefined values to be nil.
$Value = $null
if ($Value -is [string]) {
$Value = ''
}
else {
$Value = $null
}
}

if ($Value.Count -eq 1 -and $Property.Definition -match '\\[\\]') {
Expand Down Expand Up @@ -123,4 +128,4 @@ Function ConvertTo-CanonicalResult {

# Output the final result
$ResultObject
}
}

0 comments on commit 25efb36

Please sign in to comment.