codecoverage improvement
[dcaegen2/platform.git] / mod / distributorapi / distributor / config.py
1 # ============LICENSE_START=======================================================
2 # Copyright (c) 2019-2022 AT&T Intellectual Property. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=========================================================
16 """Configuration for distributor api"""
17 import os, tempfile, six, inspect
18 from datetime import datetime
19 from distributor import errors
20
21
22 def _grab_env(name, default=None):
23     try:
24         if default:
25             return os.environ.get(name, default)
26         else:
27             return os.environ[name]
28     except KeyError:
29         raise errors.DistributorAPIConfigError("Required environment variable missing: {0}".format(name))
30
31
32 def init():
33     global nifi_registry_url
34     nifi_registry_url = _grab_env("NIFI_REGISTRY_URL", default="http://nifi-registry:18080/nifi-registry-api")
35
36     global onboarding_api_url
37     onboarding_api_url = _grab_env("ONBOARDING_API_URL", default="http://onboarding-api:8080/onboarding")