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

Make dependancy adal optional #108

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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