Skip to content

Commit

Permalink
setup - remvoe dep on shared function (#752)
Browse files Browse the repository at this point in the history
Remove the dep on ConvertFrom-AnsibleJson so that we can start to
deprecate that function in Ansible exec wrapper. This is the only
instance where it is used outside of the exec wrapper and it can easily
be replaced by the custom PSCustomObject enumerator. Luckily this code
path is not used by any of our supported connection plugins. It may be
used by other connection types that cannot pipeline or through local
debugging.
  • Loading branch information
jborean93 authored Jan 26, 2025
1 parent 783928a commit 9d04d78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/setup-json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- setup - Remove dependency on shared function loaded by Ansible
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: ansible
name: windows
version: 2.7.0
version: 2.8.0
readme: README.md
authors:
- Jordan Borean @jborean93
Expand Down
23 changes: 16 additions & 7 deletions plugins/modules/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@ $spec = @{
# This module can be called by the gather_facts action plugin in ansible-base. While it shouldn't add any new options
# we need to make sure the module doesn't break if it does. To do this we need to add any options in the input args
if ($args.Length -gt 0) {
$params = Get-Content -LiteralPath $args[0] | ConvertFrom-AnsibleJson
$params = Get-Content $args[0] | ConvertFrom-Json
if ($params) {
foreach ($prop in $params.PSObject.Properties.Name) {
if ($prop.StartsWith('_') -or $spec.options.ContainsKey($prop)) {
continue
}
$spec.options.$prop = @{ type = 'raw' }
}
}
}
else {
$params = $complex_args
}
if ($params) {
foreach ($param in $params.GetEnumerator()) {
if ($param.Key.StartsWith('_') -or $spec.options.ContainsKey($param.Key)) {
continue
if ($params) {
foreach ($param in $params.GetEnumerator()) {
if ($param.Key.StartsWith('_') -or $spec.options.ContainsKey($param.Key)) {
continue
}
$spec.options."$($param.Key)" = @{ type = 'raw' }
}
$spec.options."$($param.Key)" = @{ type = 'raw' }
}
}


$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)

$measureSubset = $module.Params._measure_subset
Expand Down

0 comments on commit 9d04d78

Please sign in to comment.