community.general icon indicating copy to clipboard operation
community.general copied to clipboard

New module: Gitlab integration

Open drzraf opened this issue 4 years ago • 33 comments

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:

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.

drzraf avatar Mar 29 '21 17:03 drzraf

cc @Lunik @Shaps @dj-wasabi @marwatk @scodeman @waheedi @zanssa click here for bot help

ansibullbot avatar Mar 30 '21 06:03 ansibullbot

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)

drzraf avatar Apr 05 '21 15:04 drzraf

Some months ago, GitLab services were renamed to GitLab integrations. Should I take that into account :S ?

drzraf avatar Apr 11 '21 16:04 drzraf

Some months ago, GitLab services were renamed to GitLab integrations. 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.

felixfontein avatar Apr 17 '21 12:04 felixfontein

Done. Note that python-gitlab still name them Project services

drzraf avatar Apr 18 '21 00:04 drzraf

cc @metanovii click here for bot help

ansibullbot avatar Jul 08 '21 12:07 ansibullbot

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.

felixfontein avatar Jul 26 '21 15:07 felixfontein

@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

felixfontein avatar Sep 13 '21 05:09 felixfontein

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)

drzraf avatar Sep 14 '21 12:09 drzraf

Cc @sh0shin

russoz avatar Nov 13 '21 03:11 russoz

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.

drzraf avatar Feb 17 '22 14:02 drzraf

cc @lgatellier @nejch click here for bot help

ansibullbot avatar Feb 17 '22 14:02 ansibullbot

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

click here for bot help

ansibullbot avatar Feb 17 '22 14:02 ansibullbot

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

click here for bot help

ansibullbot avatar Feb 17 '22 15:02 ansibullbot

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.

felixfontein avatar Feb 17 '22 19:02 felixfontein

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.

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?

drzraf avatar Feb 17 '22 21:02 drzraf

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.

felixfontein avatar Feb 17 '22 22:02 felixfontein

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)

drzraf avatar Feb 18 '22 01:02 drzraf

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(-)

drzraf avatar Feb 18 '22 02:02 drzraf

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

click here for bot help

ansibullbot avatar Feb 18 '22 02:02 ansibullbot

cc @suukit click here for bot help

ansibullbot avatar Mar 12 '22 14:03 ansibullbot

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

felixfontein avatar Apr 26 '22 20:04 felixfontein

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.

felixfontein avatar Nov 03 '22 06:11 felixfontein

Do you still plan to update this PR according to the review comments?

needs_info

felixfontein avatar Nov 08 '22 19:11 felixfontein

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.

drzraf avatar Nov 11 '22 21:11 drzraf

Sorry but I still disagree with the reviewers suggestion of reimplementing, badly, _load_params instead 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.

felixfontein avatar Nov 12 '22 08:11 felixfontein

needs_info

felixfontein avatar May 10 '23 05:05 felixfontein

You can reuse it, but not in the way you are doing it right now.

Screenshot from 2023-05-11 08-13-12

...

Screenshot from 2023-05-11 08-11-11

I'm happy you changed your mind but how do you suggest to use it differently?

drzraf avatar May 11 '23 11:05 drzraf

I didn't change my mind. Using internal things in production code is still a bad idea.

felixfontein avatar May 11 '23 18:05 felixfontein