From bfa2d599a2922b559f6b0fc3af85099d99cb6a76 Mon Sep 17 00:00:00 2001 From: Calvin Li <5651959+calvinli@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:23:38 -0700 Subject: [PATCH] let enable_automated_redeploys default value be configurable --- paasta_tools/cli/cmds/get_image_version.py | 12 ++++++++++-- paasta_tools/utils.py | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/paasta_tools/cli/cmds/get_image_version.py b/paasta_tools/cli/cmds/get_image_version.py index 4d2e0b7efa..4bc7d36134 100644 --- a/paasta_tools/cli/cmds/get_image_version.py +++ b/paasta_tools/cli/cmds/get_image_version.py @@ -27,6 +27,7 @@ from paasta_tools.utils import get_pipeline_deploy_group_configs from paasta_tools.utils import list_services from paasta_tools.utils import load_v2_deployments_json +from paasta_tools.utils import optionally_load_system_paasta_config from paasta_tools.utils import parse_timestamp @@ -71,9 +72,16 @@ def add_subparser(subparsers: argparse._SubParsersAction) -> None: def check_enable_automated_redeploys(service: str, soa_dir: str) -> bool: - # TODO: Handle global flag deploy_steps = get_pipeline_deploy_group_configs(service, soa_dir) - return any([step.get("enable_automated_redeploys", False) for step in deploy_steps]) + enabled_by_default = ( + optionally_load_system_paasta_config().get_enable_automated_redeploys_default() + ) + return any( + [ + step.get("enable_automated_redeploys", enabled_by_default) + for step in deploy_steps + ] + ) def extract_timestamp(image_version: str) -> Optional[datetime.datetime]: diff --git a/paasta_tools/utils.py b/paasta_tools/utils.py index 73bff69a09..85da5b9777 100644 --- a/paasta_tools/utils.py +++ b/paasta_tools/utils.py @@ -2052,6 +2052,7 @@ class SystemPaastaConfigDict(TypedDict, total=False): vitess_tablet_pool_type_mapping: Dict vitess_throttling_config: Dict uses_bulkdata_default: bool + enable_automated_redeploys_default: bool def load_system_paasta_config( @@ -2817,6 +2818,9 @@ def get_vitess_throttling_config(self) -> Dict: def get_uses_bulkdata_default(self) -> bool: return self.config_dict.get("uses_bulkdata_default", True) + def get_enable_automated_redeploys_default(self) -> bool: + return self.config_dict.get("enable_automated_redeploys_default", False) + def _run( command: Union[str, List[str]],