Merge pull request #824 from tnqn/verbose

Fix AttributeError in create_from_yaml
This commit is contained in:
Kubernetes Prow Robot 2019-07-23 12:48:14 -07:00 committed by GitHub
commit 1ad4afff35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -147,6 +147,20 @@ class TestUtils(unittest.TestCase):
rbac_api.delete_namespaced_role(
name="pod-reader", namespace="default", body={})
def test_create_rbac_role_from_yaml_with_verbose_enabled(self):
"""
Should be able to create an rbac role with verbose enabled.
"""
k8s_client = client.api_client.ApiClient(configuration=self.config)
utils.create_from_yaml(
k8s_client, self.path_prefix + "rbac-role.yaml", verbose=True)
rbac_api = client.RbacAuthorizationV1Api(k8s_client)
rbac_role = rbac_api.read_namespaced_role(
name="pod-reader", namespace="default")
self.assertIsNotNone(rbac_role)
rbac_api.delete_namespaced_role(
name="pod-reader", namespace="default", body={})
def test_create_deployment_non_default_namespace_from_yaml(self):
"""
Should be able to create a namespace "dep",

View File

@ -156,7 +156,10 @@ def create_from_yaml_single_item(
resp = getattr(k8s_api, "create_{0}".format(kind))(
body=yml_object, **kwargs)
if verbose:
print("{0} created. status='{1}'".format(kind, str(resp.status)))
msg = "{0} created.".format(kind)
if hasattr(resp, 'status'):
msg += " status='{0}'".format(str(resp.status))
print(msg)
class FailToCreateError(Exception):