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

Commit

Permalink
Make dependancy adal optional
Browse files Browse the repository at this point in the history
  • Loading branch information
iamneha committed Dec 11, 2018
1 parent 5c242ea commit 375befb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import tempfile
import time

import adal
import google.auth
import google.auth.transport.requests
import oauthlib.oauth2
Expand All @@ -36,6 +35,11 @@
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 = {}
Expand Down Expand Up @@ -218,6 +222,9 @@ def _load_azure_token(self, provider):
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(
Expand Down

0 comments on commit 375befb

Please sign in to comment.