Skip to content

Commit

Permalink
gitlab_*: remove deprecated functionalities
Browse files Browse the repository at this point in the history
* Documentation update
* Remove deprecated functionalities

Fixes: ansible#61898 ansible#61897 ansible#61896 ansible#61895 ansible#61894 ansible#61893

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
  • Loading branch information
Akasurde committed Sep 6, 2019
1 parent 7f4328a commit 7158f2b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 212 deletions.
32 changes: 10 additions & 22 deletions lib/ansible/modules/source_control/gitlab_deploy_key.py
Expand Up @@ -34,17 +34,14 @@
- GitLab token for logging in.
version_added: "2.8"
type: str
aliases:
- private_token
- access_token
project:
description:
- Id or Full path of project in the form of group/name
- Id or Full path of project in the form of group/name.
required: true
type: str
title:
description:
- Deploy key's title
- Deploy key's title.
required: true
type: str
key:
Expand All @@ -54,13 +51,13 @@
type: str
can_push:
description:
- Whether this key can push to the project
- Whether this key can push to the project.
type: bool
default: no
state:
description:
- When C(present) the deploy key added to the project if it doesn't exist.
- When C(absent) it will be removed from the project if it exists
- When C(absent) it will be removed from the project if it exists.
required: true
default: present
type: str
Expand All @@ -71,7 +68,7 @@
- name: "Adding a project deploy key"
gitlab_deploy_key:
api_url: https://gitlab.example.com/
api_token: "{{ access_token }}"
api_token: "{{ api_token }}"
project: "my_group/my_project"
title: "Jenkins CI"
state: present
Expand All @@ -80,7 +77,7 @@
- name: "Update the above deploy key to add push access"
gitlab_deploy_key:
api_url: https://gitlab.example.com/
api_token: "{{ access_token }}"
api_token: "{{ api_token }}"
project: "my_group/my_project"
title: "Jenkins CI"
state: present
Expand All @@ -89,7 +86,7 @@
- name: "Remove the previous deploy key from the project"
gitlab_deploy_key:
api_url: https://gitlab.example.com/
api_token: "{{ access_token }}"
api_token: "{{ api_token }}"
project: "my_group/my_project"
state: absent
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."
Expand Down Expand Up @@ -120,7 +117,6 @@
type: dict
'''

import os
import re
import traceback

Expand Down Expand Up @@ -181,7 +177,7 @@ def createOrUpdateDeployKey(self, project, key_title, key_key, options):

'''
@param project Project Object
@param arguments Attributs of the deployKey
@param arguments Attributes of the deployKey
'''
def createDeployKey(self, project, arguments):
if self._module.check_mode:
Expand All @@ -196,7 +192,7 @@ def createDeployKey(self, project, arguments):

'''
@param deployKey Deploy Key Object
@param arguments Attributs of the deployKey
@param arguments Attributes of the deployKey
'''
def updateDeployKey(self, deployKey, arguments):
changed = False
Expand Down Expand Up @@ -238,16 +234,10 @@ def deleteDeployKey(self):
return self.deployKeyObject.delete()


def deprecation_warning(module):
deprecated_aliases = ['private_token', 'access_token']

module.deprecate("Aliases \'{aliases}\' are deprecated".format(aliases='\', \''.join(deprecated_aliases)), "2.10")


def main():
argument_spec = basic_auth_argument_spec()
argument_spec.update(dict(
api_token=dict(type='str', no_log=True, aliases=["private_token", "access_token"]),
api_token=dict(type='str', no_log=True),
state=dict(type='str', default="present", choices=["absent", "present"]),
project=dict(type='str', required=True),
key=dict(type='str', required=True),
Expand All @@ -270,8 +260,6 @@ def main():
supports_check_mode=True,
)

deprecation_warning(module)

gitlab_url = re.sub('/api.*', '', module.params['api_url'])
validate_certs = module.params['validate_certs']
gitlab_user = module.params['api_username']
Expand Down
57 changes: 8 additions & 49 deletions lib/ansible/modules/source_control/gitlab_group.py
Expand Up @@ -29,33 +29,18 @@
extends_documentation_fragment:
- auth_basic
options:
server_url:
description:
- The URL of the GitLab server, with protocol (i.e. http or https).
required: true
type: str
login_user:
description:
- GitLab user name.
type: str
login_password:
description:
- GitLab password for login_user
type: str
api_token:
description:
- GitLab token for logging in.
type: str
aliases:
- login_token
name:
description:
- Name of the group you want to create.
required: true
type: str
path:
description:
- The path of the group you want to create, this will be server_url/group_path
- The path of the group you want to create, this will be api_url/group_path
- If not supplied, the group_name will be used.
type: str
description:
Expand Down Expand Up @@ -141,7 +126,6 @@
type: dict
'''

