|
32 | 32 | ProposedChangeRepository, |
33 | 33 | ProposedChangeSubscriber, |
34 | 34 | ) |
| 35 | +from infrahub.proposed_change.models import RequestProposedChangeDataIntegrity |
35 | 36 | from infrahub.pytest_plugin import InfrahubBackendPlugin |
36 | 37 | from infrahub.services import InfrahubServices # noqa: TCH001 |
| 38 | +from infrahub.workflows.catalogue import REQUEST_PROPOSED_CHANGE_DATA_INTEGRITY |
37 | 39 |
|
38 | 40 | if TYPE_CHECKING: |
39 | 41 | from infrahub_sdk.node import InfrahubNode |
@@ -71,23 +73,6 @@ def log_line(self) -> str: |
71 | 73 | return "Doesn't require changes due to no relevant modified kinds or file changes in Git" |
72 | 74 |
|
73 | 75 |
|
74 | | -@flow(name="proposed-changed-data-integrity") |
75 | | -async def data_integrity(message: messages.RequestProposedChangeDataIntegrity, service: InfrahubServices) -> None: |
76 | | - """Triggers a data integrity validation check on the provided proposed change to start.""" |
77 | | - async with service.task_report( |
78 | | - related_node=message.proposed_change, |
79 | | - title="Data Integrity", |
80 | | - ): |
81 | | - log.info(f"Got a request to process data integrity defined in proposed_change: {message.proposed_change}") |
82 | | - |
83 | | - destination_branch = await registry.get_branch(db=service.database, branch=message.destination_branch) |
84 | | - source_branch = await registry.get_branch(db=service.database, branch=message.source_branch) |
85 | | - component_registry = get_component_registry() |
86 | | - async with service.database.start_transaction() as dbt: |
87 | | - diff_coordinator = await component_registry.get_component(DiffCoordinator, db=dbt, branch=source_branch) |
88 | | - await diff_coordinator.update_branch_diff(base_branch=destination_branch, diff_branch=source_branch) |
89 | | - |
90 | | - |
91 | 76 | @flow(name="proposed-changed-pipeline") |
92 | 77 | async def pipeline(message: messages.RequestProposedChangePipeline, service: InfrahubServices) -> None: |
93 | 78 | async with service.task_report( |
@@ -164,14 +149,15 @@ async def pipeline(message: messages.RequestProposedChangePipeline, service: Inf |
164 | 149 | branch=message.source_branch |
165 | 150 | ): |
166 | 151 | await task_report.info("Adding Data Integrity job", proposed_change=message.proposed_change) |
167 | | - events.append( |
168 | | - messages.RequestProposedChangeDataIntegrity( |
169 | | - proposed_change=message.proposed_change, |
170 | | - source_branch=message.source_branch, |
171 | | - source_branch_sync_with_git=message.source_branch_sync_with_git, |
172 | | - destination_branch=message.destination_branch, |
173 | | - branch_diff=branch_diff, |
174 | | - ) |
| 152 | + model = RequestProposedChangeDataIntegrity( |
| 153 | + proposed_change=message.proposed_change, |
| 154 | + source_branch=message.source_branch, |
| 155 | + source_branch_sync_with_git=message.source_branch_sync_with_git, |
| 156 | + destination_branch=message.destination_branch, |
| 157 | + branch_diff=branch_diff, |
| 158 | + ) |
| 159 | + await service.workflow.submit_workflow( |
| 160 | + workflow=REQUEST_PROPOSED_CHANGE_DATA_INTEGRITY, parameters={"model": model} |
175 | 161 | ) |
176 | 162 |
|
177 | 163 | if message.check_type in [CheckType.REPOSITORY, CheckType.USER]: |
|
0 commit comments