infrahub-server 1.2.3__py3-none-any.whl → 1.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. infrahub/cli/db.py +308 -2
  2. infrahub/cli/git_agent.py +4 -10
  3. infrahub/config.py +32 -0
  4. infrahub/core/branch/tasks.py +50 -10
  5. infrahub/core/constants/__init__.py +1 -0
  6. infrahub/core/constraint/node/runner.py +6 -5
  7. infrahub/core/graph/__init__.py +1 -1
  8. infrahub/core/migrations/graph/__init__.py +4 -0
  9. infrahub/core/migrations/graph/m018_uniqueness_nulls.py +68 -70
  10. infrahub/core/migrations/graph/m025_uniqueness_nulls.py +26 -0
  11. infrahub/core/migrations/graph/m026_0000_prefix_fix.py +54 -0
  12. infrahub/core/migrations/schema/node_attribute_remove.py +16 -2
  13. infrahub/core/models.py +1 -1
  14. infrahub/core/node/__init__.py +4 -1
  15. infrahub/core/node/constraints/grouped_uniqueness.py +6 -1
  16. infrahub/core/node/resource_manager/number_pool.py +1 -1
  17. infrahub/core/registry.py +18 -0
  18. infrahub/core/schema/basenode_schema.py +21 -1
  19. infrahub/core/schema/definitions/internal.py +2 -1
  20. infrahub/core/schema/generated/base_node_schema.py +1 -1
  21. infrahub/core/schema/manager.py +21 -1
  22. infrahub/core/schema/schema_branch.py +8 -7
  23. infrahub/core/schema/schema_branch_computed.py +12 -1
  24. infrahub/database/__init__.py +10 -0
  25. infrahub/events/branch_action.py +3 -0
  26. infrahub/events/group_action.py +6 -1
  27. infrahub/events/node_action.py +5 -1
  28. infrahub/git/integrator.py +2 -2
  29. infrahub/graphql/mutations/main.py +10 -12
  30. infrahub/message_bus/messages/__init__.py +0 -4
  31. infrahub/message_bus/messages/request_proposedchange_pipeline.py +5 -0
  32. infrahub/message_bus/operations/__init__.py +0 -3
  33. infrahub/message_bus/operations/requests/proposed_change.py +29 -9
  34. infrahub/message_bus/types.py +2 -34
  35. infrahub/proposed_change/branch_diff.py +65 -0
  36. infrahub/proposed_change/tasks.py +12 -4
  37. infrahub/server.py +6 -11
  38. infrahub/services/adapters/cache/__init__.py +17 -0
  39. infrahub/services/adapters/cache/redis.py +11 -1
  40. infrahub/services/adapters/message_bus/__init__.py +20 -0
  41. infrahub/services/adapters/workflow/worker.py +1 -1
  42. infrahub/services/component.py +1 -2
  43. infrahub/tasks/registry.py +3 -7
  44. infrahub/workers/infrahub_async.py +4 -10
  45. infrahub/workflows/catalogue.py +10 -0
  46. infrahub_sdk/generator.py +1 -0
  47. infrahub_sdk/node.py +16 -4
  48. infrahub_sdk/schema/__init__.py +10 -1
  49. {infrahub_server-1.2.3.dist-info → infrahub_server-1.2.5.dist-info}/METADATA +2 -2
  50. {infrahub_server-1.2.3.dist-info → infrahub_server-1.2.5.dist-info}/RECORD +57 -60
  51. infrahub_testcontainers/container.py +4 -0
  52. infrahub_testcontainers/helpers.py +1 -1
  53. infrahub_testcontainers/models.py +2 -2
  54. infrahub_testcontainers/performance_test.py +4 -4
  55. infrahub/core/branch/flow_models.py +0 -0
  56. infrahub/message_bus/messages/event_branch_merge.py +0 -13
  57. infrahub/message_bus/messages/event_worker_newprimaryapi.py +0 -9
  58. infrahub/message_bus/operations/event/__init__.py +0 -3
  59. infrahub/message_bus/operations/event/branch.py +0 -61
  60. infrahub/message_bus/operations/event/worker.py +0 -9
  61. {infrahub_server-1.2.3.dist-info → infrahub_server-1.2.5.dist-info}/LICENSE.txt +0 -0
  62. {infrahub_server-1.2.3.dist-info → infrahub_server-1.2.5.dist-info}/WHEEL +0 -0
  63. {infrahub_server-1.2.3.dist-info → infrahub_server-1.2.5.dist-info}/entry_points.txt +0 -0
@@ -1,61 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from prefect import flow
4
-
5
- from infrahub.core import registry
6
- from infrahub.core.diff.model.path import BranchTrackingId
7
- from infrahub.core.diff.models import RequestDiffUpdate
8
- from infrahub.core.diff.repository.repository import DiffRepository
9
- from infrahub.dependencies.registry import get_component_registry
10
- from infrahub.log import get_logger
11
- from infrahub.message_bus import InfrahubMessage, messages
12
- from infrahub.services import InfrahubServices # noqa: TC001 needed for prefect flow
13
- from infrahub.workflows.catalogue import (
14
- DIFF_UPDATE,
15
- TRIGGER_ARTIFACT_DEFINITION_GENERATE,
16
- TRIGGER_GENERATOR_DEFINITION_RUN,
17
- )
18
-
19
- log = get_logger()
20
-
21
-
22
- @flow(name="branch-event-merge")
23
- async def merge(message: messages.EventBranchMerge, service: InfrahubServices) -> None:
24
- async with service.database.start_session() as db:
25
- log.info("Branch merged", source_branch=message.source_branch, target_branch=message.target_branch)
26
-
27
- events: list[InfrahubMessage] = [
28
- messages.RefreshRegistryBranches(),
29
- ]
30
- component_registry = get_component_registry()
31
- default_branch = registry.get_branch_from_registry()
32
- diff_repository = await component_registry.get_component(DiffRepository, db=db, branch=default_branch)
33
- # send diff update requests for every branch-tracking diff
34
- branch_diff_roots = await diff_repository.get_roots_metadata(base_branch_names=[message.target_branch])
35
-
36
- await service.workflow.submit_workflow(
37
- workflow=TRIGGER_ARTIFACT_DEFINITION_GENERATE,
38
- context=message.context,
39
- parameters={"branch": message.target_branch},
40
- )
41
-
42
- await service.workflow.submit_workflow(
43
- workflow=TRIGGER_GENERATOR_DEFINITION_RUN,
44
- context=message.context,
45
- parameters={"branch": message.target_branch},
46
- )
47
-
48
- for diff_root in branch_diff_roots:
49
- if (
50
- diff_root.base_branch_name != diff_root.diff_branch_name
51
- and diff_root.tracking_id
52
- and isinstance(diff_root.tracking_id, BranchTrackingId)
53
- ):
54
- request_diff_update_model = RequestDiffUpdate(branch_name=diff_root.diff_branch_name)
55
- await service.workflow.submit_workflow(
56
- workflow=DIFF_UPDATE, context=message.context, parameters={"model": request_diff_update_model}
57
- )
58
-
59
- for event in events:
60
- event.assign_meta(parent=message)
61
- await service.message_bus.send(message=event)
@@ -1,9 +0,0 @@
1
- from prefect import flow
2
-
3
- from infrahub.message_bus import messages
4
- from infrahub.services import InfrahubServices
5
-
6
-
7
- @flow(name="event-worker-newprimary-api")
8
- async def new_primary_api(message: messages.EventWorkerNewPrimaryAPI, service: InfrahubServices) -> None:
9
- service.log.info("api_worker promoted to primary", worker_id=message.worker_id)