Skip to content

Commit

Permalink
get rid of magic numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertdeng123 committed Nov 16, 2024
1 parent de8f8fb commit 62448fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions devservices/commands/down.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from devservices.constants import DEVSERVICES_DEPENDENCIES_CACHE_DIR
from devservices.constants import DEVSERVICES_DEPENDENCIES_CACHE_DIR_KEY
from devservices.constants import DEVSERVICES_DIR_NAME
from devservices.constants import DOCKER_COMPOSE_COMMAND_LENGTH
from devservices.exceptions import DependencyError
from devservices.exceptions import DockerComposeError
from devservices.utils.console import Console
Expand Down Expand Up @@ -97,8 +98,8 @@ def down(args: Namespace) -> None:
def _bring_down_dependency(
cmd: list[str], current_env: dict[str, str], status: Status
) -> subprocess.CompletedProcess[str]:
# TODO: Get rid of these magic numbers, we need a smarter way to determine the containers being brought down
for dependency in cmd[7:]:
# TODO: Get rid of these constants, we need a smarter way to determine the containers being brought down
for dependency in cmd[DOCKER_COMPOSE_COMMAND_LENGTH:]:
status.info(f"Stopping {dependency}")
return run_cmd(cmd, current_env)

Expand Down
1 change: 1 addition & 0 deletions devservices/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
DEVSERVICES_DEPENDENCIES_CACHE_DIR = os.path.join(DEVSERVICES_CACHE_DIR, "dependencies")
DEVSERVICES_DEPENDENCIES_CACHE_DIR_KEY = "DEVSERVICES_DEPENDENCIES_CACHE_DIR"
STATE_DB_FILE = os.path.join(DEVSERVICES_LOCAL_DIR, "state")
DOCKER_COMPOSE_COMMAND_LENGTH = 7

DEPENDENCY_CONFIG_VERSION = "v1"
DEPENDENCY_GIT_PARTIAL_CLONE_CONFIG_OPTIONS = {
Expand Down

0 comments on commit 62448fc

Please sign in to comment.