import os
import traceback

GITLAB_IMP_ERR = None
Expand Down Expand Up @@ -211,7 +195,7 @@ def createOrUpdateGroup(self, name, parent, options):
return False

'''
@param arguments Attributs of the group
@param arguments Attributes of the group
'''
def createGroup(self, arguments):
if self._module.check_mode:
Expand All @@ -226,7 +210,7 @@ def createGroup(self, arguments):

'''
@param group Group Object
@param arguments Attributs of the group
@param arguments Attributes of the group
'''
def updateGroup(self, group, arguments):
changed = False
Expand Down Expand Up @@ -267,19 +251,10 @@ def existsGroup(self, project_identifier):
return False


def deprecation_warning(module):
deprecated_aliases = ['login_token']

module.deprecate("Aliases \'{aliases}\' are deprecated".format(aliases='\', \''.join(deprecated_aliases)), "2.10")


def main():
argument_spec = basic_auth_argument_spec()
argument_spec.update(dict(
server_url=dict(type='str', required=True, removed_in_version="2.10"),
login_user=dict(type='str', no_log=True, removed_in_version="2.10"),
login_password=dict(type='str', no_log=True, removed_in_version="2.10"),
api_token=dict(type='str', no_log=True, aliases=["login_token"]),
api_token=dict(type='str', no_log=True),
name=dict(type='str', required=True),
path=dict(type='str'),
description=dict(type='str'),
Expand All @@ -291,38 +266,22 @@ def main():
module = AnsibleModule(
argument_spec=argument_spec,
mutually_exclusive=[
['api_url', 'server_url'],
['api_username', 'login_user'],
['api_password', 'login_password'],
['api_username', 'api_token'],
['api_password', 'api_token'],
['login_user', 'login_token'],
['login_password', 'login_token']
],
required_together=[
['api_username', 'api_password'],
['login_user', 'login_password'],
],
required_one_of=[
['api_username', 'api_token', 'login_user', 'login_token']
['api_username', 'api_token']
],
supports_check_mode=True,
)

deprecation_warning(module)

server_url = module.params['server_url']
login_user = module.params['login_user']
login_password = module.params['login_password']

api_url = module.params['api_url']
validate_certs = module.params['validate_certs']
api_user = module.params['api_username']
api_password = module.params['api_password']

gitlab_url = server_url if api_url is None else api_url
gitlab_user = login_user if api_user is None else api_user
gitlab_password = login_password if api_password is None else api_password
gitlab_url = module.params['api_url']
gitlab_user = module.params['api_username']
gitlab_password = module.params['api_password']
gitlab_token = module.params['api_token']

group_name = module.params['name']
Expand Down
18 changes: 3 additions & 15 deletions lib/ansible/modules/source_control/gitlab_hook.py
Expand Up @@ -35,9 +35,6 @@
- GitLab token for logging in.
version_added: "2.8"
type: str
aliases:
- private_token
- access_token
project:
description:
- Id or Full path of the project in the form of group/name.
Expand Down Expand Up @@ -165,7 +162,6 @@
type: dict
'''

import os
import re
import traceback

Expand Down Expand Up @@ -242,7 +238,7 @@ def createOrUpdateHook(self, project, hook_url, options):

'''
@param project Project Object
@param arguments Attributs of the hook
@param arguments Attributes of the hook
'''
def createHook(self, project, arguments):
if self._module.check_mode:
Expand All @@ -254,7 +250,7 @@ def createHook(self, project, arguments):

'''
@param hook Hook Object
@param arguments Attributs of the hook
@param arguments Attributes of the hook
'''
def updateHook(self, hook, arguments):
changed = False
Expand Down Expand Up @@ -296,16 +292,10 @@ def deleteHook(self):
return self.hookObject.delete()


def deprecation_warning(module):
deprecated_aliases = ['private_token', 'access_token']

module.deprecate("Aliases \'{aliases}\' are deprecated".format(aliases='\', \''.join(deprecated_aliases)), "2.10")


def main():
argument_spec = basic_auth_argument_spec()
argument_spec.update(dict(
api_token=dict(type='str', no_log=True, aliases=["private_token", "access_token"]),
api_token=dict(type='str', no_log=True),
state=dict(type='str', default="present", choices=["absent", "present"]),
project=dict(type='str', required=True),
hook_url=dict(type='str', required=True),
Expand Down Expand Up @@ -336,8 +326,6 @@ def main():
supports_check_mode=True,
)

deprecation_warning(module)

gitlab_url = re.sub('/api.*', '', module.params['api_url'])
validate_certs = module.params['validate_certs']
gitlab_user = module.params['api_username']
Expand Down

0 comments on commit 7158f2b

Please sign in to comment.