From 7b84c0ee801cff4907b2c80c7add964f8bdbb4de Mon Sep 17 00:00:00 2001 From: Guillaume Martinez Date: Mon, 11 Feb 2019 00:30:36 +0100 Subject: [PATCH] gitlab_hook: renaming module name (#51979) * gitlab_hook: renaming module name * gitlab_hook: rename module in documentation * gitlab_hook: remove plural in docs and code * gitlab_hook: fix unit test functions --- .../modules/source_control/_gitlab_hooks.py | 1 + .../{gitlab_hooks.py => gitlab_hook.py} | 14 +++++++------- .../{test_gitlab_hooks.py => test_gitlab_hook.py} | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) create mode 120000 lib/ansible/modules/source_control/_gitlab_hooks.py rename lib/ansible/modules/source_control/{gitlab_hooks.py => gitlab_hook.py} (98%) rename test/units/modules/source_control/{test_gitlab_hooks.py => test_gitlab_hook.py} (89%) diff --git a/lib/ansible/modules/source_control/_gitlab_hooks.py b/lib/ansible/modules/source_control/_gitlab_hooks.py new file mode 120000 index 0000000000..bb7ccd6db1 --- /dev/null +++ b/lib/ansible/modules/source_control/_gitlab_hooks.py @@ -0,0 +1 @@ +gitlab_hook.py \ No newline at end of file diff --git a/lib/ansible/modules/source_control/gitlab_hooks.py b/lib/ansible/modules/source_control/gitlab_hook.py similarity index 98% rename from lib/ansible/modules/source_control/gitlab_hooks.py rename to lib/ansible/modules/source_control/gitlab_hook.py index 574dc92c26..fb6b5f9e45 100644 --- a/lib/ansible/modules/source_control/gitlab_hooks.py +++ b/lib/ansible/modules/source_control/gitlab_hook.py @@ -16,10 +16,10 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' --- -module: gitlab_hooks +module: gitlab_hook short_description: Manages GitLab project hooks. description: - - Adds, updates and removes project hooks + - Adds, updates and removes project hook version_added: "2.6" author: - Marcus Watkins (@marwatk) @@ -111,7 +111,7 @@ options: EXAMPLES = ''' - name: "Adding a project hook" - gitlab_hooks: + gitlab_hook: api_url: https://gitlab.example.com/ api_token: "{{ access_token }}" project: "my_group/my_project" @@ -123,7 +123,7 @@ EXAMPLES = ''' token: "my-super-secret-token-that-my-ci-server-will-check" - name: "Delete the previous hook" - gitlab_hooks: + gitlab_hook: api_url: https://gitlab.example.com/ api_token: "{{ access_token }}" project: "my_group/my_project" @@ -131,7 +131,7 @@ EXAMPLES = ''' state: absent - name: "Delete a hook by numeric project id" - gitlab_hooks: + gitlab_hook: api_url: https://gitlab.example.com/ api_token: "{{ access_token }}" project: 10 @@ -279,7 +279,7 @@ class GitLabHook(object): @param project Project object @param hook_url Url to call on event ''' - def existsHooks(self, project, hook_url): + def existsHook(self, project, hook_url): # When project exists, object will be stored in self.projectObject. hook = self.findHook(project, hook_url) if hook: @@ -376,7 +376,7 @@ def main(): if project is None: module.fail_json(msg="Failed to create hook: project %s doesn't exists" % project_identifier) - hook_exists = gitlab_hook.existsHooks(project, hook_url) + hook_exists = gitlab_hook.existsHook(project, hook_url) if state == 'absent': if hook_exists: diff --git a/test/units/modules/source_control/test_gitlab_hooks.py b/test/units/modules/source_control/test_gitlab_hook.py similarity index 89% rename from test/units/modules/source_control/test_gitlab_hooks.py rename to test/units/modules/source_control/test_gitlab_hook.py index c559147392..5735f663be 100644 --- a/test/units/modules/source_control/test_gitlab_hooks.py +++ b/test/units/modules/source_control/test_gitlab_hook.py @@ -5,7 +5,7 @@ from __future__ import absolute_import -from ansible.modules.source_control.gitlab_hooks import GitLabHook +from ansible.modules.source_control.gitlab_hook import GitLabHook from .gitlab import (GitlabModuleTestCase, python_version_match_requirement, @@ -31,11 +31,11 @@ class TestGitlabHook(GitlabModuleTestCase): def test_hook_exist(self): project = self.gitlab_instance.projects.get(1) - rvalue = self.moduleUtil.existsHooks(project, "http://example.com/hook") + rvalue = self.moduleUtil.existsHook(project, "http://example.com/hook") self.assertEqual(rvalue, True) - rvalue = self.moduleUtil.existsHooks(project, "http://gitlab.com/hook") + rvalue = self.moduleUtil.existsHook(project, "http://gitlab.com/hook") self.assertEqual(rvalue, False) @@ -72,7 +72,7 @@ class TestGitlabHook(GitlabModuleTestCase): def test_delete_hook(self): project = self.gitlab_instance.projects.get(1) - self.moduleUtil.existsHooks(project, "http://example.com/hook") + self.moduleUtil.existsHook(project, "http://example.com/hook") rvalue = self.moduleUtil.deleteHook()