Commit Graph

9 Commits (7cb489eca3bb167ac9e22b310075e944b8254a27)

Author SHA1 Message Date
Trond Hindenes 72760f5999 All changes referenced in PRs #8767 , #8768 , #8769 :
This changes the get-attr function slightly, and lets the module specify whether a param is needed and auto-fails if it is not present. A module can now verify params like so::
 $params = Parse-Args $args;
 $result = New-Object psobject;
 Set-Attr $result "changed" $false;
 $path = Get-Attr -obj $params -name path -failifempty $true -resultobj $result

or

$params = Parse-Args $args;
 $result = New-Object psobject;
 Set-Attr $result "changed" $false;
 $path = Get-Attr -obj $params -name path -failifempty $true -emptyattributefailmessage "Oh man. You forgot the main part!" -resultobj $result

slight tweak in how the powershell module converts to json in order to support nested objects (allows for more complex facts, among others)

This script gathers some extended facts on windows hosts in a json array attribute called "ansible_interfaces". This info is needed for some network-related modules I'm working on. Required the update to powershell.ps1 to return deeply nested json objects.
10 years ago
Matt Martz 09dd535296 Make helper functions more robust against undefined powershell objects 10 years ago
Matt Martz df8866b8bd Add examples for how to use powershell common functions 10 years ago
Matt Martz e4e610565c Add convenience function (Get-Attr) for getting an attribute/member from a powershell psobject 10 years ago
Matt Martz 90c98ada7c Add ConvertTo-Bool filter function in powershell common code 10 years ago
Chris Church 243cd877ae Add integration tests for fetch/slurp, make powershell fetch/slurp work as close as possible to existing fetch/slurp modules. 10 years ago
Matt Martz 97f4f56286 Add Exit-Json and Fail-Json powershell helper functions 10 years ago
Matt Martz a25c441300 Add shared functions to module_utils/powershell.ps1 and refactor powershell modules to utilize the common powershell code 10 years ago
Michael DeHaan 627ff30a6f Add module replacer capability for powershell files. 10 years ago