Skip to content
Snippets Groups Projects
Commit 03b9c97e authored by Olena Holub (EPAM)'s avatar Olena Holub (EPAM)
Browse files

Move whitelisted cloud provider names to conf.py

parent 1c06c220
No related branches found
No related tags found
1 merge request!572Added whitelisted cloud provider names
Pipeline #313262 failed
......@@ -39,11 +39,18 @@ Recently policy service was migrated from Flask to FastAPI, this was done in par
* baremetal
* aws
* azure
* gcp
* gc
* ibm
* LOCAL
* MOCK or undefined
Libraries for working with storage can only be imported for the following providers:
* baremetal
* aws
* azure
* gc
* ibm
Related Settings/Environmental variables:
- `POLICY_BUCKET` - used by AWS, Google Cloud and IBM to determine which bucket is used for providing bundle files. Service identity running policy service needs to have write permission to contents in this bucket. Note us-east-1 is only region supported at this time for AWS.
- `CONTAINER_NAME` - used by Azure to determine which container is used for providing bundle files. Service principal running policy service needs to have write permission to contents in this bucket.
......
......@@ -22,6 +22,8 @@ from typing import Tuple
from osdu_api.providers.types import FileLikeObject
import conf
logger = logging.getLogger(__name__)
......@@ -55,11 +57,9 @@ def get_storage() -> BundleStorageClient:
logger.critical("Error: No CLOUD_PROVIDER ENV VAR SET")
sys.exit(1)
allowed_values = ["aws", "gc", "az", "local", "ibm", "baremetal"]
cloud_env = os.environ.get("CLOUD_PROVIDER")
if cloud_env in allowed_values:
if cloud_env in conf.ALLOWED_CLOUD_PROVIDERS:
try:
provider_module = _import_provider_specific_module(cloud_env)
except ModuleNotFoundError as exc:
......
......@@ -546,4 +546,8 @@ ALLOW_CORRELATION_ID_PATTERN = "^[A-Za-z0-9_-]*$"
# OCI Registry not supported
OPA_SUPPORTED_SERVICES = ["s3", "gcs", "gcp", "blob", "nginx"]
# whitelisted cloud providers to import libraries
ALLOWED_CLOUD_PROVIDERS = {"aws", "azure", "baremetal", "gc", "ibm"}
CLOUD_PROVIDER = os.getenv("CLOUD_PROVIDER", "LOCAL")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment