mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix gitlab_project container_expiration_policy for project create (#8790)
* Fix gitlab_project container_expiration_policy for project create * Check for container_expiration_policy presence before renaming it * Add missing links to changelog fragment * Fix changelog grammar
This commit is contained in:
parent
4598758419
commit
573a7b97c6
2 changed files with 7 additions and 2 deletions
|
@ -0,0 +1,3 @@
|
|||
bugfixes:
|
||||
- gitlab_project - fix crash caused by old Gitlab projects not having a ``container_expiration_policy`` attribute (https://github.com/ansible-collections/community.general/pull/8790).
|
||||
- gitlab_project - fix ``container_expiration_policy`` not being applied when creating a new project (https://github.com/ansible-collections/community.general/pull/8790).
|
|
@ -521,6 +521,8 @@ class GitLabProject(object):
|
|||
return True
|
||||
|
||||
arguments['namespace_id'] = namespace.id
|
||||
if 'container_expiration_policy' in arguments:
|
||||
arguments['container_expiration_policy_attributes'] = arguments['container_expiration_policy']
|
||||
try:
|
||||
project = self._gitlab.projects.create(arguments)
|
||||
except (gitlab.exceptions.GitlabCreateError) as e:
|
||||
|
@ -548,9 +550,9 @@ class GitLabProject(object):
|
|||
|
||||
for arg_key, arg_value in arguments.items():
|
||||
if arguments[arg_key] is not None:
|
||||
if getattr(project, arg_key) != arguments[arg_key]:
|
||||
if getattr(project, arg_key, None) != arguments[arg_key]:
|
||||
if arg_key == 'container_expiration_policy':
|
||||
old_val = getattr(project, arg_key)
|
||||
old_val = getattr(project, arg_key, {})
|
||||
final_val = {key: value for key, value in arg_value.items() if value is not None}
|
||||
|
||||
if final_val.get('older_than') == '0d':
|
||||
|
|
Loading…
Reference in a new issue