Skip to content

Commit acb4a22

Browse files
authored
Merge branch 'release-1.2' into dga-20250309-stable-2-release
2 parents b6023d2 + 2125843 commit acb4a22

File tree

34 files changed

+141
-307
lines changed

34 files changed

+141
-307
lines changed

backend/infrahub/core/schema/schema_branch.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,12 +1833,11 @@ def add_relationships_to_template(self, node: NodeSchema) -> None:
18331833
template_schema.relationships = [
18341834
r for r in template_schema.relationships if r.kind == RelationshipKind.TEMPLATE
18351835
]
1836+
# Tell if the user explicitely requested this template
1837+
is_autogenerated_subtemplate = node.generate_template is False
18361838

18371839
for relationship in node.relationships:
1838-
if relationship.peer in [
1839-
InfrahubKind.GENERICGROUP,
1840-
InfrahubKind.PROFILE,
1841-
] or relationship.kind not in [
1840+
if relationship.peer in [InfrahubKind.GENERICGROUP, InfrahubKind.PROFILE] or relationship.kind not in [
18421841
RelationshipKind.COMPONENT,
18431842
RelationshipKind.PARENT,
18441843
RelationshipKind.ATTRIBUTE,
@@ -1856,8 +1855,9 @@ def add_relationships_to_template(self, node: NodeSchema) -> None:
18561855
name=relationship.name,
18571856
peer=rel_template_peer,
18581857
kind=relationship.kind,
1859-
optional=relationship.kind
1860-
in [RelationshipKind.COMPONENT, RelationshipKind.ATTRIBUTE, RelationshipKind.GENERIC],
1858+
optional=relationship.optional
1859+
if is_autogenerated_subtemplate
1860+
else relationship.kind != RelationshipKind.PARENT,
18611861
cardinality=relationship.cardinality,
18621862
branch=relationship.branch,
18631863
identifier=self._generate_identifier_string(template_schema.kind, rel_template_peer),
@@ -1928,12 +1928,15 @@ def generate_object_template_from_node(
19281928
if inherited in need_template_kinds:
19291929
template.inherit_from.append(self._get_object_template_kind(node_kind=inherited))
19301930

1931+
# Tell if the user explicitely requested this template
1932+
is_autogenerated_subtemplate = node.generate_template is False
19311933
for node_attr in node.attributes:
19321934
if node_attr.unique:
19331935
continue
19341936

19351937
attr = AttributeSchema(
1936-
optional=True, **node_attr.model_dump(exclude=["id", "unique", "optional", "read_only", "inherited"])
1938+
optional=node_attr.optional if is_autogenerated_subtemplate else True,
1939+
**node_attr.model_dump(exclude=["id", "unique", "optional", "read_only", "inherited"]),
19371940
)
19381941
template.attributes.append(attr)
19391942

backend/infrahub/message_bus/messages/__init__.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
from infrahub.message_bus import InfrahubMessage, InfrahubResponse
22

33
from .check_generator_run import CheckGeneratorRun
4-
from .event_branch_create import EventBranchCreate
5-
from .event_branch_delete import EventBranchDelete
64
from .event_branch_merge import EventBranchMerge
7-
from .event_branch_rebased import EventBranchRebased
8-
from .event_node_mutated import EventNodeMutated
9-
from .event_schema_update import EventSchemaUpdate
105
from .event_worker_newprimaryapi import EventWorkerNewPrimaryAPI
116
from .finalize_validator_execution import FinalizeValidatorExecution
127
from .git_file_get import GitFileGet, GitFileGetResponse
@@ -21,12 +16,7 @@
2116

2217
MESSAGE_MAP: dict[str, type[InfrahubMessage]] = {
2318
"check.generator.run": CheckGeneratorRun,
24-
"event.branch.create": EventBranchCreate,
25-
"event.branch.delete": EventBranchDelete,
2619
"event.branch.merge": EventBranchMerge,
27-
"event.branch.rebased": EventBranchRebased,
28-
"event.node.mutated": EventNodeMutated,
29-
"event.schema.update": EventSchemaUpdate,
3020
"event.worker.new_primary_api": EventWorkerNewPrimaryAPI,
3121
"finalize.validator.execution": FinalizeValidatorExecution,
3222
"git.file.get": GitFileGet,
@@ -49,7 +39,7 @@
4939
"check.artifact.create": 2,
5040
"check.repository.check_definition": 2,
5141
"check.repository.merge_conflicts": 2,
52-
"event.branch.create": 5,
42+
"send.echo.request": 5, # Currently only for testing purposes, will be removed once all message bus have been migrated to prefect
5343
"event.branch.delete": 5,
5444
"event.branch.merge": 5,
5545
"event.schema.update": 5,

backend/infrahub/message_bus/messages/event_branch_create.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

backend/infrahub/message_bus/messages/event_branch_delete.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

backend/infrahub/message_bus/messages/event_branch_rebased.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

backend/infrahub/message_bus/messages/event_node_mutated.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

backend/infrahub/message_bus/messages/event_schema_update.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

backend/infrahub/message_bus/operations/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
COMMAND_MAP = {
1919
"check.generator.run": check.generator.run,
2020
"event.branch.merge": event.branch.merge,
21-
"event.node.mutated": event.node.mutated,
22-
"event.schema.update": event.schema.update,
2321
"event.worker.new_primary_api": event.worker.new_primary_api,
2422
"finalize.validator.execution": finalize.validator.execution,
2523
"git.file.get": git.file.get,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from . import branch, node, schema, worker
1+
from . import branch, worker
22

3-
__all__ = ["branch", "node", "schema", "worker"]
3+
__all__ = ["branch", "worker"]

backend/infrahub/message_bus/operations/event/node.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)