|
29 | 29 | from infrahub.dependencies.registry import get_component_registry |
30 | 30 | from infrahub.events.branch_action import BranchCreatedEvent, BranchDeletedEvent, BranchMergedEvent, BranchRebasedEvent |
31 | 31 | from infrahub.events.models import EventMeta, InfrahubEvent |
32 | | -from infrahub.events.node_action import NodeMutatedEvent |
| 32 | +from infrahub.events.node_action import get_node_event |
33 | 33 | from infrahub.exceptions import BranchNotFoundError, MergeFailedError, ValidationError |
34 | 34 | from infrahub.graphql.mutations.models import BranchCreateModel # noqa: TC001 |
35 | 35 | from infrahub.log import get_log_data |
|
46 | 46 |
|
47 | 47 |
|
48 | 48 | @flow(name="branch-rebase", flow_run_name="Rebase branch {branch}") |
49 | | -async def rebase_branch(branch: str, context: InfrahubContext, service: InfrahubServices) -> None: |
| 49 | +async def rebase_branch(branch: str, context: InfrahubContext, service: InfrahubServices) -> None: # noqa: PLR0915 |
50 | 50 | async with service.database.start_session() as db: |
51 | 51 | log = get_run_logger() |
52 | 52 | await add_tags(branches=[branch]) |
@@ -175,11 +175,11 @@ async def rebase_branch(branch: str, context: InfrahubContext, service: Infrahub |
175 | 175 | diff=default_branch_diff, branch=obj, db=db, migration_tracker=MigrationTracker(migrations=migrations) |
176 | 176 | ) |
177 | 177 | for action, node_changelog in changelog_collector.collect_changelogs(): |
178 | | - mutate_event = NodeMutatedEvent( |
| 178 | + node_event_class = get_node_event(MutationAction.from_diff_action(diff_action=action)) |
| 179 | + mutate_event = node_event_class( |
179 | 180 | kind=node_changelog.node_kind, |
180 | 181 | node_id=node_changelog.node_id, |
181 | | - data=node_changelog, |
182 | | - action=MutationAction.from_diff_action(diff_action=action), |
| 182 | + changelog=node_changelog, |
183 | 183 | fields=node_changelog.updated_fields, |
184 | 184 | meta=EventMeta.from_parent(parent=rebase_event, branch=obj), |
185 | 185 | ) |
@@ -282,11 +282,11 @@ async def merge_branch(branch: str, context: InfrahubContext, service: InfrahubS |
282 | 282 |
|
283 | 283 | for action, node_changelog in node_events: |
284 | 284 | meta = EventMeta.from_parent(parent=merge_event, branch=default_branch) |
285 | | - mutate_event = NodeMutatedEvent( |
| 285 | + node_event_class = get_node_event(MutationAction.from_diff_action(diff_action=action)) |
| 286 | + mutate_event = node_event_class( |
286 | 287 | kind=node_changelog.node_kind, |
287 | 288 | node_id=node_changelog.node_id, |
288 | | - data=node_changelog, |
289 | | - action=MutationAction.from_diff_action(diff_action=action), |
| 289 | + changelog=node_changelog, |
290 | 290 | fields=node_changelog.updated_fields, |
291 | 291 | meta=meta, |
292 | 292 | ) |
|
0 commit comments