Skip to content
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

ServiceVariables: deduce service name from repository path #528

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions tdp/core/variables/cluster_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def initialize_cluster_variables(
else:
repo = repository_class.init(service_tdp_vars)
schemas = collections.get_service_schema(service)
service_variables = ServiceVariables(service, repo, schemas)
service_variables = ServiceVariables(repo, schemas)
cluster_variables[service] = service_variables

try:
Expand Down Expand Up @@ -155,9 +155,7 @@ def get_cluster_variables(
if path.is_dir():
repo = repository_class(tdp_vars / path.name)
schemas = collections.get_service_schema(path.stem)
cluster_variables[path.name] = ServiceVariables(
path.name, repo, schemas
)
cluster_variables[path.name] = ServiceVariables(repo, schemas)

cluster_variables = ClusterVariables(cluster_variables)

Expand Down
10 changes: 5 additions & 5 deletions tdp/core/variables/service_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __repr__(self):
class ServiceVariables:
"""Variables of a service."""

def __init__(self, service_name: str, repository: Repository, schema: dict):
def __init__(self, repository: Repository, schema: dict):
"""Initialize a ServiceVariables object.

Args:
Expand All @@ -54,16 +54,16 @@ def __init__(self, service_name: str, repository: Repository, schema: dict):
Raises:
ValueError: If the service name is longer than SERVICE_NAME_MAX_LENGTH.
"""
if len(service_name) > SERVICE_NAME_MAX_LENGTH:
raise ValueError(f"{service_name} is longer than {SERVICE_NAME_MAX_LENGTH}")
self._name = service_name
self._repo = repository
# Check that the service name is not too long
if len(self.name) > SERVICE_NAME_MAX_LENGTH:
raise ValueError(f"{self.name} is longer than {SERVICE_NAME_MAX_LENGTH}")
self._schema = schema

@property
def name(self) -> str:
"""Name of the service."""
return self._name
return self.path.name

@property
def repository(self) -> Repository:
Expand Down
Loading