Debian Codegraph @

test/support/windows-integration/plugins/modules/slurp.ps1

raw
1 #!powershell
2
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 #Requires -Module Ansible.ModuleUtils.Legacy
6
7 $params = Parse-Args $args -supports_check_mode $true;
8 $src = Get-AnsibleParam -obj $params -name "src" -type "path" -aliases "path" -failifempty $true;
9
10 $result = @{
11 changed = $false;
12 }
13
14 If (Test-Path -LiteralPath $src -PathType Leaf)
15 {
16 $bytes = [System.IO.File]::ReadAllBytes($src);
17 $result.content = [System.Convert]::ToBase64String($bytes);
18 $result.encoding = "base64";
19 Exit-Json $result;
20 }
21 ElseIf (Test-Path -LiteralPath $src -PathType Container)
22 {
23 Fail-Json $result "Path $src is a directory";
24 }
25 Else
26 {
27 Fail-Json $result "Path $src is not found";
28 }