From 10433ad8da0f377b26373893a76a9ad22ee8b1e0 Mon Sep 17 00:00:00 2001 From: Ian Woodard <17186604+IanWoodard@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:23:43 -0700 Subject: [PATCH 1/2] ref(config): Renaming service config and moving it to a config dir --- setup.cfg | 3 +++ src/commands/list_dependencies.py | 4 ++-- src/{utils/config.py => configs/service_config.py} | 12 ++++++------ src/utils/devenv.py | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) rename src/{utils/config.py => configs/service_config.py} (88%) diff --git a/setup.cfg b/setup.cfg index 17192f3..378bdc3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,3 +9,6 @@ extend-ignore = python_version = 3.12 strict = True ignore_missing_imports = True + +[mypy-yaml.*] +ignore_missing_imports = True diff --git a/src/commands/list_dependencies.py b/src/commands/list_dependencies.py index 947f589..3b8eef3 100644 --- a/src/commands/list_dependencies.py +++ b/src/commands/list_dependencies.py @@ -4,7 +4,7 @@ from argparse import ArgumentParser from argparse import Namespace -from utils.config import load_devservices_config +from configs.service_config import load_service_config def add_parser(subparsers: _SubParsersAction[ArgumentParser]) -> None: @@ -22,7 +22,7 @@ def add_parser(subparsers: _SubParsersAction[ArgumentParser]) -> None: def list_dependencies(args: Namespace) -> None: """List the dependencies of a service.""" - config = load_devservices_config(args.service_name) + config = load_service_config(args.service_name) dependencies = config.devservices_config.dependencies diff --git a/src/utils/config.py b/src/configs/service_config.py similarity index 88% rename from src/utils/config.py rename to src/configs/service_config.py index 057cb83..e2e7d8d 100644 --- a/src/utils/config.py +++ b/src/configs/service_config.py @@ -12,7 +12,7 @@ from pydantic import BaseModel from pydantic import Field from pydantic import validator -from utils.devenv import get_code_root +from utils.devenv import get_coderoot class Dependency(BaseModel): @@ -20,7 +20,7 @@ class Dependency(BaseModel): link: Optional[str] = None -class DevservicesConfig(BaseModel): +class ServiceConfig(BaseModel): version: float service_name: str dependencies: Dict[str, Dependency] @@ -51,10 +51,10 @@ def check_modes( class Config(BaseModel): - devservices_config: DevservicesConfig = Field(alias="x-sentry-devservices-config") + devservices_config: ServiceConfig = Field(alias="x-sentry-service-config") -def load_devservices_config(service_name: Optional[str]) -> Config: +def load_service_config(service_name: Optional[str]) -> Config: """Load the devservices config for a service.""" if not service_name: current_dir = os.getcwd() @@ -66,8 +66,8 @@ def load_devservices_config(service_name: Optional[str]) -> Config: f"Config file not found in current directory: {config_path}" ) else: - code_root = get_code_root() - service_path = os.path.join(code_root, service_name) + coderoot = get_coderoot() + service_path = os.path.join(coderoot, service_name) config_path = os.path.join( service_path, DEVSERVICES_DIR_NAME, DOCKER_COMPOSE_FILE_NAME ) diff --git a/src/utils/devenv.py b/src/utils/devenv.py index d411f9f..35f34f9 100644 --- a/src/utils/devenv.py +++ b/src/utils/devenv.py @@ -9,7 +9,7 @@ from devenv.lib.config import read_config -def get_code_root() -> str: +def get_coderoot() -> str: config_path = os.path.join(home, ".config", "sentry-devenv", "config.ini") try: devenv_config: ConfigParser = read_config(config_path) From f3644412d8f7d3c90330fa588f69a2ad366e78bb Mon Sep 17 00:00:00 2001 From: Ian Woodard <17186604+IanWoodard@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:27:25 -0700 Subject: [PATCH 2/2] fixing naming --- src/commands/list_dependencies.py | 6 +++--- src/configs/service_config.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/list_dependencies.py b/src/commands/list_dependencies.py index 3b8eef3..a15f631 100644 --- a/src/commands/list_dependencies.py +++ b/src/commands/list_dependencies.py @@ -24,12 +24,12 @@ def list_dependencies(args: Namespace) -> None: """List the dependencies of a service.""" config = load_service_config(args.service_name) - dependencies = config.devservices_config.dependencies + dependencies = config.service_config.dependencies if not dependencies: - print(f"No dependencies found for {config.devservices_config.service_name}") + print(f"No dependencies found for {config.service_config.service_name}") return - print(f"Dependencies of {config.devservices_config.service_name}:") + print(f"Dependencies of {config.service_config.service_name}:") for dependency_key, dependency_info in dependencies.items(): print("-", dependency_key, ":", dependency_info.description) diff --git a/src/configs/service_config.py b/src/configs/service_config.py index e2e7d8d..1490812 100644 --- a/src/configs/service_config.py +++ b/src/configs/service_config.py @@ -51,7 +51,7 @@ def check_modes( class Config(BaseModel): - devservices_config: ServiceConfig = Field(alias="x-sentry-service-config") + service_config: ServiceConfig = Field(alias="x-sentry-service-config") def load_service_config(service_name: Optional[str]) -> Config: