diff --git a/README.md b/README.md index 33f8e90..b83e886 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The Infrastructure expects to be deployed in the same Pod / local environment as A configuration is located in `/config.yaml`. All relevant variables can be configured via exporting environment variables. | Environment Variable | Default | Description | -|-------------------------------|--------------------------------|-----------------------------------------------------------------------| +| ----------------------------- | ------------------------------ | --------------------------------------------------------------------- | | LOGGING_LEVEL_ROOT | DEBUG | Logging level for service logger | | PROBING_WEBSERVER_HOST | "0.0.0.0" | Probe webserver address | | PROBING_WEBSERVER_PORT | 8080 | Probe webserver port | @@ -22,11 +22,12 @@ A configuration is located in `/config.yaml`. All relevant variables can be conf | DEAD_LETTER_QUEUE | dead_letter_queue | Messages that failed to process | | ANALYSIS_ENDPOINT | "http://127.0.0.1:5000" | Endpoint for analysis container | | STORAGE_BACKEND | s3 | The type of storage to use {s3, azure} | -| STORAGE_BUCKET | "pyinfra-test-bucket" | The bucket / container to pull files specified in queue requests from | +| STORAGE_BUCKET | "redaction" | The bucket / container to pull files specified in queue requests from | | STORAGE_ENDPOINT | "http://127.0.0.1:9000" | Endpoint for s3 storage | | STORAGE_KEY | root | User for s3 storage | | STORAGE_SECRET | password | Password for s3 storage | | STORAGE_AZURECONNECTIONSTRING | "DefaultEndpointsProtocol=..." | Connection string for Azure storage | +| STORAGE_AZURECONTAINERNAME | "redaction" | AKS container | ## Response Format diff --git a/pyinfra/__init__.py b/pyinfra/__init__.py index e69de29..9d92b43 100644 --- a/pyinfra/__init__.py +++ b/pyinfra/__init__.py @@ -0,0 +1,3 @@ +from pyinfra import k8s_probes, queue, storage, config + +__all__ = ["k8s_probes", "queue", "storage", "config"] \ No newline at end of file diff --git a/pyinfra/config.py b/pyinfra/config.py index a08f5ab..3ebcd4f 100644 --- a/pyinfra/config.py +++ b/pyinfra/config.py @@ -38,7 +38,10 @@ class Config(object): self.storage_backend = read_from_environment("STORAGE_BACKEND", "s3") # The bucket / container to pull files specified in queue requests from - self.storage_bucket = read_from_environment("STORAGE_BUCKET_NAME", "redaction") + if self.storage_backend == "s3": + self.storage_bucket = read_from_environment("STORAGE_BUCKET_NAME", "redaction") + else: + self.storage_bucket = read_from_environment("STORAGE_AZURECONTAINERNAME", "redaction") # Endpoint for s3 storage self.storage_endpoint = read_from_environment("STORAGE_ENDPOINT", "http://127.0.0.1:9000") diff --git a/pyinfra/k8s_probes/__init__.py b/pyinfra/k8s_probes/__init__.py index e69de29..ecc33ff 100644 --- a/pyinfra/k8s_probes/__init__.py +++ b/pyinfra/k8s_probes/__init__.py @@ -0,0 +1,3 @@ +from pyinfra.k8s_probes import startup + +__all__ = ["startup"] \ No newline at end of file diff --git a/pyinfra/queue/__init__.py b/pyinfra/queue/__init__.py index e69de29..c980a1e 100644 --- a/pyinfra/queue/__init__.py +++ b/pyinfra/queue/__init__.py @@ -0,0 +1,3 @@ +from pyinfra.queue import queue_manager + +__all__ = ["queue_manager"] \ No newline at end of file diff --git a/pyinfra/storage/__init__.py b/pyinfra/storage/__init__.py index e69de29..f01d6da 100644 --- a/pyinfra/storage/__init__.py +++ b/pyinfra/storage/__init__.py @@ -0,0 +1,4 @@ +from pyinfra.storage import adapters, storage +from pyinfra.storage.storage import get_storage + +__all__ = ["adapters", "storage"] \ No newline at end of file diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..247b7ba --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +import pytest +from pyinfra.config import get_config, Config +import os + +@pytest.fixture(params=["aws", "azure"]) +def storage_config(request) -> Config: + if request.param == "aws": + os.environ["STORAGE_BACKEND"] = "s3" + os.environ["STORAGE_BUCKET_NAME"] = "pyinfra-test-bucket" + os.environ["STORAGE_ENDPOINT"] = "https://s3.amazonaws.com" + os.environ["STORAGE_KEY"] = "AKIA4QVP6D4LCDAGYGN2" + os.environ["STORAGE_SECRET"] = "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" + os.environ["STORAGE_REGION"] = "eu-west-1" + else: + os.environ["STORAGE_BACKEND"] = "azure" + os.environ["STORAGE_AZURECONTAINERNAME"] = "pyinfra-test-bucket" + os.environ["STORAGE_AZURECONNECTIONSTRING"] = "DefaultEndpointsProtocol=https;AccountName=iqserdevelopment;AccountKey=4imAbV9PYXaztSOMpIyAClg88bAZCXuXMGJG0GA1eIBpdh2PlnFGoRBnKqLy2YZUSTmZ3wJfC7tzfHtuC6FEhQ==;EndpointSuffix=core.windows.net" + + return get_config() diff --git a/tests/test_storage.py b/tests/test_storage.py new file mode 100644 index 0000000..830f9df --- /dev/null +++ b/tests/test_storage.py @@ -0,0 +1,5 @@ +from pyinfra.storage import get_storage + +def test_storage(storage_config) -> None: + storage = get_storage(storage_config) + assert storage.has_bucket(storage_config.storage_bucket)