Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 2 additions & 10 deletions commons/feature_toggles/feature_toggle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@
import json
from time_tracker_api.security import current_user_email
from azure.appconfiguration import AzureAppConfigurationClient
from utils.environment_variables import check_variables_are_defined


class FeatureToggleConfig:
def check_variables_are_defined():
azure_app_variable = 'AZURE_APP_CONFIGURATION_CONNECTION_STRING'
if azure_app_variable not in os.environ:
raise EnvironmentError(
"{} is not defined in the environment".format(
azure_app_variable
)
)

check_variables_are_defined()
check_variables_are_defined(['AZURE_APP_CONFIGURATION_CONNECTION_STRING'])
AZURE_APP_CONFIGURATION_CONNECTION_STRING = os.environ.get(
'AZURE_APP_CONFIGURATION_CONNECTION_STRING'
)
Expand Down
2 changes: 1 addition & 1 deletion requirements/time_tracker_api/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ pytest-mock==2.0.0
coverage==4.5.1

# Git hooks
pre-commit==2.2.0
pre-commit==2.2.0
24 changes: 10 additions & 14 deletions utils/azure_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@
import requests
import json
from typing import List
from utils.environment_variables import check_variables_are_defined


class MSConfig:
def check_variables_are_defined():
auth_variables = [
'MS_CLIENT_ID',
'MS_AUTHORITY',
'MS_SECRET',
'MS_SCOPE',
'MS_ENDPOINT',
]
for var in auth_variables:
if var not in os.environ:
raise EnvironmentError(
"{} is not defined in the environment".format(var)
)
ms_variables = [
'MS_CLIENT_ID',
'MS_AUTHORITY',
'MS_SECRET',
'MS_SCOPE',
'MS_ENDPOINT',
]

check_variables_are_defined(ms_variables)

check_variables_are_defined()
CLIENT_ID = os.environ.get('MS_CLIENT_ID')
AUTHORITY = os.environ.get('MS_AUTHORITY')
SECRET = os.environ.get('MS_SECRET')
Expand Down
9 changes: 9 additions & 0 deletions utils/environment_variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os


def check_variables_are_defined(variables):
for var in variables:
if var not in os.environ:
raise EnvironmentError(
"{} is not defined in the environment".format(var)
)