Skip to content

Commit

Permalink
Sort parameters in gitlab_group to aid in adding more params (#8899)
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-lecomte authored Sep 29, 2024
1 parent 8ef77d8 commit ab84f16
Showing 1 changed file with 67 additions and 67 deletions.
134 changes: 67 additions & 67 deletions plugins/modules/gitlab_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,73 +33,73 @@
support: none
options:
name:
auto_devops_enabled:
description:
- Name of the group you want to create.
required: true
type: str
path:
- Default to Auto DevOps pipeline for all projects within this group.
type: bool
version_added: 3.7.0
avatar_path:
description:
- 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
- Absolute path image to configure avatar. File size should not exceed 200 kb.
- This option is only used on creation, not for updates.
type: path
version_added: 4.2.0
description:
description:
- A description for the group.
type: str
state:
force_delete:
description:
- create or delete group.
- Possible values are present and absent.
default: present
- Force delete group even if projects in it.
- Used only when O(state=absent).
type: bool
default: false
version_added: 7.5.0
name:
description:
- Name of the group you want to create.
required: true
type: str
choices: ["present", "absent"]
parent:
description:
- Allow to create subgroups
- Id or Full path of parent group in the form of group/name
type: str
visibility:
path:
description:
- Default visibility of the group
choices: ["private", "internal", "public"]
default: private
- 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
project_creation_level:
description:
- Determine if developers can create projects in the group.
choices: ["developer", "maintainer", "noone"]
type: str
version_added: 3.7.0
auto_devops_enabled:
require_two_factor_authentication:
description:
- Default to Auto DevOps pipeline for all projects within this group.
- Require all users in this group to setup two-factor authentication.
type: bool
version_added: 3.7.0
state:
description:
- create or delete group.
- Possible values are present and absent.
default: present
type: str
choices: ["present", "absent"]
subgroup_creation_level:
description:
- Allowed to create subgroups.
choices: ["maintainer", "owner"]
type: str
version_added: 3.7.0
require_two_factor_authentication:
description:
- Require all users in this group to setup two-factor authentication.
type: bool
version_added: 3.7.0
avatar_path:
description:
- Absolute path image to configure avatar. File size should not exceed 200 kb.
- This option is only used on creation, not for updates.
type: path
version_added: 4.2.0
force_delete:
visibility:
description:
- Force delete group even if projects in it.
- Used only when O(state=absent).
type: bool
default: false
version_added: 7.5.0
- Default visibility of the group
choices: ["private", "internal", "public"]
default: private
type: str
'''

EXAMPLES = '''
Expand Down Expand Up @@ -207,13 +207,13 @@ def create_or_update_group(self, name, parent, options):
parent_id = self.get_group_id(parent)

payload = {
'auto_devops_enabled': options['auto_devops_enabled'],
'name': name,
'path': options['path'],
'parent_id': parent_id,
'visibility': options['visibility'],
'path': options['path'],
'project_creation_level': options['project_creation_level'],
'auto_devops_enabled': options['auto_devops_enabled'],
'subgroup_creation_level': options['subgroup_creation_level'],
'visibility': options['visibility'],
}
if options.get('description'):
payload['description'] = options['description']
Expand All @@ -230,13 +230,13 @@ def create_or_update_group(self, name, parent, options):
changed = True
else:
changed, group = self.update_group(self.group_object, {
'name': name,
'auto_devops_enabled': options['auto_devops_enabled'],
'description': options['description'],
'visibility': options['visibility'],
'name': name,
'project_creation_level': options['project_creation_level'],
'auto_devops_enabled': options['auto_devops_enabled'],
'subgroup_creation_level': options['subgroup_creation_level'],
'require_two_factor_authentication': options['require_two_factor_authentication'],
'subgroup_creation_level': options['subgroup_creation_level'],
'visibility': options['visibility'],
})

self.group_object = group
Expand Down Expand Up @@ -322,28 +322,28 @@ def main():
argument_spec = basic_auth_argument_spec()
argument_spec.update(auth_argument_spec())
argument_spec.update(dict(
name=dict(type='str', required=True),
path=dict(type='str'),
auto_devops_enabled=dict(type='bool'),
avatar_path=dict(type='path'),
description=dict(type='str'),
state=dict(type='str', default="present", choices=["absent", "present"]),
force_delete=dict(type='bool', default=False),
name=dict(type='str', required=True),
parent=dict(type='str'),
visibility=dict(type='str', default="private", choices=["internal", "private", "public"]),
path=dict(type='str'),
project_creation_level=dict(type='str', choices=['developer', 'maintainer', 'noone']),
auto_devops_enabled=dict(type='bool'),
subgroup_creation_level=dict(type='str', choices=['maintainer', 'owner']),
require_two_factor_authentication=dict(type='bool'),
avatar_path=dict(type='path'),
force_delete=dict(type='bool', default=False),
state=dict(type='str', default="present", choices=["absent", "present"]),
subgroup_creation_level=dict(type='str', choices=['maintainer', 'owner']),
visibility=dict(type='str', default="private", choices=["internal", "private", "public"]),
))

module = AnsibleModule(
argument_spec=argument_spec,
mutually_exclusive=[
['api_username', 'api_token'],
['api_username', 'api_oauth_token'],
['api_username', 'api_job_token'],
['api_token', 'api_oauth_token'],
['api_token', 'api_job_token'],
['api_token', 'api_oauth_token'],
['api_username', 'api_job_token'],
['api_username', 'api_oauth_token'],
['api_username', 'api_token'],
],
required_together=[
['api_username', 'api_password'],
Expand All @@ -357,18 +357,18 @@ def main():
# check prerequisites and connect to gitlab server
gitlab_instance = gitlab_authentication(module)

auto_devops_enabled = module.params['auto_devops_enabled']
avatar_path = module.params['avatar_path']
description = module.params['description']
force_delete = module.params['force_delete']
group_name = module.params['name']
group_path = module.params['path']
description = module.params['description']
state = module.params['state']
parent_identifier = module.params['parent']
group_visibility = module.params['visibility']
parent_identifier = module.params['parent']
project_creation_level = module.params['project_creation_level']
auto_devops_enabled = module.params['auto_devops_enabled']
subgroup_creation_level = module.params['subgroup_creation_level']
require_two_factor_authentication = module.params['require_two_factor_authentication']
avatar_path = module.params['avatar_path']
force_delete = module.params['force_delete']
state = module.params['state']
subgroup_creation_level = module.params['subgroup_creation_level']

# Define default group_path based on group_name
if group_path is None:
Expand All @@ -395,14 +395,14 @@ def main():

if state == 'present':
if gitlab_group.create_or_update_group(group_name, parent_group, {
"path": group_path,
"auto_devops_enabled": auto_devops_enabled,
"avatar_path": avatar_path,
"description": description,
"visibility": group_visibility,
"path": group_path,
"project_creation_level": project_creation_level,
"auto_devops_enabled": auto_devops_enabled,
"subgroup_creation_level": subgroup_creation_level,
"require_two_factor_authentication": require_two_factor_authentication,
"avatar_path": avatar_path,
"subgroup_creation_level": subgroup_creation_level,
"visibility": group_visibility,
}):
module.exit_json(changed=True, msg="Successfully created or updated the group %s" % group_name, group=gitlab_group.group_object._attrs)
else:
Expand Down

0 comments on commit ab84f16

Please sign in to comment.