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

Commit 9da0652

Browse files
committed
Dynamically load apiserver id from kube config
1 parent afd1301 commit 9da0652

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

config/kube_config.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,13 @@ def _refresh_azure_token(self, config):
249249
tenant = config['tenant-id']
250250
authority = 'https://login.microsoftonline.com/{}'.format(tenant)
251251
context = adal.AuthenticationContext(
252-
authority, validate_authority=True,
252+
authority, validate_authority=True, api_version='1.0'
253253
)
254254
refresh_token = config['refresh-token']
255255
client_id = config['client-id']
256+
apiserver_id = config['apiserver-id']
256257
token_response = context.acquire_token_with_refresh_token(
257-
refresh_token, client_id, '00000002-0000-0000-c000-000000000000')
258+
refresh_token, client_id, apiserver_id)
258259

259260
provider = self._user['auth-provider']['config']
260261
provider.value['access-token'] = token_response['accessToken']

config/kube_config_test.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class TestKubeConfigLoader(BaseTestCase):
647647
"auth-provider": {
648648
"config": {
649649
"access-token": TEST_AZURE_TOKEN,
650-
"apiserver-id": "ApiserverId",
650+
"apiserver-id": "00000002-0000-0000-c000-000000000000",
651651
"environment": "AzurePublicCloud",
652652
"refresh-token": "refreshToken",
653653
"tenant-id": "9d2ac018-e843-4e14-9e2b-4e0ddac75433"
@@ -662,7 +662,7 @@ class TestKubeConfigLoader(BaseTestCase):
662662
"auth-provider": {
663663
"config": {
664664
"access-token": TEST_AZURE_TOKEN,
665-
"apiserver-id": "ApiserverId",
665+
"apiserver-id": "00000002-0000-0000-c000-000000000000",
666666
"environment": "AzurePublicCloud",
667667
"expires-in": "0",
668668
"expires-on": "156207275",
@@ -679,7 +679,7 @@ class TestKubeConfigLoader(BaseTestCase):
679679
"auth-provider": {
680680
"config": {
681681
"access-token": TEST_AZURE_TOKEN,
682-
"apiserver-id": "ApiserverId",
682+
"apiserver-id": "00000002-0000-0000-c000-000000000000",
683683
"environment": "AzurePublicCloud",
684684
"expires-in": "0",
685685
"expires-on": "2018-10-18 00:52:29.044727",
@@ -696,7 +696,7 @@ class TestKubeConfigLoader(BaseTestCase):
696696
"auth-provider": {
697697
"config": {
698698
"access-token": TEST_AZURE_TOKEN,
699-
"apiserver-id": "ApiserverId",
699+
"apiserver-id": "00000002-0000-0000-c000-000000000000",
700700
"environment": "AzurePublicCloud",
701701
"expires-in": "0",
702702
"expires-on": "2018-10-18 00:52",
@@ -713,7 +713,7 @@ class TestKubeConfigLoader(BaseTestCase):
713713
"auth-provider": {
714714
"config": {
715715
"access-token": TEST_AZURE_TOKEN,
716-
"apiserver-id": "ApiserverId",
716+
"apiserver-id": "00000002-0000-0000-c000-000000000000",
717717
"environment": "AzurePublicCloud",
718718
"expires-in": "0",
719719
"expires-on": "-1",

0 commit comments

Comments
 (0)