-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows - Add common util for web requests #54759
Conversation
cc @blakfeld @dagwieers @if-meaton @jhawkesworth @nitzmahone @tksarah |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Another impressive piece of work. The only thing I can think of is maybe to benchmark against existing modules, although I can't think of a reason why performance might change materially (and network conditions are much more likely to affect actual execution time in use) but more testing before merging a big refactoring allways improves confidence that the change will stick. |
3fd6d94
to
5b7a001
Compare
The test
The test
The test
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, one little thing to think about with the default handling on explicit HttpAgent arg vs headers. Much nicer setup in general. I don't love the pre-existing continuation pattern of Invoke-WithWebRequest, but it seems to work OK for most things right now- something that could probably be revisited later if there's a good reason.
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.WebRequest.psm1
Outdated
Show resolved
Hide resolved
Merging to get this out into people's installs so we can hopefully detect any bugs before the 2.9 release. Thanks everyone for the reviews. |
SUMMARY
Adds a common URL handler for PowerShell modules. It tries to combine common elements like shared module arg spec, reduce code duplication for the somewhat convoluted WebRequest class in .NET and add the ability to easily add common module options for URL based modules in the future.
Things I know that still need to be fixed/solved before this can move away from a WIP PR;
Fix validate-modules to load other PS and C# module utils so the module arg spec can be from a util. Currently it fails because we don't load themEdit: Done with Load Ansible module_utils for ps_argspec validator #58571Figure out how we want to document the shared values and when they were added. Right now it just omits the- Doc fragments are more versatile than I expected, have been able to preserve the version_added for specific modules while still sharing the docs as much as possible.version_added
component in the shared doc fragment because some options were present/added in some modules but not othersInvoke-WithWebRequest
is too complicated with it's use of a ScriptBlockWhether- Alternative option was chosen where the module (if passed in) would provide a backup/default value for parameters not explicitly passed inRegister-AnsibleWebRequestParams
is something we want to use. Unfortunately we cannot take advantage of splatting from$module.Params
and this was the next best thing I could find that allowed the module to ignore options that were implemented inside.ISSUE TYPE
COMPONENT NAME
win_get_url
win_uri