-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Refactor of consul modules #7826
Refactor of consul modules #7826
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Hopefully fixed the ansible-test issues. I noticed that |
This comment was marked as outdated.
This comment was marked as outdated.
c9b9ad5
to
580f9a9
Compare
580f9a9
to
1260acc
Compare
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.
Thanks for your contribution!
Two first comments:
plugins/doc_fragments/consul.py
Outdated
description: | ||
- The protocol scheme on which the consul agent is running. | ||
default: http | ||
choices: [ http, https ] |
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.
Adding the choices
here is a breaking change. (Or was it absolutely impossible to specify anything else than http
and https
as the scheme before?)
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.
I wouldn't know what else one could specify. But I'll happily remove it if you think it is to dangerous.
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.
I guess it's better to not have choices here then. You could mention both choices in the description
if you want, if you want to make sure users know what they can specify here (that the second choices is https
is probably not completely obvious to everyone).
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.
It is a weird setting anyways, in the long run it would probably make more sense to deprecate this and have a simple ssl on/off toggle.
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.
If this change remains, this PR cannot be merged because it contains a breaking change.
1260acc
to
ebebb13
Compare
It uses deprecated APIs disabled since Consul 1.11 (which is EOL), don't bother updating the module anymore.
@felixfontein I think this is review ready. The rewrite does not cover As for While on it I dropped the dependency on For me this is basically foundational work to be able to add binding rules and acl auth methods via later commits. But I'd love to get this reviewed and merged before because it improves stuff independently. |
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.
I haven't yet checked the module code changes.
Please add a changelog fragment.
Thank you for the review. I will fix it over the course of the week. I might have more questions so I know what to look for and where next time and you don't have to tell me to fix obvious stuff then... 😄
…On Tue, Jan 16, 2024, at 22:37, Felix Fontein wrote:
***@***.**** commented on this pull request.
I haven't yet checked the module code changes.
Please add a changelog fragment
<https://docs.ansible.com/ansible/devel/community/collection_development_process.html#creating-a-changelog-fragment>.
In plugins/module_utils/consul.py
<#7826 (comment)>:
> @@ -5,25 +5,93 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import absolute_import, division, print_function
-__metaclass__ = type
Please keep `__metaclass = type` next to `from __future__ import ...`.
In plugins/module_utils/consul.py
<#7826 (comment)>:
>
-def get_consul_url(configuration):
This function is part of the public API of the collection and needs to
stay until the next major release.
(Same for `get_auth_headers` and `handle_consul_response_error` below.)
In plugins/modules/consul_session.py
<#7826 (comment)>:
> - token:
- description:
- - The token key identifying an ACL rule set that controls access to
- the key value pair.
- type: str
- version_added: 5.6.0
` token:
version_added: 5.6.0
`
needs to stay.
—
Reply to this email directly, view it on GitHub
<#7826 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAT5C2QDLKNTR3PLFJXX3TYO3XLHAVCNFSM6AAAAABBYS32FSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQMRVGE3TKOBXGA>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
854c2c8
to
0d738bd
Compare
I think I managed to address all comments, let me know if I missed something, thanks! |
0d738bd
to
33ad1d8
Compare
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 good to me. Do you want to do more changes, or should I merge this?
As far as the refactoring goes, I think I am done with it. If possible I would like to mark |
I would simply rename That should be clear enough :) |
d3c04ad
to
0421fca
Compare
Okay, I have marked it private and added a note to the doc string. Let me know if there is anything else needed. I will be working on the new modules now. |
@@ -135,22 +103,11 @@ | |||
""" | |||
|
|||
from ansible.module_utils.basic import AnsibleModule | |||
from ansible_collections.community.general.plugins.module_utils.consul import ( | |||
_ConsulModule, auth_argument_spec) |
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.
Here you could also do
_ConsulModule, auth_argument_spec) | |
_ConsulModule as ConsulModule, auth_argument_spec) |
to avoid propagating the rename to the modules, but let's keep it at is now :)
44679e7
into
ansible-collections:main
Backport to stable-8: 💚 backport PR created✅ Backport PR branch: Backported as #7877 🤖 @patchback |
* Extract common functionality. * Refactor duplicated code into module_utils. * Fixed ansible-test issues. * Address review comments. * Revert changes to consul_acl. It uses deprecated APIs disabled since Consul 1.11 (which is EOL), don't bother updating the module anymore. * Remove unused code. * Merge token into default doc fragment. * JSON all the way down. * extract validation tests into custom file and prep for requests removal. * Removed dependency on requests. * Initial test for consul_kv. * fixup license headers. * Revert changes to consul.py since it utilizes python-consul. * Disable the lookup test for now. * Fix python 2.7 support. * Address review comments. * Address review comments. * Addec changelog fragment. * Mark ConsulModule as private. (cherry picked from commit 44679e7)
@apollo13 thanks a lot for your contribution! |
) Refactor of consul modules (#7826) * Extract common functionality. * Refactor duplicated code into module_utils. * Fixed ansible-test issues. * Address review comments. * Revert changes to consul_acl. It uses deprecated APIs disabled since Consul 1.11 (which is EOL), don't bother updating the module anymore. * Remove unused code. * Merge token into default doc fragment. * JSON all the way down. * extract validation tests into custom file and prep for requests removal. * Removed dependency on requests. * Initial test for consul_kv. * fixup license headers. * Revert changes to consul.py since it utilizes python-consul. * Disable the lookup test for now. * Fix python 2.7 support. * Address review comments. * Address review comments. * Addec changelog fragment. * Mark ConsulModule as private. (cherry picked from commit 44679e7) Co-authored-by: Florian Apolloner <[email protected]>
SUMMARY
Refactors common code from consul_modules into module_utils
ISSUE TYPE
COMPONENT NAME
consul