Skip to content

Correctly link sidecar resources again #445

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

Merged
merged 1 commit into from
May 13, 2025
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
File renamed without changes.
10 changes: 5 additions & 5 deletions tests/manifests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def owns_manifest_named(self, manifest_name: str) -> bool:
pass

@abc.abstractmethod
def deployable_details_for_container(self, container_name: str | None) -> "DeployableDetails | None":
def deployable_details_for_container(self, container_name: str) -> "DeployableDetails | None":
pass


Expand Down Expand Up @@ -194,8 +194,8 @@ def owns_manifest_named(self, manifest_name: str) -> bool:

return manifest_name.startswith(self.name)

def deployable_details_for_container(self, container_name: str | None) -> DeployableDetails | None:
return self if container_name is not None and container_name.startswith(self.name) else None
def deployable_details_for_container(self, container_name: str) -> DeployableDetails | None:
return self if container_name.startswith(self.name) else None


@dataclass(unsafe_hash=True)
Expand All @@ -211,7 +211,7 @@ def __post_init__(self):
def owns_manifest_named(self, manifest_name: str) -> bool:
return manifest_name.startswith(self.name)

def deployable_details_for_container(self, container_name: str | None) -> DeployableDetails:
def deployable_details_for_container(self, container_name: str) -> DeployableDetails:
for sidecar in self.sidecars:
if sidecar.deployable_details_for_container(container_name) is not None:
return sidecar
Expand Down Expand Up @@ -281,7 +281,7 @@ def owns_manifest_named(self, manifest_name: str) -> bool:

return manifest_name.startswith(self.name)

def deployable_details_for_container(self, container_name: str | None) -> DeployableDetails:
def deployable_details_for_container(self, container_name: str) -> DeployableDetails:
for sidecar in self.sidecars:
if sidecar.deployable_details_for_container(container_name) is not None:
return sidecar
Expand Down
11 changes: 7 additions & 4 deletions tests/manifests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,13 @@ def _template_to_deployable_details(
match = deployable_details

assert match is not None, f"{template_id(template)} can't be linked to any (sub-)component"
match = match.deployable_details_for_container(container_name)
assert match is not None, (
f"{template_id(template)} can't be linked to any (sub-)component or specific container"
)
# If this is a template that has multiple containers, the containers could have different ownership
# e.g. a sidecar. For everything else we don't need to check further as there's no shared ownership
if container_name is not None:
match = match.deployable_details_for_container(container_name)
assert match is not None, (
f"{template_id(template)} can't be linked to any (sub-)component or specific container"
)
return match

return _template_to_deployable_details
Expand Down
Loading