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

Commit 375befb

Browse files
committed
Make dependancy adal optional
1 parent 5c242ea commit 375befb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

config/kube_config.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import tempfile
2222
import time
2323

24-
import adal
2524
import google.auth
2625
import google.auth.transport.requests
2726
import oauthlib.oauth2
@@ -36,6 +35,11 @@
3635
from .config_exception import ConfigException
3736
from .dateutil import UTC, format_rfc3339, parse_rfc3339
3837

38+
try:
39+
import adal
40+
except ImportError:
41+
pass
42+
3943
EXPIRY_SKEW_PREVENTION_DELAY = datetime.timedelta(minutes=5)
4044
KUBE_CONFIG_DEFAULT_LOCATION = os.environ.get('KUBECONFIG', '~/.kube/config')
4145
_temp_files = {}
@@ -218,6 +222,9 @@ def _load_azure_token(self, provider):
218222
return self.token
219223

220224
def _refresh_azure_token(self, config):
225+
if 'adal' not in globals():
226+
raise ImportError('refresh token error, adal library not imported')
227+
221228
tenant = config['tenant-id']
222229
authority = 'https://login.microsoftonline.com/{}'.format(tenant)
223230
context = adal.AuthenticationContext(

0 commit comments

Comments
 (0)