def get_resource(self, resource, namespace="all"):
ret, resources = None, list()
try:
ret, namespaced_resource = self._call_api_client(resource)
except ApiException as ae:
self.logger.warning("resource autocomplete disabled, encountered "
"ApiException", exc_info=1)
except (NewConnectionError, MaxRetryError, ConnectTimeoutError):
self.logger.warning("unable to connect to k8 cluster", exc_info=1)
if ret:
for i in ret.items:
if namespace == "all" or not namespaced_resource:
resources.append((i.metadata.name, i.metadata.namespace))
elif namespace == i.metadata.namespace:
resources.append((i.metadata.name, i.metadata.namespace))
return resources
评论列表
文章目录