-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat(cli): add --config option for custom config file path #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| from sentry_sdk import logger as sentry_logger | ||
|
|
||
| from devservices.configs.service_config import ServiceConfig | ||
| from devservices.configs.service_config import load_service_config_from_file | ||
| from devservices.exceptions import ConfigNotFoundError | ||
| from devservices.exceptions import ConfigParseError | ||
| from devservices.exceptions import ConfigValidationError | ||
|
|
@@ -25,8 +26,6 @@ class Service: | |
|
|
||
| def get_local_services(coderoot: str) -> list[Service]: | ||
| """Get a list of services in the coderoot.""" | ||
| from devservices.configs.service_config import load_service_config_from_file | ||
|
|
||
| console = Console() | ||
|
|
||
| services = [] | ||
|
|
@@ -51,32 +50,40 @@ def get_local_services(coderoot: str) -> list[Service]: | |
| return services | ||
|
|
||
|
|
||
| def find_matching_service(service_name: str | None = None) -> Service: | ||
| def find_matching_service( | ||
| service_name: str | None = None, config_path: str | None = None | ||
| ) -> Service: | ||
| """Find a service with the given name.""" | ||
| if service_name is None: | ||
| from devservices.configs.service_config import load_service_config_from_file | ||
|
|
||
| repo_path = os.getcwd() | ||
| service_config = load_service_config_from_file(repo_path) | ||
|
|
||
| return Service( | ||
| name=service_config.service_name, | ||
| repo_path=repo_path, | ||
| config=service_config, | ||
| if config_path is not None and service_name is not None: | ||
| raise ConfigValidationError( | ||
| "Cannot specify both a service name and a custom config path" | ||
| ) | ||
| coderoot = get_coderoot() | ||
| services = get_local_services(coderoot) | ||
| for service in services: | ||
| if service.name.lower() == service_name.lower(): | ||
| return service | ||
| unique_service_names = sorted(set(service.name for service in services)) | ||
| error_message = f"Service '{service_name}' not found." | ||
| if len(unique_service_names) > 0: | ||
| service_bullet_points = "\n".join( | ||
| [f"- {service_name}" for service_name in unique_service_names] | ||
| ) | ||
| error_message += "\nSupported services:\n" + service_bullet_points | ||
| raise ServiceNotFoundError(error_message) | ||
| if config_path is not None: | ||
| config_path = os.path.abspath(config_path) | ||
| repo_path = os.getcwd() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| elif service_name is None: | ||
| repo_path = os.getcwd() | ||
| else: | ||
| coderoot = get_coderoot() | ||
| services = get_local_services(coderoot) | ||
| for service in services: | ||
| if service.name.lower() == service_name.lower(): | ||
| return service | ||
| unique_service_names = sorted(set(service.name for service in services)) | ||
| error_message = f"Service '{service_name}' not found." | ||
| if len(unique_service_names) > 0: | ||
| service_bullet_points = "\n".join( | ||
| [f"- {service_name}" for service_name in unique_service_names] | ||
| ) | ||
| error_message += "\nSupported services:\n" + service_bullet_points | ||
| raise ServiceNotFoundError(error_message) | ||
|
|
||
| service_config = load_service_config_from_file(repo_path, config_path=config_path) | ||
| return Service( | ||
| name=service_config.service_name, | ||
| repo_path=repo_path, | ||
| config=service_config, | ||
| ) | ||
|
|
||
|
|
||
| def get_active_service_names(clean_stale_entries: bool = False) -> set[str]: | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: When using the
--configflag,repo_pathis incorrectly set to the current working directory instead of being derived from the providedconfig_path, causing subsequent commands to fail.Severity: CRITICAL
Suggested Fix
Modify the logic to derive
repo_pathfrom the absolute path of theconfig_pathprovided. The path should be the grandparent directory if the config is inside adevservices/directory, or the parent directory otherwise, as stated in the pull request's description.Prompt for AI Agent