def get_object(self, name=None, namespace=None):
k8s_obj = None
method_name = 'list' if self.kind.endswith('list') else 'read'
try:
get_method = self.lookup_method(method_name, namespace)
if name is None and namespace is None:
k8s_obj = get_method()
elif name and namespace is None:
k8s_obj = get_method(name)
elif namespace and not name:
k8s_obj = get_method(namespace)
else:
k8s_obj = get_method(name, namespace)
except ApiException as exc:
if exc.status != 404:
if self.base_model_name == 'Project'and exc.status == 403:
pass
else:
msg = json.loads(exc.body).get('message', exc.reason) if exc.body.startswith('{') else exc.body
raise self.get_exception_class()(msg, status=exc.status)
except MaxRetryError as ex:
raise self.get_exception_class()(str(ex.reason))
return k8s_obj
评论列表
文章目录