This repository was archived by the owner on Oct 3, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -275,7 +275,12 @@ def get_kwargs(self, **kwargs) -> dict:
275
275
if "base" not in kwargs :
276
276
raise TypeError ("unknown API version; base kwarg must be specified." )
277
277
base = kwargs .pop ("base" )
278
- bits = [base , version ]
278
+ if version .startswith ("/" ):
279
+ # for compatibility with pykube-ng 20.1.0 when calling api.get(version="/apis"):
280
+ # posixpath.join() was throwing away everything before the first "absolute" path (i.e. starting with a slash)
281
+ bits = [version ]
282
+ else :
283
+ bits = [base , version ]
279
284
# Overwrite (default) namespace from context if it was set
280
285
if "namespace" in kwargs :
281
286
n = kwargs .pop ("namespace" )
Original file line number Diff line number Diff line change @@ -99,3 +99,21 @@ def test_http_with_oidc_auth(monkeypatch):
99
99
100
100
mock_send .assert_called_once ()
101
101
assert mock_send .call_args [0 ][0 ].headers ["Authorization" ] == "Bearer some-id-token"
102
+
103
+
104
+ def test_get_kwargs ():
105
+ cfg = KubeConfig .from_file (GOOD_CONFIG_FILE_PATH )
106
+ api = HTTPClient (cfg )
107
+
108
+ assert api .get_kwargs (version = "v1" ) == {
109
+ "timeout" : 10 ,
110
+ "url" : "http://localhost/api/v1/" ,
111
+ }
112
+ assert api .get_kwargs (version = "/apis" ) == {
113
+ "timeout" : 10 ,
114
+ "url" : "http://localhost/apis/" ,
115
+ }
116
+ assert api .get_kwargs (version = "storage.k8s.io/v1" ) == {
117
+ "timeout" : 10 ,
118
+ "url" : "http://localhost/apis/storage.k8s.io/v1/" ,
119
+ }
You can’t perform that action at this time.
0 commit comments