mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
* Windows: Add special parameter types Adding explicit parameter types now exposes this information in the module documentation, and proves really helpful. We only do this for non-string types as strings, mostly because strings are implicit. PS We also make copyright statements consistent and use #Requires for explicit library imports * Type "string" must be type "str" * A few more Copyright corrections * More fixes * Don't add file encoding to Powershell files * Don't add missing interfacetypes parameter Otherwise CI demands an incorrect version_added * Small fix
28 lines
723 B
PowerShell
28 lines
723 B
PowerShell
#!powershell
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
#Requires -Module Ansible.ModuleUtils.Legacy
|
|
|
|
$params = Parse-Args $args -supports_check_mode $true;
|
|
$src = Get-AnsibleParam -obj $params -name "src" -type "path" -aliases "path" -failifempty $true;
|
|
|
|
$result = @{
|
|
changed = $false;
|
|
}
|
|
|
|
If (Test-Path -Path $src -PathType Leaf)
|
|
{
|
|
$bytes = [System.IO.File]::ReadAllBytes($src);
|
|
$result.content = [System.Convert]::ToBase64String($bytes);
|
|
$result.encoding = "base64";
|
|
Exit-Json $result;
|
|
}
|
|
ElseIf (Test-Path -Path $src -PathType Container)
|
|
{
|
|
Fail-Json $result "Path $src is a directory";
|
|
}
|
|
Else
|
|
{
|
|
Fail-Json $result "Path $src is not found";
|
|
}
|