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

Commit

Permalink
Dynamically load apiserver id from kube config
Browse files Browse the repository at this point in the history
  • Loading branch information
fooka03 committed Oct 8, 2019
1 parent afd1301 commit 9da0652
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,13 @@ def _refresh_azure_token(self, config):
tenant = config['tenant-id']
authority = 'https://login.microsoftonline.com/{}'.format(tenant)
context = adal.AuthenticationContext(
authority, validate_authority=True,
authority, validate_authority=True, api_version='1.0'
)
refresh_token = config['refresh-token']
client_id = config['client-id']
apiserver_id = config['apiserver-id']
token_response = context.acquire_token_with_refresh_token(
refresh_token, client_id, '00000002-0000-0000-c000-000000000000')
refresh_token, client_id, apiserver_id)

provider = self._user['auth-provider']['config']
provider.value['access-token'] = token_response['accessToken']
Expand Down
10 changes: 5 additions & 5 deletions config/kube_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ class TestKubeConfigLoader(BaseTestCase):
"auth-provider": {
"config": {
"access-token": TEST_AZURE_TOKEN,
"apiserver-id": "ApiserverId",
"apiserver-id": "00000002-0000-0000-c000-000000000000",
"environment": "AzurePublicCloud",
"refresh-token": "refreshToken",
"tenant-id": "9d2ac018-e843-4e14-9e2b-4e0ddac75433"
Expand All @@ -662,7 +662,7 @@ class TestKubeConfigLoader(BaseTestCase):
"auth-provider": {
"config": {
"access-token": TEST_AZURE_TOKEN,
"apiserver-id": "ApiserverId",
"apiserver-id": "00000002-0000-0000-c000-000000000000",
"environment": "AzurePublicCloud",
"expires-in": "0",
"expires-on": "156207275",
Expand All @@ -679,7 +679,7 @@ class TestKubeConfigLoader(BaseTestCase):
"auth-provider": {
"config": {
"access-token": TEST_AZURE_TOKEN,
"apiserver-id": "ApiserverId",
"apiserver-id": "00000002-0000-0000-c000-000000000000",
"environment": "AzurePublicCloud",
"expires-in": "0",
"expires-on": "2018-10-18 00:52:29.044727",
Expand All @@ -696,7 +696,7 @@ class TestKubeConfigLoader(BaseTestCase):
"auth-provider": {
"config": {
"access-token": TEST_AZURE_TOKEN,
"apiserver-id": "ApiserverId",
"apiserver-id": "00000002-0000-0000-c000-000000000000",
"environment": "AzurePublicCloud",
"expires-in": "0",
"expires-on": "2018-10-18 00:52",
Expand All @@ -713,7 +713,7 @@ class TestKubeConfigLoader(BaseTestCase):
"auth-provider": {
"config": {
"access-token": TEST_AZURE_TOKEN,
"apiserver-id": "ApiserverId",
"apiserver-id": "00000002-0000-0000-c000-000000000000",
"environment": "AzurePublicCloud",
"expires-in": "0",
"expires-on": "-1",
Expand Down

0 comments on commit 9da0652

Please sign in to comment.