Skip to content
Draft
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
8 changes: 1 addition & 7 deletions backend/infrahub/core/schema/schema_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,8 +2051,6 @@ def add_relationships_to_template(self, node: NodeSchema | GenericSchema) -> Non
template_schema.relationships = [
r for r in template_schema.relationships if r.kind == RelationshipKind.TEMPLATE
]
# Tell if the user explicitely requested this template
is_autogenerated_subtemplate = node.generate_template is False

for relationship in node.relationships:
if relationship.peer in [InfrahubKind.GENERICGROUP, InfrahubKind.PROFILE] or relationship.kind not in [
Expand All @@ -2068,10 +2066,6 @@ def add_relationships_to_template(self, node: NodeSchema | GenericSchema) -> Non
if relationship.kind not in [RelationshipKind.ATTRIBUTE, RelationshipKind.GENERIC]
else relationship.peer
)

is_optional = (
relationship.optional if is_autogenerated_subtemplate else relationship.kind != RelationshipKind.PARENT
)
identifier = (
f"template_{relationship.identifier}"
if relationship.identifier
Expand All @@ -2088,7 +2082,7 @@ def add_relationships_to_template(self, node: NodeSchema | GenericSchema) -> Non
name=relationship.name,
peer=rel_template_peer,
kind=relationship.kind,
optional=is_optional,
optional=True,
cardinality=relationship.cardinality,
direction=relationship.direction,
branch=relationship.branch,
Expand Down
Loading