mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-07-28 10:24:45 +00:00
not tested
This commit is contained in:
@@ -67,7 +67,5 @@ options:
|
|||||||
wait_for:
|
wait_for:
|
||||||
description:
|
description:
|
||||||
- Specifies a property on the resource to wait for.
|
- Specifies a property on the resource to wait for.
|
||||||
- Ignored if C(wait) is not set or is set to False.
|
- Ignored if C(wait) is not set or is set to I(False).
|
||||||
default: 120
|
|
||||||
type: int
|
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ class K8sAnsibleMixin(object):
|
|||||||
|
|
||||||
def _wait_for_elapsed():
|
def _wait_for_elapsed():
|
||||||
return (datetime.now() - start).seconds
|
return (datetime.now() - start).seconds
|
||||||
|
|
||||||
response = None
|
response = None
|
||||||
while _wait_for_elapsed() < timeout:
|
while _wait_for_elapsed() < timeout:
|
||||||
try:
|
try:
|
||||||
@@ -438,7 +438,7 @@ class K8sAnsibleMixin(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _wait_for_property(resource):
|
def _wait_for_property(resource):
|
||||||
return all([ jsonpath.match("$.{}".format(item),json_data) for item in wait_for ])
|
return all([ jsonpath.match("$.{}".format(item),resource) for item in wait_for ])
|
||||||
|
|
||||||
def _resource_absent(resource):
|
def _resource_absent(resource):
|
||||||
return not resource
|
return not resource
|
||||||
@@ -457,13 +457,15 @@ class K8sAnsibleMixin(object):
|
|||||||
kind = definition['kind']
|
kind = definition['kind']
|
||||||
predicates = []
|
predicates = []
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if condition:
|
|
||||||
predicates.append(_custom_condition)
|
|
||||||
if wait_for:
|
|
||||||
# json path predicate
|
|
||||||
predicates.append(_wait_for_property)
|
|
||||||
if condition is None and wait_for is None:
|
if condition is None and wait_for is None:
|
||||||
predicates.append(waiter.get(kind, lambda x: x))
|
predicates.append(waiter.get(kind, lambda x: x))
|
||||||
|
else:
|
||||||
|
if condition:
|
||||||
|
# add waiter on custom condition
|
||||||
|
predicates.append(_custom_condition)
|
||||||
|
if wait_for:
|
||||||
|
# json path predicate
|
||||||
|
predicates.append(_wait_for_property)
|
||||||
else:
|
else:
|
||||||
predicates.append(_resource_absent)
|
predicates.append(_resource_absent)
|
||||||
return self._wait_for(resource, definition['metadata']['name'], definition['metadata'].get('namespace'), predicates, sleep, timeout, state)
|
return self._wait_for(resource, definition['metadata']['name'], definition['metadata'].get('namespace'), predicates, sleep, timeout, state)
|
||||||
|
|||||||
Reference in New Issue
Block a user