Merge pull request #108 from iamneha/make-adal-optional

Make dependancy adal optional
This commit is contained in:
Kubernetes Prow Robot 2019-01-22 18:12:14 -08:00 committed by GitHub
commit 260f855a0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,6 @@ import os
import tempfile
import time
import adal
import google.auth
import google.auth.transport.requests
import oauthlib.oauth2
@ -36,6 +35,11 @@ from kubernetes.config.exec_provider import ExecProvider
from .config_exception import ConfigException
from .dateutil import UTC, format_rfc3339, parse_rfc3339
try:
import adal
except ImportError:
pass
EXPIRY_SKEW_PREVENTION_DELAY = datetime.timedelta(minutes=5)
KUBE_CONFIG_DEFAULT_LOCATION = os.environ.get('KUBECONFIG', '~/.kube/config')
_temp_files = {}
@ -218,6 +222,9 @@ class KubeConfigLoader(object):
return self.token
def _refresh_azure_token(self, config):
if 'adal' not in globals():
raise ImportError('refresh token error, adal library not imported')
tenant = config['tenant-id']
authority = 'https://login.microsoftonline.com/{}'.format(tenant)
context = adal.AuthenticationContext(