mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07: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
|
# 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
|
if ($null -eq $value) {
|
||||||
# is seen as null in the check below
|
return $null
|
||||||
if ($null -ne $value -or $value -is [array]) {
|
}
|
||||||
|
|
||||||
if ($type -eq "path") {
|
if ($type -eq "path") {
|
||||||
# Expand environment variables on path-type
|
# Expand environment variables on path-type
|
||||||
$value = Expand-Environment($value)
|
$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
|
# , is not a typo, forces it to return as a list when it is empty or only has 1 entry
|
||||||
return ,$value
|
return ,$value
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $value
|
return $value
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue