Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit 5731554

Browse files
committed
Merge remote-tracking branch 'upstream/master' into add-oidc-auth-support
2 parents 1118961 + 11da619 commit 5731554

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
[![Build Status](https://travis-ci.org/kubernetes-client/python-base.svg?branch=master)](https://travis-ci.org/kubernetes-client/python-base)
44

5-
This is the utility part of the [python client](https://github.com/kubernetes-incubator/client-python). It has been added to the main
5+
This is the utility part of the [python client](https://github.com/kubernetes-client/python). It has been added to the main
66
repo using git submodules. This structure allow other developers to create
77
their own kubernetes client and still use standard kubernetes python utilities.
88
For more information refer to [clients-library-structure](https://github.com/kubernetes-client/community/blob/master/design-docs/clients-library-structure.md).
99

1010
# Development
1111
Any changes to utilites in this repo should be send as a PR to this repo. After
1212
the PR is merged, developers should create another PR in the main repo to update
13-
the submodule. See [this document](https://github.com/kubernetes-incubator/client-python/blob/master/devel/submodules.md) for more guidelines.
13+
the submodule. See [this document](https://github.com/kubernetes-client/python/blob/master/devel/submodules.md) for more guidelines.

config/kube_config.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,23 @@ def get_with_name(self, name, safe=False):
399399
raise ConfigException(
400400
'Invalid kube-config file. Expected %s to be a list'
401401
% self.name)
402+
result = None
402403
for v in self.value:
403404
if 'name' not in v:
404405
raise ConfigException(
405406
'Invalid kube-config file. '
406407
'Expected all values in %s list to have \'name\' key'
407408
% self.name)
408409
if v['name'] == name:
409-
return ConfigNode('%s[name=%s]' % (self.name, name), v)
410+
if result is None:
411+
result = v
412+
else:
413+
raise ConfigException(
414+
'Invalid kube-config file. '
415+
'Expected only one object with name %s in %s list'
416+
% (name, self.name))
417+
if result is not None:
418+
return ConfigNode('%s[name=%s]' % (self.name, name), result)
410419
if safe:
411420
return None
412421
raise ConfigException(

config/kube_config_test.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,19 @@ class TestConfigNode(BaseTestCase):
193193
"with_names": [{"name": "test_name", "value": "test_value"},
194194
{"name": "test_name2",
195195
"value": {"key1", "test"}},
196-
{"name": "test_name3", "value": [1, 2, 3]}]}
196+
{"name": "test_name3", "value": [1, 2, 3]}],
197+
"with_names_dup": [{"name": "test_name", "value": "test_value"},
198+
{"name": "test_name",
199+
"value": {"key1", "test"}},
200+
{"name": "test_name3", "value": [1, 2, 3]}]}
197201

198202
def setUp(self):
199203
super(TestConfigNode, self).setUp()
200204
self.node = ConfigNode("test_obj", self.test_obj)
201205

202206
def test_normal_map_array_operations(self):
203207
self.assertEqual("test", self.node['key1'])
204-
self.assertEqual(4, len(self.node))
208+
self.assertEqual(5, len(self.node))
205209

206210
self.assertEqual("test_obj/key2", self.node['key2'].name)
207211
self.assertEqual(["a", "b", "c"], self.node['key2'].value)
@@ -248,6 +252,11 @@ def test_get_with_name_on_name_does_not_exists(self):
248252
lambda: self.node['with_names'].get_with_name('no-name'),
249253
"Expected object with name no-name in test_obj/with_names list")
250254

255+
def test_get_with_name_on_duplicate_name(self):
256+
self.expect_exception(
257+
lambda: self.node['with_names_dup'].get_with_name('test_name'),
258+
"Expected only one object with name test_name in test_obj/with_names_dup list")
259+
251260

252261
class FakeConfig:
253262

run_tox.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ SCRIPT_ROOT=`pwd`
3434
popd > /dev/null
3535

3636
cd "${TMP_DIR}"
37-
git clone https://github.com/kubernetes-incubator/client-python.git
38-
cd client-python
37+
git clone https://github.com/kubernetes-client/python.git
38+
cd python
3939
git config user.email "[email protected]"
4040
git config user.name "kubenetes client"
4141
git rm -rf kubernetes/base

0 commit comments

Comments
 (0)