community.general
community.general copied to clipboard
New module: Gitlab integration
SUMMARY
New module: Gitlab integration services
Fixes https://github.com/ansible/ansible/pull/40053
Reroll of #667
ISSUE TYPE
- New Module Pull Request
COMPONENT NAME
community.general.gitlab_integration
ADDITIONAL INFORMATION
This module provides a way to setup Gitlab integration services using Ansible and supports all services defined by Gitlab.com API (and their corresponding parameters) as of ~~2020/07/09~~ 2022/02/17.
Known bugs:
- Most Gitlab integration services rely upon secret parameter (password, token, api_key) which are write-only (ie: not exposed on GET request). That currently keeps module from being idempotent when such a suboption is used.
- The active state of a service could not be set using the API. Use
state=absentto completely remove the service configuration instead of deactivating it. But some work happened recently on GitLab side, it may be fixed by now.
EXTENDED DEFINITION OF SERVICE
- Their validation is done by doing a redundant initialization of the
AnsibleModule()and modifying the argument spec meanwhile.
~~- The extended definition of services and their suboptions (name, required or not, type) is generated from Gitlab upstream file the 2021/03/29.~~
- The extended definition of services and their suboptions (name, required or not, type) is generated from Gitlab upstream file the 2022/02/17.
cc @Lunik @Shaps @dj-wasabi @marwatk @scodeman @waheedi @zanssa click here for bot help
In https://github.com/ansible-collections/community.general/pull/2129/commits/372f6c56074e8a19d0d128b7c8e9959937b7b611 I tried to add some tests.
Integration can't be run (disabled) so it's mostly an example.
The units tests are more tricky (just mostly added boilerplate code)
Some months ago, GitLab services were renamed to GitLab integrations. Should I take that into account :S ?
Some months ago, GitLab
serviceswere renamed to GitLabintegrations. Should I take that into account :S ?
Just wait a couple of more months until it is renamed something else again, and only then change it. Just joking ;) I guess it's better to update the module now before it has been released, since renaming the module, options, return values etc. later is a huge PITA, and having a different name than it is used in GitLab itself is also confusing to users.
Done. Note that python-gitlab still name them Project services
cc @metanovii click here for bot help
Please note that we added a new sanity test which requires a BOTMETA entry for every new plugin and module. See this section on adding new plugins and modules for details.
@drzraf are you planning on resolving https://github.com/ansible-collections/community.general/pull/2129#discussion_r606197773 ? If not, I think it's best to close this.
needs_info
I'll. Notably renaming to integration. About suboption validation (above thread), I make no promise. I don't see any easy other way than re-instanciation (which, to me, sounds clean, elegant and simply does the work)
Cc @sh0shin
Rebased. About https://github.com/ansible-collections/community.general/pull/2129#discussion_r606197773 I don't see any alternative. With this (double AnsibleModule instanciation), I do strict validation about parameters which helps the user and is very convenient. It's also not forbidden per-se and is working perfectly. So I don't see the reasons for doing the things poorly when they could be done right.
cc @lgatellier @nejch click here for bot help
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'findProject''
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'findProject''
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'findProject''
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)'
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)'
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name 'findProject'
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:189:0: traceback: ImportError: cannot import name findProject
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'gitlabAuthentication''
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'gitlabAuthentication''
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'gitlabAuthentication''
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)'
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:0:0: import-error: Exception attempting to import module for argument_spec introspection, 'cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible_collections/community/general/plugins/module_utils/gitlab.py)'
The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication' from 'ansible_collections.community.general.plugins.module_utils.gitlab' (/root/ansible/ansible_collections/community/general/plugins/module_utils/gitlab.py)
The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name 'gitlabAuthentication'
The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:190:0: traceback: ImportError: cannot import name gitlabAuthentication
Rebased. About #2129 (comment) I don't see any alternative. With this (double AnsibleModule instanciation), I do strict validation about parameters which helps the user and is very convenient. It's also not forbidden per-se and is working perfectly. So I don't see the reasons for doing the things poorly when they could be done right.
I'm afraid we cannot merge the module in that case. Double instantiation of AnsibleModule is undefined behavior and can break at any time.
Rebased. About #2129 (comment) I don't see any alternative. With this (double AnsibleModule instanciation), I do strict validation about parameters which helps the user and is very convenient. It's also not forbidden per-se and is working perfectly. So I don't see the reasons for doing the things poorly when they could be done right.
I'm afraid we cannot merge the module in that case. Double instantiation of
AnsibleModuleis undefined behavior and can break at any time.
Which alternative do you suggest? An opaque dict? Copy/pasting kb of code? Can't we "scope" such an instantiation? Does an (elegant) way to resolve this exists?
Which alternative do you suggest? An opaque dict? Copy/pasting kb of code?
I would write some validation code myself to handle this. Some functions from https://github.com/ansible/ansible/blob/stable-2.9/lib/ansible/module_utils/common/validation.py might be useful.
But isn't a case of single-responsability purpose. Here it's up to the module to create an opaque object of AnsibleModule inside main(). The fact that I create 1, 2 or 10 such objects is totally up to me. I could even del <that AnsibleModule> as well for the sake of mind and to be sure one is created at a time. Said another way, creating/removing an AnsibleModule is totally stateless.
The AnsibleModule documentation even states the following:
Common code for quickly building an ansible module in Python
(although you can write modules with anything that can return JSON).
Quoting the doc for _load_params
''' read the modules parameters and store them globally.
This function may be needed for certain very dynamic custom modules which
want to process the parameters that are being handed the module. Since
this is so closely tied to the implementation of modules we cannot
guarantee API stability for it (it may change between versions) however we
will try not to break it gratuitously. **It is certainly more future-proof
to call this function and consume its outputs than to implement the logic
inside**
I'll try to collects from lib/ansible/module_utils/* to see if I can reuse something (although, again, it's not clear why I couldn't use helpers the way I want, but not the AnsibleModule class the way I want)
See the last commit where I avoided the famous AnsibleModule::__init__() so that you could estimate the "cost" of doing so and make an informed decision.
plugins/modules/source_control/gitlab/gitlab_integration.py | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 8 deletions(-)
The test ansible-test sanity --test pep8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:425:1: E302: expected 2 blank lines, found 1
The test ansible-test sanity --test pep8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:425:1: E302: expected 2 blank lines, found 1
The test ansible-test sanity --test pep8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:425:1: E302: expected 2 blank lines, found 1
The test ansible-test sanity --test pep8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:425:1: E302: expected 2 blank lines, found 1
The test ansible-test sanity --test pep8 [explain] failed with 1 error:
plugins/modules/source_control/gitlab/gitlab_integration.py:425:1: E302: expected 2 blank lines, found 1
cc @suukit click here for bot help
This New Module PR contains a symbolic link from plugins/modules/ to the actual Python file. Since #4562 this is no longer necessary and will soon be flagged as an error. Instead you need to add an entry to meta/runtime.yml, similar to this one: https://github.com/ansible-collections/community.general/blob/main/meta/runtime.yml#L21-L22
See also our updated instructions on creating new modules: https://github.com/ansible-collections/community.general/blob/main/CONTRIBUTING.md#creating-new-modules-or-plugins
Please note that in #5461 the collection repository was restructured to remove the directory tree in plugins/modules/, and the corresponding tree in tests/unit/plugins/modules/. Your PR adds new files into this hierarchy. Please rebase with the current main branch and move your files directly into plugins/modules/. You also can remove the changes to meta/runtime.yml, these are not needed anymore (the corresponding section was removed from CONTRIBUTING.md), and make sure to adjust the new entries in .github/BOTMETA.yml as well.
Do you still plan to update this PR according to the review comments?
needs_info
Do you still plan to update this PR according to the review comments?
Sorry but I still disagree with the reviewers suggestion of reimplementing, badly, the _load_params function instead of reusing it (as original author anticipated in code comment). Drop suboptions validation doesn't seem right either.
I'm using a version of this module locally on a regular basis but I won't produce yet another PR containing bad/inefficient/unmaintainable/inelegant code... without a technical reason being given. I hope reviewers will reconsider their choice.
Although I did the initial PR Jul 17th, 2020, the future of this module's [possible inclusion] is definitely not in my hands.
Good luck to you and/or to other (still) motivated Ansible contributors.
Sorry but I still disagree with the reviewers suggestion of reimplementing, badly,
_load_paramsinstead of reusing it (as code author anticipated) or having to drop suboptions validation altogether.
You can reuse it, but not in the way you are doing it right now.
If you don't want to change the code, you will have to find someone else who can get your module merged. I don't merge things that are simply wrong from my point of view, sorry.
needs_info
You can reuse it, but not in the way you are doing it right now.
...
I'm happy you changed your mind but how do you suggest to use it differently?
I didn't change my mind. Using internal things in production code is still a bad idea.