diff --git a/tools/py/deploy.py b/tools/py/deploy.py index b88152f01..40b697081 100644 --- a/tools/py/deploy.py +++ b/tools/py/deploy.py @@ -1,7 +1,10 @@ import argparse import dotenv +import re import subprocess +from typing import Callable + import publish_data_stream import publish_sparkd @@ -96,16 +99,25 @@ def _get_env_files(services, profile): add(root.joinpath(".env")) add(root.joinpath(".env.local")) if profile is not None: - if "sparkd" in services or "sparkd-symbols" in services: - profile_dir=_resolve_profile_dir(root.joinpath("src/app_sparkd/configurations"), profile) - add(profile_dir.joinpath(".env")) - add(profile_dir.joinpath(".env.local")) - if "pubsub" in services: - profile_dir = _resolve_profile_dir(root.joinpath("src/DataStreamSuite/PubSubServer/Configurations"), profile) - add(profile_dir.joinpath(".env")) - add(profile_dir.joinpath(".env.local")) - if "md-publisher" in services: - profile_dir = _resolve_profile_dir(root.joinpath("src/DataStreamSuite/DataStreamPublisher/Configurations"), profile) + + def re_predicate(pattern: str) -> Callable[[str], bool]: + return lambda s: re.search(pattern, s) is not None + + any_re_predicate: Callable[ + [tuple[str, str]], + bool] = lambda p: any(filter(re_predicate(p[0]), services)) + profile_dirs = [ + ("^sparkd", "src/app_sparkd/configurations"), + ("^pubsub", "src/DataStreamSuite/PubSubServer/Configurations"), + ( + "^(md|ds)-publisher", + "src/DataStreamSuite/DataStreamPublisher/Configurations"), + ] + search_path = map( + lambda p: root.joinpath(p[1]), + filter(any_re_predicate, profile_dirs)) + for dir in search_path: + profile_dir = _resolve_profile_dir(dir, profile) add(profile_dir.joinpath(".env")) add(profile_dir.joinpath(".env.local")) return files