infrahub-server 1.5.0b0__py3-none-any.whl → 1.5.0b2__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 (183) hide show
  1. infrahub/actions/tasks.py +8 -0
  2. infrahub/api/diff/diff.py +1 -1
  3. infrahub/api/internal.py +2 -0
  4. infrahub/api/oauth2.py +13 -19
  5. infrahub/api/oidc.py +15 -21
  6. infrahub/api/schema.py +24 -3
  7. infrahub/artifacts/models.py +2 -1
  8. infrahub/auth.py +137 -3
  9. infrahub/cli/__init__.py +2 -0
  10. infrahub/cli/db.py +103 -98
  11. infrahub/cli/db_commands/clean_duplicate_schema_fields.py +212 -0
  12. infrahub/cli/dev.py +118 -0
  13. infrahub/cli/tasks.py +46 -0
  14. infrahub/cli/upgrade.py +30 -3
  15. infrahub/computed_attribute/tasks.py +20 -8
  16. infrahub/core/attribute.py +13 -5
  17. infrahub/core/branch/enums.py +1 -1
  18. infrahub/core/branch/models.py +7 -3
  19. infrahub/core/branch/tasks.py +70 -8
  20. infrahub/core/changelog/models.py +4 -12
  21. infrahub/core/constants/__init__.py +3 -0
  22. infrahub/core/constants/infrahubkind.py +1 -0
  23. infrahub/core/diff/model/path.py +4 -0
  24. infrahub/core/diff/payload_builder.py +1 -1
  25. infrahub/core/diff/query/artifact.py +1 -0
  26. infrahub/core/diff/query/field_summary.py +1 -0
  27. infrahub/core/graph/__init__.py +1 -1
  28. infrahub/core/initialization.py +5 -2
  29. infrahub/core/ipam/utilization.py +1 -1
  30. infrahub/core/manager.py +6 -3
  31. infrahub/core/migrations/__init__.py +3 -0
  32. infrahub/core/migrations/exceptions.py +4 -0
  33. infrahub/core/migrations/graph/__init__.py +12 -11
  34. infrahub/core/migrations/graph/load_schema_branch.py +21 -0
  35. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +1 -1
  36. infrahub/core/migrations/graph/m040_duplicated_attributes.py +81 -0
  37. infrahub/core/migrations/graph/m041_profile_attrs_in_db.py +145 -0
  38. infrahub/core/migrations/graph/m042_create_hfid_display_label_in_db.py +164 -0
  39. infrahub/core/migrations/graph/m043_backfill_hfid_display_label_in_db.py +866 -0
  40. infrahub/core/migrations/query/__init__.py +7 -8
  41. infrahub/core/migrations/query/attribute_add.py +8 -6
  42. infrahub/core/migrations/query/attribute_remove.py +134 -0
  43. infrahub/core/migrations/runner.py +54 -0
  44. infrahub/core/migrations/schema/attribute_kind_update.py +9 -3
  45. infrahub/core/migrations/schema/attribute_supports_profile.py +90 -0
  46. infrahub/core/migrations/schema/node_attribute_add.py +35 -4
  47. infrahub/core/migrations/schema/node_attribute_remove.py +13 -109
  48. infrahub/core/migrations/schema/node_kind_update.py +2 -1
  49. infrahub/core/migrations/schema/node_remove.py +2 -1
  50. infrahub/core/migrations/schema/placeholder_dummy.py +3 -2
  51. infrahub/core/migrations/shared.py +52 -19
  52. infrahub/core/node/__init__.py +158 -51
  53. infrahub/core/node/constraints/attribute_uniqueness.py +3 -1
  54. infrahub/core/node/create.py +46 -63
  55. infrahub/core/node/lock_utils.py +70 -44
  56. infrahub/core/node/node_property_attribute.py +230 -0
  57. infrahub/core/node/resource_manager/ip_address_pool.py +2 -1
  58. infrahub/core/node/resource_manager/ip_prefix_pool.py +2 -1
  59. infrahub/core/node/resource_manager/number_pool.py +2 -1
  60. infrahub/core/node/standard.py +1 -1
  61. infrahub/core/protocols.py +7 -1
  62. infrahub/core/query/attribute.py +55 -0
  63. infrahub/core/query/ipam.py +1 -0
  64. infrahub/core/query/node.py +23 -4
  65. infrahub/core/query/relationship.py +1 -0
  66. infrahub/core/registry.py +2 -2
  67. infrahub/core/relationship/constraints/count.py +1 -1
  68. infrahub/core/relationship/model.py +1 -1
  69. infrahub/core/schema/__init__.py +56 -0
  70. infrahub/core/schema/attribute_schema.py +4 -0
  71. infrahub/core/schema/basenode_schema.py +42 -2
  72. infrahub/core/schema/definitions/core/__init__.py +2 -0
  73. infrahub/core/schema/definitions/core/generator.py +2 -0
  74. infrahub/core/schema/definitions/core/group.py +16 -2
  75. infrahub/core/schema/definitions/internal.py +16 -3
  76. infrahub/core/schema/generated/attribute_schema.py +2 -2
  77. infrahub/core/schema/generated/base_node_schema.py +6 -1
  78. infrahub/core/schema/manager.py +22 -1
  79. infrahub/core/schema/node_schema.py +5 -2
  80. infrahub/core/schema/schema_branch.py +300 -8
  81. infrahub/core/schema/schema_branch_display.py +123 -0
  82. infrahub/core/schema/schema_branch_hfid.py +114 -0
  83. infrahub/core/validators/aggregated_checker.py +1 -1
  84. infrahub/core/validators/determiner.py +12 -1
  85. infrahub/core/validators/relationship/peer.py +1 -1
  86. infrahub/core/validators/tasks.py +1 -1
  87. infrahub/database/graph.py +21 -0
  88. infrahub/display_labels/__init__.py +0 -0
  89. infrahub/display_labels/gather.py +48 -0
  90. infrahub/display_labels/models.py +240 -0
  91. infrahub/display_labels/tasks.py +192 -0
  92. infrahub/display_labels/triggers.py +22 -0
  93. infrahub/events/branch_action.py +27 -1
  94. infrahub/events/group_action.py +1 -1
  95. infrahub/events/node_action.py +1 -1
  96. infrahub/generators/constants.py +7 -0
  97. infrahub/generators/models.py +7 -0
  98. infrahub/generators/tasks.py +34 -22
  99. infrahub/git/base.py +4 -1
  100. infrahub/git/integrator.py +23 -15
  101. infrahub/git/models.py +2 -1
  102. infrahub/git/repository.py +22 -5
  103. infrahub/git/tasks.py +66 -10
  104. infrahub/git/utils.py +123 -1
  105. infrahub/graphql/analyzer.py +1 -1
  106. infrahub/graphql/api/endpoints.py +14 -4
  107. infrahub/graphql/manager.py +4 -9
  108. infrahub/graphql/mutations/convert_object_type.py +11 -1
  109. infrahub/graphql/mutations/display_label.py +118 -0
  110. infrahub/graphql/mutations/generator.py +25 -7
  111. infrahub/graphql/mutations/hfid.py +125 -0
  112. infrahub/graphql/mutations/ipam.py +54 -35
  113. infrahub/graphql/mutations/main.py +27 -28
  114. infrahub/graphql/mutations/relationship.py +2 -2
  115. infrahub/graphql/mutations/resource_manager.py +2 -2
  116. infrahub/graphql/mutations/schema.py +5 -5
  117. infrahub/graphql/queries/resource_manager.py +1 -1
  118. infrahub/graphql/resolvers/resolver.py +2 -0
  119. infrahub/graphql/schema.py +4 -0
  120. infrahub/graphql/schema_sort.py +170 -0
  121. infrahub/graphql/types/branch.py +4 -1
  122. infrahub/graphql/types/enums.py +3 -0
  123. infrahub/groups/tasks.py +1 -1
  124. infrahub/hfid/__init__.py +0 -0
  125. infrahub/hfid/gather.py +48 -0
  126. infrahub/hfid/models.py +240 -0
  127. infrahub/hfid/tasks.py +191 -0
  128. infrahub/hfid/triggers.py +22 -0
  129. infrahub/lock.py +67 -16
  130. infrahub/message_bus/types.py +2 -1
  131. infrahub/middleware.py +26 -1
  132. infrahub/permissions/constants.py +2 -0
  133. infrahub/proposed_change/tasks.py +35 -17
  134. infrahub/server.py +21 -4
  135. infrahub/services/__init__.py +8 -5
  136. infrahub/services/adapters/http/__init__.py +5 -0
  137. infrahub/services/adapters/workflow/worker.py +14 -3
  138. infrahub/task_manager/event.py +5 -0
  139. infrahub/task_manager/models.py +7 -0
  140. infrahub/task_manager/task.py +73 -0
  141. infrahub/trigger/catalogue.py +4 -0
  142. infrahub/trigger/models.py +2 -0
  143. infrahub/trigger/setup.py +13 -4
  144. infrahub/trigger/tasks.py +6 -0
  145. infrahub/workers/dependencies.py +10 -1
  146. infrahub/workers/infrahub_async.py +10 -2
  147. infrahub/workflows/catalogue.py +80 -0
  148. infrahub/workflows/initialization.py +21 -0
  149. infrahub/workflows/utils.py +2 -1
  150. infrahub_sdk/checks.py +1 -1
  151. infrahub_sdk/client.py +13 -10
  152. infrahub_sdk/config.py +29 -2
  153. infrahub_sdk/ctl/cli_commands.py +2 -0
  154. infrahub_sdk/ctl/generator.py +4 -0
  155. infrahub_sdk/ctl/graphql.py +184 -0
  156. infrahub_sdk/ctl/schema.py +28 -9
  157. infrahub_sdk/generator.py +7 -1
  158. infrahub_sdk/graphql/__init__.py +12 -0
  159. infrahub_sdk/graphql/constants.py +1 -0
  160. infrahub_sdk/graphql/plugin.py +85 -0
  161. infrahub_sdk/graphql/query.py +77 -0
  162. infrahub_sdk/{graphql.py → graphql/renderers.py} +81 -73
  163. infrahub_sdk/graphql/utils.py +40 -0
  164. infrahub_sdk/protocols.py +14 -0
  165. infrahub_sdk/schema/__init__.py +70 -4
  166. infrahub_sdk/schema/repository.py +8 -0
  167. infrahub_sdk/spec/models.py +7 -0
  168. infrahub_sdk/spec/object.py +53 -44
  169. infrahub_sdk/spec/processors/__init__.py +0 -0
  170. infrahub_sdk/spec/processors/data_processor.py +10 -0
  171. infrahub_sdk/spec/processors/factory.py +34 -0
  172. infrahub_sdk/spec/processors/range_expand_processor.py +56 -0
  173. infrahub_sdk/spec/range_expansion.py +1 -1
  174. infrahub_sdk/transforms.py +1 -1
  175. {infrahub_server-1.5.0b0.dist-info → infrahub_server-1.5.0b2.dist-info}/METADATA +7 -4
  176. {infrahub_server-1.5.0b0.dist-info → infrahub_server-1.5.0b2.dist-info}/RECORD +182 -143
  177. infrahub_testcontainers/container.py +115 -3
  178. infrahub_testcontainers/docker-compose-cluster.test.yml +6 -1
  179. infrahub_testcontainers/docker-compose.test.yml +6 -1
  180. infrahub/core/migrations/graph/m040_profile_attrs_in_db.py +0 -166
  181. {infrahub_server-1.5.0b0.dist-info → infrahub_server-1.5.0b2.dist-info}/LICENSE.txt +0 -0
  182. {infrahub_server-1.5.0b0.dist-info → infrahub_server-1.5.0b2.dist-info}/WHEEL +0 -0
  183. {infrahub_server-1.5.0b0.dist-info → infrahub_server-1.5.0b2.dist-info}/entry_points.txt +0 -0
