Skip to content

Commit

Permalink
Fix ValueError in list_namespaced_config_map
Browse files Browse the repository at this point in the history
Make sure we set an empty dict/list if we don't get
any data from the server

Fixes kubernetes-client#104
  • Loading branch information
dims committed Jan 23, 2017
1 parent a3e922a commit 1e48433
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kubernetes/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ def __deserialize_model(self, data, klass):
and instance.attribute_map[attr] in data\
and isinstance(data, (list, dict)):
value = data[instance.attribute_map[attr]]
if value is None:
value = [] if isinstance(data, list) else {}
setattr(instance, attr, self.__deserialize(value, attr_type))

return instance
2 changes: 2 additions & 0 deletions kubernetes/e2e_test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ def test_configmap_apis(self):
resp = api.delete_namespaced_config_map(
name='test-configmap', body={}, namespace='default')

resp = api.list_namespaced_config_map('kube-system', pretty=True)
self.assertEqual([], resp.items)

@unittest.skipUnless(
_is_k8s_running(), "Kubernetes is not available")
Expand Down

0 comments on commit 1e48433

Please sign in to comment.