Skip to content

Commit d6ad50e

Browse files
authored
Merge pull request #445 from element-hq/bbz/corectly-attribute-sidecar-resources
Correctly link sidecar resources again
2 parents 62b356c + 86012dd commit d6ad50e

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed
File renamed without changes.

tests/manifests/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def owns_manifest_named(self, manifest_name: str) -> bool:
159159
pass
160160

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

165165

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

195195
return manifest_name.startswith(self.name)
196196

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

200200

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

214-
def deployable_details_for_container(self, container_name: str | None) -> DeployableDetails:
214+
def deployable_details_for_container(self, container_name: str) -> DeployableDetails:
215215
for sidecar in self.sidecars:
216216
if sidecar.deployable_details_for_container(container_name) is not None:
217217
return sidecar
@@ -281,7 +281,7 @@ def owns_manifest_named(self, manifest_name: str) -> bool:
281281

282282
return manifest_name.startswith(self.name)
283283

284-
def deployable_details_for_container(self, container_name: str | None) -> DeployableDetails:
284+
def deployable_details_for_container(self, container_name: str) -> DeployableDetails:
285285
for sidecar in self.sidecars:
286286
if sidecar.deployable_details_for_container(container_name) is not None:
287287
return sidecar

tests/manifests/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,13 @@ def _template_to_deployable_details(
319319
match = deployable_details
320320

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

328331
return _template_to_deployable_details

0 commit comments

Comments
 (0)