File without changes
@@ -0,0 +1,10 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any
3
+
4
+
5
+ class DataProcessor(ABC):
6
+ """Abstract base class for data processing strategies"""
7
+
8
+ @abstractmethod
9
+ async def process_data(self, data: list[dict[str, Any]]) -> list[dict[str, Any]]:
10
+ """Process the data according to the strategy"""
@@ -0,0 +1,34 @@
1
+ from collections.abc import Sequence
2
+ from typing import Any
3
+
4
+ from ..models import InfrahubObjectParameters
5
+ from .data_processor import DataProcessor
6
+ from .range_expand_processor import RangeExpandDataProcessor
7
+
8
+ PROCESSOR_PER_KIND: dict[str, DataProcessor] = {}
9
+
10
+
11
+ class DataProcessorFactory:
12
+ """Factory to create appropriate data processor based on strategy"""
13
+
14
+ @classmethod
15
+ def get_processors(cls, kind: str, parameters: InfrahubObjectParameters) -> Sequence[DataProcessor]:
16
+ processors: list[DataProcessor] = []
17
+ if parameters.expand_range:
18
+ processors.append(RangeExpandDataProcessor())
19
+ if kind in PROCESSOR_PER_KIND:
20
+ processors.append(PROCESSOR_PER_KIND[kind])
21
+
22
+ return processors
23
+
24
+ @classmethod
25
+ async def process_data(
26
+ cls,
27
+ kind: str,
28
+ data: list[dict[str, Any]],
29
+ parameters: InfrahubObjectParameters,
30
+ ) -> list[dict[str, Any]]:
31
+ processors = cls.get_processors(kind=kind, parameters=parameters)
32
+ for processor in processors:
33
+ data = await processor.process_data(data=data)
34
+ return data
@@ -0,0 +1,56 @@
1
+ from __future__ import annotations
2
+
3
+ import copy
4
+ import logging
5
+ import re
6
+ from typing import Any
7
+
8
+ from ...exceptions import ValidationError
9
+ from ..range_expansion import MATCH_PATTERN, range_expansion
10
+ from .data_processor import DataProcessor
11
+
12
+ log = logging.getLogger("infrahub_sdk")
13
+
14
+
15
+ class RangeExpandDataProcessor(DataProcessor):
16
+ """Process data with range expansion"""
17
+
18
+ @classmethod
19
+ async def process_data(
20
+ cls,
21
+ data: list[dict[str, Any]],
22
+ ) -> list[dict[str, Any]]:
23
+ """Expand any item in data with range pattern in any value. Supports multiple fields, requires equal expansion length."""
24
+ range_pattern = re.compile(MATCH_PATTERN)
25
+ expanded = []
26
+ for item in data:
27
+ # Find all fields to expand
28
+ expand_fields = {}
29
+ for key, value in item.items():
30
+ if isinstance(value, str) and range_pattern.search(value):
31
+ try:
32
+ expand_fields[key] = range_expansion(value)
33
+ except (ValueError, TypeError, KeyError):
34
+ # If expansion fails, treat as no expansion
35
+ log.debug(
36
+ f"Range expansion failed for value '{value}' in key '{key}'. Treating as no expansion."
37
+ )
38
+ expand_fields[key] = [value]
39
+ if not expand_fields:
40
+ expanded.append(item)
41
+ continue
42
+ # Check all expanded lists have the same length
43
+ lengths = [len(v) for v in expand_fields.values()]
44
+ if len(set(lengths)) > 1:
45
+ raise ValidationError(
46
+ identifier="range_expansion",
47
+ message=f"Range expansion mismatch: fields expanded to different lengths: {lengths}",
48
+ )
49
+ n = lengths[0]
50
+ # Zip expanded values and produce new items
51
+ for i in range(n):
52
+ new_item = copy.deepcopy(item)
53
+ for key, values in expand_fields.items():
54
+ new_item[key] = values[i]
55
+ expanded.append(new_item)
56
+ return expanded
@@ -1,7 +1,7 @@
1
1
  import itertools
