mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* correction doc
* Update gitlab_group.py
* improve gitlab
* Update changelogs/3766-improve_gitlab_group_and_project.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/source_control/gitlab/gitlab_group.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/source_control/gitlab/gitlab_group.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/source_control/gitlab/gitlab_group.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/source_control/gitlab/gitlab_group.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* correction
* correction sanity project
* Update plugins/modules/source_control/gitlab/gitlab_project.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* modif condition default_branch arg
* Update gitlab_project.py
change indent if defautl_branch inside if initialize_with_radme
Co-authored-by: paitrault <aymeric.paitrault@inetum.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit c6dcae5fda
)
Co-authored-by: paytroff <paytroff@gmail.com>
This commit is contained in:
parent
a60d55f03c
commit
e96101fb3f
3 changed files with 50 additions and 0 deletions
3
changelogs/3766-improve_gitlab_group_and_project.yml
Normal file
3
changelogs/3766-improve_gitlab_group_and_project.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
minor_changes:
|
||||
- gitlab_group, gitlab_project - add new option ``avatar_path`` (https://github.com/ansible-collections/community.general/pull/3792).
|
||||
- gitlab_project - add new option ``default_branch`` to gitlab_project (if ``readme = true``) (https://github.com/ansible-collections/community.general/pull/3792).
|
|
@ -83,6 +83,12 @@ options:
|
|||
- 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
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -212,6 +218,13 @@ class GitLabGroup(object):
|
|||
if options.get('require_two_factor_authentication'):
|
||||
payload['require_two_factor_authentication'] = options['require_two_factor_authentication']
|
||||
group = self.create_group(payload)
|
||||
|
||||
# add avatar to group
|
||||
if options['avatar_path']:
|
||||
try:
|
||||
group.avatar = open(options['avatar_path'], 'rb')
|
||||
except IOError as e:
|
||||
self._module.fail_json(msg='Cannot open {0}: {1}'.format(options['avatar_path'], e))
|
||||
changed = True
|
||||
else:
|
||||
changed, group = self.update_group(self.group_object, {
|
||||
|
@ -308,6 +321,7 @@ def main():
|
|||
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'),
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -335,6 +349,7 @@ def main():
|
|||
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']
|
||||
|
||||
if not HAS_GITLAB_PACKAGE:
|
||||
module.fail_json(msg=missing_required_lib("python-gitlab"), exception=GITLAB_IMP_ERR)
|
||||
|
@ -373,6 +388,7 @@ def main():
|
|||
"auto_devops_enabled": auto_devops_enabled,
|
||||
"subgroup_creation_level": subgroup_creation_level,
|
||||
"require_two_factor_authentication": require_two_factor_authentication,
|
||||
"avatar_path": avatar_path,
|
||||
}):
|
||||
module.exit_json(changed=True, msg="Successfully created or updated the group %s" % group_name, group=gitlab_group.group_object._attrs)
|
||||
else:
|
||||
|
|
|
@ -162,6 +162,18 @@ options:
|
|||
- Enable shared runners for this project.
|
||||
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"
|
||||
default_branch:
|
||||
description:
|
||||
- Default branch name for a new project.
|
||||
- This option is only used on creation, not for updates. This is also only used if I(initialize_with_readme=true).
|
||||
type: str
|
||||
version_added: "4.2.0"
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
|
@ -280,8 +292,18 @@ class GitLabProject(object):
|
|||
})
|
||||
if options['initialize_with_readme']:
|
||||
project_options['initialize_with_readme'] = options['initialize_with_readme']
|
||||
if options['default_branch']:
|
||||
project_options['default_branch'] = options['default_branch']
|
||||
|
||||
project_options = self.get_options_with_value(project_options)
|
||||
project = self.create_project(namespace, project_options)
|
||||
|
||||
# add avatar to project
|
||||
try:
|
||||
project.avatar = open(options['avatar_path'], 'rb')
|
||||
except IOError as e:
|
||||
self._module.fail_json(msg='Cannot open {0}: {1}'.format(options['avatar_path'], e))
|
||||
|
||||
changed = True
|
||||
else:
|
||||
changed, project = self.update_project(self.project_object, project_options)
|
||||
|
@ -370,6 +392,7 @@ def main():
|
|||
path=dict(type='str'),
|
||||
description=dict(type='str'),
|
||||
initialize_with_readme=dict(type='bool', default=False),
|
||||
default_branch=dict(type='str'),
|
||||
issues_enabled=dict(type='bool', default=True),
|
||||
merge_requests_enabled=dict(type='bool', default=True),
|
||||
merge_method=dict(type='str', default='merge', choices=["merge", "rebase_merge", "ff"]),
|
||||
|
@ -388,6 +411,7 @@ def main():
|
|||
squash_option=dict(type='str', choices=['never', 'always', 'default_off', 'default_on']),
|
||||
ci_config_path=dict(type='str'),
|
||||
shared_runners_enabled=dict(type='bool'),
|
||||
avatar_path=dict(type='path'),
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
@ -429,6 +453,11 @@ def main():
|
|||
squash_option = module.params['squash_option']
|
||||
ci_config_path = module.params['ci_config_path']
|
||||
shared_runners_enabled = module.params['shared_runners_enabled']
|
||||
avatar_path = module.params['avatar_path']
|
||||
default_branch = module.params['default_branch']
|
||||
|
||||
if default_branch and not initialize_with_readme:
|
||||
module.fail_json(msg="Param default_branch need param initialize_with_readme set to true")
|
||||
|
||||
if not HAS_GITLAB_PACKAGE:
|
||||
module.fail_json(msg=missing_required_lib("python-gitlab"), exception=GITLAB_IMP_ERR)
|
||||
|
@ -480,6 +509,7 @@ def main():
|
|||
"path": project_path,
|
||||
"description": project_description,
|
||||
"initialize_with_readme": initialize_with_readme,
|
||||
"default_branch": default_branch,
|
||||
"issues_enabled": issues_enabled,
|
||||
"merge_requests_enabled": merge_requests_enabled,
|
||||
"merge_method": merge_method,
|
||||
|
@ -496,6 +526,7 @@ def main():
|
|||
"squash_option": squash_option,
|
||||
"ci_config_path": ci_config_path,
|
||||
"shared_runners_enabled": shared_runners_enabled,
|
||||
"avatar_path": avatar_path,
|
||||
}):
|
||||
|
||||
module.exit_json(changed=True, msg="Successfully created or updated the project %s" % project_name, project=gitlab_project.project_object._attrs)
|
||||
|
|
Loading…
Reference in a new issue