mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Windows modules: Add -type "path" to path parameters (#20282)
This PR is based on #20164 functionality to specify the parameter type (e.g. as done for python modules). In this case only -type "path" has a specific meaning, as it will expand environment variables for paths. Which is typically done on Windows. So you can do: - win_copy: src: files/some.doc dest: '%UserProfile%\My Documents'
This commit is contained in:
parent
5afc0d0c58
commit
7be39ca553
11 changed files with 22 additions and 22 deletions
|
@ -27,14 +27,14 @@ $result = New-Object psobject @{
|
|||
changed = $false
|
||||
}
|
||||
|
||||
$creates = Get-AnsibleParam -obj $params -name "creates"
|
||||
$creates = Get-AnsibleParam -obj $params -name "creates" -type "path"
|
||||
If ($creates -ne $null) {
|
||||
If (Test-Path $params.creates) {
|
||||
Exit-Json $result "The 'creates' file or directory already exists."
|
||||
}
|
||||
}
|
||||
|
||||
$src = Get-AnsibleParam -obj $params -name "src" -failifempty $true
|
||||
$src = Get-AnsibleParam -obj $params -name "src" -type "path" -failifempty $true
|
||||
If (-Not (Test-Path -path $src)){
|
||||
Fail-Json $result "src file: $src does not exist."
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ If (-Not (Test-Path -path $src)){
|
|||
$ext = [System.IO.Path]::GetExtension($src)
|
||||
|
||||
|
||||
$dest = Get-AnsibleParam -obj $params -name "dest" -failifempty $true
|
||||
$dest = Get-AnsibleParam -obj $params -name "dest" -type "path" -failifempty $true
|
||||
If (-Not (Test-Path $dest -PathType Container)){
|
||||
Try{
|
||||
New-Item -itemtype directory -path $dest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue