mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
gitlab_project: Add initialize_with_readme
option (#3601)
* Add initialize_with_readme option to gitlab_project. Update integration/unit tests. * Fix pep8 * Revert unit tests * Update plugins/modules/source_control/gitlab/gitlab_project.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/source_control/gitlab/gitlab_project.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/source_control/gitlab/gitlab_project.py Co-authored-by: Felix Fontein <felix@fontein.de> * Move initialize_with_readme to proper spot to only add if project does not exist. * Update plugins/modules/source_control/gitlab/gitlab_project.py Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
40ccd1501b
commit
9fb76efde0
2 changed files with 14 additions and 2 deletions
|
@ -48,6 +48,13 @@ options:
|
||||||
description:
|
description:
|
||||||
- An description for the project.
|
- An description for the project.
|
||||||
type: str
|
type: str
|
||||||
|
initialize_with_readme:
|
||||||
|
description:
|
||||||
|
- Will initialize the project with a default C(README.md).
|
||||||
|
- Is only used when the project is created, and ignored otherwise.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: "4.0.0"
|
||||||
issues_enabled:
|
issues_enabled:
|
||||||
description:
|
description:
|
||||||
- Whether you want to create issues or not.
|
- Whether you want to create issues or not.
|
||||||
|
@ -187,6 +194,7 @@ EXAMPLES = r'''
|
||||||
wiki_enabled: True
|
wiki_enabled: True
|
||||||
snippets_enabled: True
|
snippets_enabled: True
|
||||||
import_url: http://git.example.com/example/lab.git
|
import_url: http://git.example.com/example/lab.git
|
||||||
|
initialize_with_readme: true
|
||||||
state: present
|
state: present
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
'''
|
'''
|
||||||
|
@ -270,6 +278,8 @@ class GitLabProject(object):
|
||||||
'path': options['path'],
|
'path': options['path'],
|
||||||
'import_url': options['import_url'],
|
'import_url': options['import_url'],
|
||||||
})
|
})
|
||||||
|
if options['initialize_with_readme']:
|
||||||
|
project_options['initialize_with_readme'] = options['initialize_with_readme']
|
||||||
project_options = self.getOptionsWithValue(project_options)
|
project_options = self.getOptionsWithValue(project_options)
|
||||||
project = self.createProject(namespace, project_options)
|
project = self.createProject(namespace, project_options)
|
||||||
changed = True
|
changed = True
|
||||||
|
@ -359,6 +369,7 @@ def main():
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
path=dict(type='str'),
|
path=dict(type='str'),
|
||||||
description=dict(type='str'),
|
description=dict(type='str'),
|
||||||
|
initialize_with_readme=dict(type='bool', default=False),
|
||||||
issues_enabled=dict(type='bool', default=True),
|
issues_enabled=dict(type='bool', default=True),
|
||||||
merge_requests_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"]),
|
merge_method=dict(type='str', default='merge', choices=["merge", "rebase_merge", "ff"]),
|
||||||
|
@ -399,6 +410,7 @@ def main():
|
||||||
project_name = module.params['name']
|
project_name = module.params['name']
|
||||||
project_path = module.params['path']
|
project_path = module.params['path']
|
||||||
project_description = module.params['description']
|
project_description = module.params['description']
|
||||||
|
initialize_with_readme = module.params['initialize_with_readme']
|
||||||
issues_enabled = module.params['issues_enabled']
|
issues_enabled = module.params['issues_enabled']
|
||||||
merge_requests_enabled = module.params['merge_requests_enabled']
|
merge_requests_enabled = module.params['merge_requests_enabled']
|
||||||
merge_method = module.params['merge_method']
|
merge_method = module.params['merge_method']
|
||||||
|
@ -467,6 +479,7 @@ def main():
|
||||||
if gitlab_project.createOrUpdateProject(project_name, namespace, {
|
if gitlab_project.createOrUpdateProject(project_name, namespace, {
|
||||||
"path": project_path,
|
"path": project_path,
|
||||||
"description": project_description,
|
"description": project_description,
|
||||||
|
"initialize_with_readme": initialize_with_readme,
|
||||||
"issues_enabled": issues_enabled,
|
"issues_enabled": issues_enabled,
|
||||||
"merge_requests_enabled": merge_requests_enabled,
|
"merge_requests_enabled": merge_requests_enabled,
|
||||||
"merge_method": merge_method,
|
"merge_method": merge_method,
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
validate_certs: False
|
validate_certs: False
|
||||||
login_token: "{{ gitlab_login_token }}"
|
login_token: "{{ gitlab_login_token }}"
|
||||||
name: "{{ gitlab_project_name }}"
|
name: "{{ gitlab_project_name }}"
|
||||||
|
initialize_with_readme: True
|
||||||
state: present
|
state: present
|
||||||
register: gitlab_project_state
|
register: gitlab_project_state
|
||||||
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- gitlab_project_state is changed
|
- gitlab_project_state is changed
|
||||||
|
@ -39,7 +39,6 @@
|
||||||
state: present
|
state: present
|
||||||
register: gitlab_project_state_again
|
register: gitlab_project_state_again
|
||||||
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- gitlab_project_state_again is not changed
|
- gitlab_project_state_again is not changed
|
||||||
|
|
Loading…
Reference in a new issue