2
2
  import re
3
3
 
4
- MATCH_PATTERN = r"(\[[\w,-]+\])"
4
+ MATCH_PATTERN = r"(\[[\w,-]*[-,][\w,-]*\])"
5
5
 
6
6
 
7
7
  def _escape_brackets(s: str) -> str:
@@ -17,7 +17,7 @@ INFRAHUB_TRANSFORM_VARIABLE_TO_IMPORT = "INFRAHUB_TRANSFORMS"
17
17
  class InfrahubTransform(InfrahubOperation):
18
18
  name: str | None = None
19
19
  query: str
20
- timeout: int = 10
20
+ timeout: int = 60
21
21
 
22
22
  def __init__(
23
23
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: infrahub-server
3
- Version: 1.5.0b0
3
+ Version: 1.5.0b2
4
4
  Summary: Infrahub is taking a new approach to Infrastructure Management by providing a new generation of datastore to organize and control all the data that defines how an infrastructure should run.
5
5
  License: Apache-2.0
6
6
  Author: OpsMill
@@ -13,10 +13,13 @@ Classifier: Programming Language :: Python :: 3.12
13
13
  Requires-Dist: Jinja2 (>=3,<4)
14
14
  Requires-Dist: aio-pika (>=9.4,<9.5)
15
15
  Requires-Dist: aiodataloader (==0.4.0)
16
+ Requires-Dist: ariadne-codegen (==0.15.3)
16
17
  Requires-Dist: asgi-correlation-id (==4.2.0)
17
- Requires-Dist: authlib (==1.3.2)
18
+ Requires-Dist: authlib (==1.6.5)
18
19
  Requires-Dist: bcrypt (>=4.1,<4.2)
19
20
  Requires-Dist: boto3 (==1.34.129)
21
+ Requires-Dist: cachetools-async (>=0.0.5,<0.0.6)
22
+ Requires-Dist: click (==8.1.7)
20
23
  Requires-Dist: copier (>=9.8.0,<10.0.0)
21
24
  Requires-Dist: dulwich (>=0.22.7,<0.23.0)
22
25
  Requires-Dist: email-validator (>=2.1,<2.2)
@@ -37,8 +40,8 @@ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (==1.28.1)
37
40
  Requires-Dist: opentelemetry-exporter-otlp-proto-http (==1.28.1)
38
41
  Requires-Dist: opentelemetry-instrumentation-aio-pika (==0.49b1)
39
42
  Requires-Dist: opentelemetry-instrumentation-fastapi (==0.49b1)
40
- Requires-Dist: prefect (==3.4.22)
41
- Requires-Dist: prefect-redis (==0.2.4)
43
+ Requires-Dist: prefect (==3.4.23)
44
+ Requires-Dist: prefect-redis (==0.2.5)
42
45
  Requires-Dist: pyarrow (>=14)
43
46
  Requires-Dist: pydantic (>=2.10,<2.11)
44
47
  Requires-Dist: pydantic-settings (>=2.8,<2.9)