mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-27 05:43:02 +00:00
replace iterator by generator (#205)
Fix network_sanity_ee_tests SUMMARY Network sanity ee tests are broken ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Abhijeet Kasurde <None> Reviewed-by: None <None>
This commit is contained in:
@@ -114,7 +114,7 @@ class ActionModule(ActionBase):
|
||||
|
||||
def import_jinja2_lstrip(self, templates):
|
||||
# Option `lstrip_blocks' was added in Jinja2 version 2.7.
|
||||
if any([tmp['lstrip_blocks'] for tmp in templates]):
|
||||
if any(tmp['lstrip_blocks'] for tmp in templates):
|
||||
try:
|
||||
import jinja2.defaults
|
||||
except ImportError:
|
||||
|
||||
@@ -143,7 +143,7 @@ class Discoverer(kubernetes.dynamic.discovery.Discoverer):
|
||||
result for result in results if result.group_version == kwargs['api_version']
|
||||
]
|
||||
# If there are multiple matches, prefer non-List kinds
|
||||
if len(results) > 1 and not all([isinstance(x, ResourceList) for x in results]):
|
||||
if len(results) > 1 and not all(isinstance(x, ResourceList) for x in results):
|
||||
results = [result for result in results if not isinstance(result, ResourceList)]
|
||||
# if multiple resources are found that share a GVK, prefer the one with the most supported verbs
|
||||
if len(results) > 1 and len(set((x.group_version, x.kind) for x in results)) == 1:
|
||||
@@ -162,6 +162,10 @@ class LazyDiscoverer(Discoverer, kubernetes.dynamic.LazyDiscoverer):
|
||||
Discoverer.__init__(self, client, cache_file)
|
||||
self.__update_cache = False
|
||||
|
||||
@property
|
||||
def update_cache(self):
|
||||
self.__update_cache
|
||||
|
||||
|
||||
class CacheDecoder(json.JSONDecoder):
|
||||
def __init__(self, client, *args, **kwargs):
|
||||
|
||||
@@ -148,7 +148,7 @@ def get_api_client(module=None, **kwargs):
|
||||
auth[true_name] = env_value
|
||||
|
||||
def auth_set(*names):
|
||||
return all([auth.get(name) for name in names])
|
||||
return all(auth.get(name) for name in names)
|
||||
|
||||
if auth_set('host'):
|
||||
# Removing trailing slashes if any from hostname
|
||||
@@ -392,7 +392,7 @@ class K8sAnsibleMixin(object):
|
||||
|
||||
def _pod_ready(pod):
|
||||
return (pod.status and pod.status.containerStatuses is not None
|
||||
and all([container.ready for container in pod.status.containerStatuses]))
|
||||
and all(container.ready for container in pod.status.containerStatuses))
|
||||
|
||||
def _daemonset_ready(daemonset):
|
||||
return (daemonset.status and daemonset.status.desiredNumberScheduled is not None
|
||||
|
||||
@@ -40,7 +40,7 @@ class Selector(object):
|
||||
self._operator = m.group(4)
|
||||
self._data = [x.replace(' ', '') for x in m.group(6).split(',') if x != '']
|
||||
return True
|
||||
elif all([x not in data for x in self.equality_based_operators]):
|
||||
elif all(x not in data for x in self.equality_based_operators):
|
||||
self._key = data.rstrip(" ").lstrip(" ")
|
||||
if self._key.startswith("!"):
|
||||
self._key = self._key[1:].lstrip(" ")
|
||||
@@ -68,4 +68,4 @@ class LabelSelectorFilter(object):
|
||||
labels = definition['metadata']['labels']
|
||||
if not isinstance(labels, dict):
|
||||
return None
|
||||
return all([sel.isMatch(labels) for sel in self.selectors])
|
||||
return all(sel.isMatch(labels) for sel in self.selectors)
|
||||
|
||||
@@ -148,7 +148,7 @@ def filter_pods(pods, force, ignore_daemonset):
|
||||
|
||||
# Pod with local storage cannot be deleted
|
||||
# TODO: support new option delete-emptydatadir in order to allow deletion of such pod
|
||||
if pod.spec.volumes and any([vol.empty_dir for vol in pod.spec.volumes]):
|
||||
if pod.spec.volumes and any(vol.empty_dir for vol in pod.spec.volumes):
|
||||
localStorage.append((pod.metadata.namespace, pod.metadata.name))
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user