Skip to content

Commit 712aeb6

Browse files
authored
Merge branch 'kubernetes-client:master' into ResourceQuota_Comparison
2 parents cf86ff8 + 46989af commit 712aeb6

30 files changed

Lines changed: 128 additions & 159 deletions

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
- name: Upload coverage to Codecov
4747
if: "matrix.use_coverage"
48-
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2
48+
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354
4949
with:
5050
fail_ci_if_error: false
5151
verbose: true

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# v36.0.0
2+
3+
Kubernetes API Version: v1.36.1
4+
5+
# v36.0.0b1
6+
7+
Kubernetes API Version: v1.36.1
8+
9+
### Deprecation
10+
- Support new exec v5 websocket subprotocol (#2486, @aojea)
11+
112
# v36.0.0a3
213

314
Kubernetes API Version: v1.36.0

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ supported versions of Kubernetes clusters.
134134
- [client 33.y.z](https://pypi.org/project/kubernetes/33.1.0/): Kubernetes 1.32 or below (+-), Kubernetes 1.33 (✓), Kubernetes 1.34 or above (+-)
135135
- [client 34.y.z](https://pypi.org/project/kubernetes/34.1.0/): Kubernetes 1.33 or below (+-), Kubernetes 1.34 (✓), Kubernetes 1.35 or above (+-)
136136
- [client 35.y.z](https://pypi.org/project/kubernetes/35.0.0/): Kubernetes 1.34 or below (+-), Kubernetes 1.35 (✓), Kubernetes 1.36 or above (+-)
137-
- [client 36.y.z](https://pypi.org/project/kubernetes/36.0.0b1/): Kubernetes 1.35 or below (+-), Kubernetes 1.36 (✓), Kubernetes 1.37 or above (+-)
137+
- [client 36.y.z](https://pypi.org/project/kubernetes/36.0.0/): Kubernetes 1.35 or below (+-), Kubernetes 1.36 (✓), Kubernetes 1.37 or above (+-)
138138

139139

140140
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explanation of why there is no v13-v16 release.
@@ -205,12 +205,13 @@ between client-python versions.
205205
| 32.0 Alpha/Beta | Kubernetes main repo, 1.32 branch ||
206206
| 32.1 | Kubernetes main repo, 1.32 branch ||
207207
| 33.1 Alpha/Beta | Kubernetes main repo, 1.33 branch ||
208-
| 33.1 | Kubernetes main repo, 1.33 branch | |
208+
| 33.1 | Kubernetes main repo, 1.33 branch | |
209209
| 34.1 Alpha/Beta | Kubernetes main repo, 1.34 branch ||
210210
| 34.1 | Kubernetes main repo, 1.34 branch ||
211211
| 35.0 Alpha/Beta | Kubernetes main repo, 1.35 branch ||
212212
| 35.0 | Kubernetes main repo, 1.35 branch ||
213-
| 36.0 Alpha/Beta | Kubernetes main repo, 1.36 branch ||
213+
| 36.0 Alpha/Beta | Kubernetes main repo, 1.36 branch ||
214+
| 36.0 | Kubernetes main repo, 1.36 branch ||
214215

215216
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explanation of why there is no v13-v16 release.
216217

examples/cronjob_crud.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python3
2-
# -*- coding:utf-8 -*-
32

43
import json
54
import time

examples/duration-gep2257.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/python3
2-
# -*- coding:utf-8 -*-
32

43
"""
54
This example uses kubernetes.utils.duration to parse and display

examples/pod_portforward.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
import select
2020
import socket
2121
import time
22-
23-
import six.moves.urllib.request as urllib_request
22+
from urllib import request as urllib_request
2423

2524
from kubernetes import config
2625
from kubernetes.client import Configuration

kubernetes/base/config/exec_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .config_exception import ConfigException
2020

2121

22-
class ExecProvider(object):
22+
class ExecProvider:
2323
"""
2424
Implementation of the proposal for out-of-tree client
2525
authentication providers as described here --

kubernetes/base/config/incluster_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _join_host_port(host, port):
3434
return template % (host, port)
3535

3636

37-
class InClusterConfigLoader(object):
37+
class InClusterConfigLoader:
3838
def __init__(self,
3939
token_filename,
4040
cert_filename,
@@ -88,7 +88,7 @@ def _set_config(self, client_configuration):
8888
client_configuration.host = self.host
8989
client_configuration.ssl_ca_cert = self.ssl_ca_cert
9090
if self.token is not None:
91-
client_configuration.api_key['authorization'] = self.token
91+
client_configuration.api_key['BearerToken'] = self.token
9292
if not self._try_refresh_token:
9393
return
9494

kubernetes/base/config/incluster_config_test.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_refresh_token(self):
9191
loader.load_and_set(config)
9292

9393
self.assertEqual('bearer ' + _TEST_TOKEN,
94-
config.get_api_key_with_prefix('authorization'))
94+
config.get_api_key_with_prefix('BearerToken'))
9595
self.assertEqual('bearer ' + _TEST_TOKEN, loader.token)
9696
self.assertIsNotNone(loader.token_expires_at)
9797

@@ -100,14 +100,31 @@ def test_refresh_token(self):
100100
loader._token_filename = self._create_file_with_temp_content(
101101
_TEST_NEW_TOKEN)
102102
self.assertEqual('bearer ' + _TEST_TOKEN,
103-
config.get_api_key_with_prefix('authorization'))
103+
config.get_api_key_with_prefix('BearerToken'))
104104

105105
loader.token_expires_at = datetime.datetime.now()
106106
self.assertEqual('bearer ' + _TEST_NEW_TOKEN,
107-
config.get_api_key_with_prefix('authorization'))
107+
config.get_api_key_with_prefix('BearerToken'))
108108
self.assertEqual('bearer ' + _TEST_NEW_TOKEN, loader.token)
109109
self.assertGreater(loader.token_expires_at, old_token_expires_at)
110110

111+
def test_load_incluster_sets_request_authorization_header(self):
112+
from kubernetes.client import ApiClient
113+
cert_filename = self._create_file_with_temp_content(_TEST_CERT)
114+
loader = self.get_test_loader(cert_filename=cert_filename)
115+
config = Configuration()
116+
loader.load_and_set(config)
117+
118+
api_client = ApiClient(config)
119+
headers = {}
120+
api_client.update_params_for_auth(headers, [], ['BearerToken'])
121+
122+
self.assertIn('authorization', headers)
123+
self.assertTrue(
124+
headers['authorization'].lower().startswith('bearer '),
125+
"Expected a Bearer authorization header, got: %r"
126+
% headers['authorization'])
127+
111128
def _should_fail_load(self, config_loader, reason):
112129
try:
113130
config_loader.load_and_set()

kubernetes/base/config/kube_config.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
import platform
2323
import subprocess
2424
import tempfile
25-
import time
2625
from collections import namedtuple
2726

2827
import oauthlib.oauth2
2928
import urllib3
3029
import yaml
3130
from requests_oauthlib import OAuth2Session
32-
from six import PY3
3331

3432
from kubernetes.client import ApiClient, Configuration
3533
from kubernetes.config.exec_provider import ExecProvider
@@ -85,7 +83,7 @@ def _is_expired(expiry):
8583
datetime.datetime.now(tz=UTC))
8684

8785

88-
class FileOrData(object):
86+
class FileOrData:
8987
"""Utility class to read content of obj[%data_key_name] or file's
9088
content of obj[%file_key_name] and represent it as file or data.
9189
Note that the data is preferred. The obj[%file_key_name] will be used iff
@@ -151,7 +149,7 @@ def _write_file(self, force_rewrite=False):
151149
self._data, self._temp_file_path, force_recreate=force_rewrite)
152150

153151

154-
class CommandTokenSource(object):
152+
class CommandTokenSource:
155153
def __init__(self, cmd, args, tokenKey, expiryKey):
156154
self._cmd = cmd
157155
self._args = args
@@ -191,7 +189,7 @@ def token(self):
191189
expiry=parse_rfc3339(data['credential']['token_expiry']))
192190

193191

194-
class KubeConfigLoader(object):
192+
class KubeConfigLoader:
195193

196194
def __init__(self, config_dict, active_context=None,
197195
get_google_credentials=None,
@@ -363,14 +361,9 @@ def _load_oid_token(self, provider):
363361
# https://tools.ietf.org/html/rfc7515#appendix-C
364362
return
365363

366-
if PY3:
367-
jwt_attributes = json.loads(
368-
base64.urlsafe_b64decode(parts[1] + padding).decode('utf-8')
369-
)
370-
else:
371-
jwt_attributes = json.loads(
372-
base64.b64decode(parts[1] + padding)
373-
)
364+
jwt_attributes = json.loads(
365+
base64.urlsafe_b64decode(parts[1] + padding).decode('utf-8')
366+
)
374367

375368
expire = jwt_attributes.get('exp')
376369

@@ -392,14 +385,9 @@ def _refresh_oidc(self, provider):
392385
if 'idp-certificate-authority-data' in provider['config']:
393386
ca_cert = tempfile.NamedTemporaryFile(delete=True)
394387

395-
if PY3:
396-
cert = base64.b64decode(
397-
provider['config']['idp-certificate-authority-data']
398-
).decode('utf-8')
399-
else:
400-
cert = base64.b64decode(
401-
provider['config']['idp-certificate-authority-data'] + "=="
402-
)
388+
cert = base64.b64decode(
389+
provider['config']['idp-certificate-authority-data']
390+
).decode('utf-8')
403391

404392
with open(ca_cert.name, 'w') as fh:
405393
fh.write(cert)
@@ -539,7 +527,7 @@ def _load_cluster_info(self):
539527

540528
def _set_config(self, client_configuration):
541529
if 'token' in self.__dict__:
542-
client_configuration.api_key['authorization'] = self.token
530+
client_configuration.api_key['BearerToken'] = self.token
543531

544532
def _refresh_api_key(client_configuration):
545533
if ('expiry' in self.__dict__ and _is_expired(self.expiry)):
@@ -565,7 +553,7 @@ def current_context(self):
565553
return self._current_context.value
566554

567555

568-
class ConfigNode(object):
556+
class ConfigNode:
569557
"""Remembers each config key's path and construct a relevant exception
570558
message in case of missing keys. The assumption is all access keys are
571559
present in a well-formed kube-config."""

0 commit comments

Comments
 (0)