mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix a possible issue with comparing values with $null (#37763)
This PR includes: - Fix $null comparison. - Simplify Get-AnsibleParam in the same effort
This commit is contained in:
parent
f69e3e1cec
commit
5f6a350b3a
1 changed files with 43 additions and 43 deletions
|
@ -201,11 +201,12 @@ Function Get-AnsibleParam($obj, $name, $default = $null, $resultobj = @{}, $fail
|
|||
}
|
||||
}
|
||||
|
||||
# If $value -eq $null, the parameter was unspecified by the user (deliberately or not)
|
||||
# If $null -eq $value, the parameter was unspecified by the user (deliberately or not)
|
||||
# Please leave $null-values intact, modules need to know if a parameter was specified
|
||||
# When $value is already an array, we cannot rely on the null check, as an empty list
|
||||
# is seen as null in the check below
|
||||
if ($null -ne $value -or $value -is [array]) {
|
||||
if ($null -eq $value) {
|
||||
return $null
|
||||
}
|
||||
|
||||
if ($type -eq "path") {
|
||||
# Expand environment variables on path-type
|
||||
$value = Expand-Environment($value)
|
||||
|
@ -249,7 +250,6 @@ Function Get-AnsibleParam($obj, $name, $default = $null, $resultobj = @{}, $fail
|
|||
# , is not a typo, forces it to return as a list when it is empty or only has 1 entry
|
||||
return ,$value
|
||||
}
|
||||
}
|
||||
|
||||
return $value
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue