Skip to content
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

Move follow_redirects parameter #82336

Open
wants to merge 9 commits into
base: devel
Choose a base branch
from

Conversation

monsdar
Copy link

@monsdar monsdar commented Dec 3, 2023

SUMMARY

Moves the follow_redirects parameter to the url_argument_spec function so external modules like community.general.rundeck_project could use it as well without having to copy it.

Fixes #82335

ISSUE TYPE
  • Feature Pull Request

@felixfontein
Copy link
Contributor

You also need to update the docs fragment (and move the documentation there).

I'm not sure this is a good solution though, since this is an option that shouldn't be always there for modules using this. It should rather be opt-in, i.e. have another function like url_argument_spec_redirect() in lib/ansible/module_utils/urls.py and another docs fragment (f.ex. ansible.builtin.url.redirect) for the corresponding docs. Then modules can opt-in to this feature if it makes sense for them.

(TBH it probably also makes sense to split up the existing url_argument_spec into different parts. Right now most modules using the module utils only need a subset of it. Having multiple composable parts would make it a lot easier to reuse the parts you actually need. But that's more of a long-term project and needs discussion with the Core team first, I guess.)

@monsdar
Copy link
Author

monsdar commented Dec 3, 2023

I made the redirect-spec optional by adding it into its own function. I also created a corresponding doc_fragment and made ansible.builtin.uri use this instead of defining the parameter itself.

Offtopic: I'm a bit wondered why the module isn't using the uri-doc_fragment at all. Is this on purpose? Perhaps the docs should be merged into the doc_fragment.

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You definitely also need a changelog fragment.

Also please note that the url lookup also has follow_redirects, although with a different description, a different default, a version_added, etc. Here you can use the ability to overwrite docs fragments, by including the docs fragment, and specifying

  follow_redirects:
    description: String of urllib2, all/yes, safe, none to determine how redirects are followed
    version_added: "2.10"
    default: 'urllib2'
    vars:
        - name: ansible_lookup_url_follow_redirects
    env:
        - name: ANSIBLE_LOOKUP_URL_FOLLOW_REDIRECTS
    ini:
        - section: url_lookup
          key: follow_redirects

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally not add a new docs fragment, but add a sub-docs fragment to the url docs fragment. Not sure what the Core team prefers though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot find any docs on this, but it sounds like the way to go. Could you give me a pointer on how to implement it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the sub-doc fragment. I'm unsure about the uri-lookup docs though. The default there is urllib2 while the uri-module has safe as default. Would this be overwritten in a wrong manner?

lib/ansible/plugins/doc_fragments/url_redirect.py Outdated Show resolved Hide resolved
@ansibot ansibot added feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. module This issue/PR relates to a module. has_issue labels Dec 4, 2023
@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Dec 7, 2023
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Dec 14, 2023
@monsdar
Copy link
Author

monsdar commented Jan 8, 2024

Sorry for the long pause, Christmas got in the way 👀

@webknjaz webknjaz added the ci_verified Changes made in this PR are causing tests to fail. label Jan 8, 2024
@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 8, 2024
@ansibot
Copy link
Contributor

ansibot commented Jan 8, 2024

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/plugins/doc_fragments/url.py:89:0: missing-final-newline: Final newline missing

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/plugins/doc_fragments/url.py:89:4: W292: no newline at end of file

click here for bot help

@ansibot ansibot removed ci_verified Changes made in this PR are causing tests to fail. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 8, 2024
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 9, 2024
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request. has_issue module This issue/PR relates to a module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add parameter follow_redirects to the list of url_argument_spec
5 participants