mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-04-12 03:40:58 +00:00
Add support for configuring garbage collection (#334)
* Add support for configuring garbage collection This surfaces deleteOptions functionality in a top-level delete_options parameter. * Add changelog fragment * Remove kind and apiVersion from delete_options * Add release version to docs
This commit is contained in:
@@ -189,6 +189,27 @@ WAIT_ARG_SPEC = dict(
|
||||
)
|
||||
)
|
||||
|
||||
DELETE_OPTS_ARG_SPEC = {
|
||||
'propagationPolicy': {
|
||||
'choices': ['Foreground', 'Background', 'Orphan'],
|
||||
},
|
||||
'gracePeriodSeconds': {
|
||||
'type': 'int',
|
||||
},
|
||||
'preconditions': {
|
||||
'type': 'dict',
|
||||
'options': {
|
||||
'resourceVersion': {
|
||||
'type': 'str',
|
||||
},
|
||||
'uid': {
|
||||
'type': 'str',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Map kubernetes-client parameters to ansible parameters
|
||||
AUTH_ARG_MAP = {
|
||||
'kubeconfig': 'kubeconfig',
|
||||
@@ -594,6 +615,7 @@ class K8sAnsibleMixin(object):
|
||||
return definition
|
||||
|
||||
def perform_action(self, resource, definition):
|
||||
delete_options = self.params.get('delete_options')
|
||||
result = {'changed': False, 'result': {}}
|
||||
state = self.params.get('state', None)
|
||||
force = self.params.get('force', False)
|
||||
@@ -646,6 +668,13 @@ class K8sAnsibleMixin(object):
|
||||
# Delete the object
|
||||
result['changed'] = True
|
||||
if not self.check_mode:
|
||||
if delete_options:
|
||||
body = {
|
||||
'apiVersion': 'v1',
|
||||
'kind': 'DeleteOptions',
|
||||
}
|
||||
body.update(delete_options)
|
||||
params['body'] = body
|
||||
try:
|
||||
k8s_obj = resource.delete(**params)
|
||||
result['result'] = k8s_obj.to_dict()
|
||||
|
||||
Reference in New Issue
Block a user