mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* added description parameter to create request
* added changelog fragment
* Update changelogs/fragments/1196-use_description-in-gitlab-group-creation.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* added integration test for description in gitlab_group
* per request in the PR, creating separate task for the description issue in the integration test
* replaced deprecated param names with new names
* description should be optional to keep backward compatibility
* Update plugins/modules/source_control/gitlab/gitlab_group.py
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 7db2ce5be3
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
1b7c49cf56
commit
e09392e867
4 changed files with 43 additions and 9 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- gitlab_group - added description parameter to ``createGroup()`` call (https://github.com/ansible-collections/community.general/issues/138).
|
|
@ -162,11 +162,15 @@ class GitLabGroup(object):
|
||||||
if self.groupObject is None:
|
if self.groupObject is None:
|
||||||
parent_id = self.getGroupId(parent)
|
parent_id = self.getGroupId(parent)
|
||||||
|
|
||||||
group = self.createGroup({
|
payload = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'path': options['path'],
|
'path': options['path'],
|
||||||
'parent_id': parent_id,
|
'parent_id': parent_id,
|
||||||
'visibility': options['visibility']})
|
'visibility': options['visibility']
|
||||||
|
}
|
||||||
|
if options.get('description'):
|
||||||
|
payload['description'] = options['description']
|
||||||
|
group = self.createGroup(payload)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
changed, group = self.updateGroup(self.groupObject, {
|
changed, group = self.updateGroup(self.groupObject, {
|
||||||
|
|
|
@ -10,18 +10,18 @@
|
||||||
|
|
||||||
- name: Cleanup GitLab Group
|
- name: Cleanup GitLab Group
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
server_url: "{{ gitlab_host }}"
|
api_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
login_token: "{{ gitlab_login_token }}"
|
api_token: "{{ gitlab_login_token }}"
|
||||||
name: ansible_test_group
|
name: ansible_test_group
|
||||||
path: ansible_test_group
|
path: ansible_test_group
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create GitLab Group
|
- name: Create GitLab Group
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
server_url: "{{ gitlab_host }}"
|
api_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
login_token: "{{ gitlab_login_token }}"
|
api_token: "{{ gitlab_login_token }}"
|
||||||
name: ansible_test_group
|
name: ansible_test_group
|
||||||
path: ansible_test_group
|
path: ansible_test_group
|
||||||
state: present
|
state: present
|
||||||
|
@ -35,9 +35,9 @@
|
||||||
|
|
||||||
- name: Create GitLab Group ( Idempotency test )
|
- name: Create GitLab Group ( Idempotency test )
|
||||||
gitlab_group:
|
gitlab_group:
|
||||||
server_url: "{{ gitlab_host }}"
|
api_url: "{{ gitlab_host }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
login_token: "{{ gitlab_login_token }}"
|
api_token: "{{ gitlab_login_token }}"
|
||||||
name: ansible_test_group
|
name: ansible_test_group
|
||||||
path: ansible_test_group
|
path: ansible_test_group
|
||||||
state: present
|
state: present
|
||||||
|
@ -47,3 +47,28 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- gitlab_group_state_again is not changed
|
- gitlab_group_state_again is not changed
|
||||||
|
|
||||||
|
- name: Cleanup GitLab Group for Description Test
|
||||||
|
gitlab_group:
|
||||||
|
api_url: "{{ gitlab_host }}"
|
||||||
|
validate_certs: false
|
||||||
|
api_token: "{{ gitlab_login_token }}"
|
||||||
|
name: ansible_test_group
|
||||||
|
path: ansible_test_group
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Create GitLab Group for Description Test
|
||||||
|
gitlab_group:
|
||||||
|
api_url: "{{ gitlab_host }}"
|
||||||
|
validate_certs: false
|
||||||
|
api_token: "{{ gitlab_login_token }}"
|
||||||
|
name: ansible_test_group
|
||||||
|
path: ansible_test_group
|
||||||
|
description: My Test Group
|
||||||
|
state: present
|
||||||
|
register: gitlab_group_state_desc
|
||||||
|
|
||||||
|
- name: Test group created with Description
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- gitlab_group_state_desc.group.description == "My Test Group"
|
||||||
|
|
|
@ -66,11 +66,14 @@ class TestGitlabGroup(GitlabModuleTestCase):
|
||||||
|
|
||||||
@with_httmock(resp_create_group)
|
@with_httmock(resp_create_group)
|
||||||
def test_create_group(self):
|
def test_create_group(self):
|
||||||
group = self.moduleUtil.createGroup({'name': "Foobar Group", 'path': "foo-bar"})
|
group = self.moduleUtil.createGroup({'name': "Foobar Group",
|
||||||
|
'path': "foo-bar",
|
||||||
|
'description': "An interesting group"})
|
||||||
|
|
||||||
self.assertEqual(type(group), Group)
|
self.assertEqual(type(group), Group)
|
||||||
self.assertEqual(group.name, "Foobar Group")
|
self.assertEqual(group.name, "Foobar Group")
|
||||||
self.assertEqual(group.path, "foo-bar")
|
self.assertEqual(group.path, "foo-bar")
|
||||||
|
self.assertEqual(group.description, "An interesting group")
|
||||||
self.assertEqual(group.id, 1)
|
self.assertEqual(group.id, 1)
|
||||||
|
|
||||||
@with_httmock(resp_create_subgroup)
|
@with_httmock(resp_create_subgroup)
|
||||||
|
|
Loading…
Reference in a new issue