infrahub-server 1.5.0b2__py3-none-any.whl → 1.5.1__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 (75) hide show
  1. infrahub/api/dependencies.py +4 -13
  2. infrahub/api/transformation.py +22 -20
  3. infrahub/cli/db.py +87 -65
  4. infrahub/cli/upgrade.py +27 -7
  5. infrahub/core/diff/calculator.py +2 -2
  6. infrahub/core/diff/query/delete_query.py +9 -5
  7. infrahub/core/diff/query/merge.py +39 -23
  8. infrahub/core/graph/__init__.py +1 -1
  9. infrahub/core/migrations/graph/__init__.py +5 -3
  10. infrahub/core/migrations/graph/m037_index_attr_vals.py +11 -30
  11. infrahub/core/migrations/graph/m039_ipam_reconcile.py +9 -7
  12. infrahub/core/migrations/graph/m041_deleted_dup_edges.py +149 -0
  13. infrahub/core/migrations/graph/{m041_profile_attrs_in_db.py → m042_profile_attrs_in_db.py} +10 -8
  14. infrahub/core/migrations/graph/{m042_create_hfid_display_label_in_db.py → m043_create_hfid_display_label_in_db.py} +6 -6
  15. infrahub/core/migrations/graph/{m043_backfill_hfid_display_label_in_db.py → m044_backfill_hfid_display_label_in_db.py} +9 -11
  16. infrahub/core/migrations/shared.py +14 -0
  17. infrahub/core/models.py +2 -2
  18. infrahub/core/node/__init__.py +26 -1
  19. infrahub/core/query/diff.py +61 -16
  20. infrahub/core/query/ipam.py +15 -4
  21. infrahub/core/query/node.py +42 -40
  22. infrahub/core/relationship/model.py +10 -5
  23. infrahub/core/schema/definitions/core/check.py +1 -1
  24. infrahub/core/schema/definitions/core/transform.py +1 -1
  25. infrahub/core/schema/schema_branch_display.py +12 -0
  26. infrahub/core/schema/schema_branch_hfid.py +6 -0
  27. infrahub/core/validators/uniqueness/checker.py +2 -1
  28. infrahub/database/__init__.py +0 -13
  29. infrahub/graphql/analyzer.py +9 -0
  30. infrahub/graphql/mutations/branch.py +5 -0
  31. infrahub/graphql/mutations/proposed_change.py +6 -0
  32. infrahub/message_bus/types.py +1 -0
  33. infrahub/profiles/queries/get_profile_data.py +4 -5
  34. infrahub/proposed_change/tasks.py +43 -9
  35. infrahub_sdk/analyzer.py +1 -1
  36. infrahub_sdk/batch.py +2 -2
  37. infrahub_sdk/branch.py +14 -2
  38. infrahub_sdk/checks.py +1 -1
  39. infrahub_sdk/client.py +2 -4
  40. infrahub_sdk/ctl/branch.py +3 -0
  41. infrahub_sdk/ctl/cli_commands.py +2 -0
  42. infrahub_sdk/ctl/exceptions.py +1 -1
  43. infrahub_sdk/ctl/task.py +110 -0
  44. infrahub_sdk/exceptions.py +18 -18
  45. infrahub_sdk/graphql/query.py +2 -2
  46. infrahub_sdk/node/attribute.py +1 -1
  47. infrahub_sdk/node/property.py +1 -1
  48. infrahub_sdk/node/related_node.py +3 -3
  49. infrahub_sdk/node/relationship.py +4 -6
  50. infrahub_sdk/object_store.py +2 -2
  51. infrahub_sdk/operation.py +1 -1
  52. infrahub_sdk/protocols_generator/generator.py +1 -1
  53. infrahub_sdk/pytest_plugin/exceptions.py +9 -9
  54. infrahub_sdk/pytest_plugin/items/base.py +1 -1
  55. infrahub_sdk/pytest_plugin/items/check.py +1 -1
  56. infrahub_sdk/pytest_plugin/items/python_transform.py +1 -1
  57. infrahub_sdk/repository.py +1 -1
  58. infrahub_sdk/schema/__init__.py +1 -1
  59. infrahub_sdk/spec/object.py +7 -3
  60. infrahub_sdk/task/exceptions.py +4 -4
  61. infrahub_sdk/task/manager.py +2 -2
  62. infrahub_sdk/task/models.py +6 -4
  63. infrahub_sdk/timestamp.py +1 -1
  64. infrahub_sdk/transfer/exporter/json.py +1 -1
  65. infrahub_sdk/transfer/importer/json.py +1 -1
  66. infrahub_sdk/transforms.py +1 -1
  67. {infrahub_server-1.5.0b2.dist-info → infrahub_server-1.5.1.dist-info}/METADATA +2 -2
  68. {infrahub_server-1.5.0b2.dist-info → infrahub_server-1.5.1.dist-info}/RECORD +75 -73
  69. infrahub_testcontainers/container.py +31 -5
  70. infrahub_testcontainers/helpers.py +19 -4
  71. infrahub_testcontainers/models.py +8 -6
  72. infrahub_testcontainers/performance_test.py +6 -4
  73. {infrahub_server-1.5.0b2.dist-info → infrahub_server-1.5.1.dist-info}/LICENSE.txt +0 -0
  74. {infrahub_server-1.5.0b2.dist-info → infrahub_server-1.5.1.dist-info}/WHEEL +0 -0
  75. {infrahub_server-1.5.0b2.dist-info → infrahub_server-1.5.1.dist-info}/entry_points.txt +0 -0
@@ -16,7 +16,7 @@ class ObjectStoreBase:
16
16
 
17
17
 
18
18
  class ObjectStore(ObjectStoreBase):
19
- def __init__(self, client: InfrahubClient):
19
+ def __init__(self, client: InfrahubClient) -> None:
20
20
  self.client = client
21
21
 
22
22
  async def get(self, identifier: str, tracker: str | None = None) -> str:
@@ -64,7 +64,7 @@ class ObjectStore(ObjectStoreBase):
64
64
 
65
65
 
66
66
  class ObjectStoreSync(ObjectStoreBase):
67
- def __init__(self, client: InfrahubClientSync):
67
+ def __init__(self, client: InfrahubClientSync) -> None:
68
68
  self.client = client
69
69
 
70
70
  def get(self, identifier: str, tracker: str | None = None) -> str:
infrahub_sdk/operation.py CHANGED
@@ -19,7 +19,7 @@ class InfrahubOperation:
19
19
  convert_query_response: bool,
20
20
  branch: str,
21
21
  root_directory: str,
22
- ):
22
+ ) -> None:
23
23
  self.branch = branch
24
24
  self.convert_query_response = convert_query_response
25
25
  self.root_directory = root_directory or os.getcwd()
@@ -34,7 +34,7 @@ def move_to_end_of_list(lst: list, item: str) -> list:
34
34
 
35
35
 
36
36
  class CodeGenerator:
37
- def __init__(self, schema: dict[str, MainSchemaTypesAll]):
37
+ def __init__(self, schema: dict[str, MainSchemaTypesAll]) -> None:
38
38
  self.generics: dict[str, GenericSchemaAPI | GenericSchema] = {}
39
39
  self.nodes: dict[str, NodeSchemaAPI | NodeSchema] = {}
40
40
  self.profiles: dict[str, ProfileSchemaAPI] = {}
@@ -7,37 +7,37 @@ class Error(Exception):
7
7
 
8
8
 
9
9
  class InvalidResourceConfigError(Error):
10
- def __init__(self, resource_name: str):
10
+ def __init__(self, resource_name: str) -> None:
11
11
  super().__init__(f"Improperly configured resource with name '{resource_name}'.")
12
12
 
13
13
 
14
14
  class DirectoryNotFoundError(Error):
15
- def __init__(self, name: str, message: str = ""):
15
+ def __init__(self, name: str, message: str = "") -> None:
16
16
  self.message = message or f"Unable to find directory {name!r}."
17
17
  super().__init__(self.message)
18
18
 
19
19
 
20
20
  class FileNotValidError(Error):
21
- def __init__(self, name: str, message: str = ""):
21
+ def __init__(self, name: str, message: str = "") -> None:
22
22
  self.message = message or f"Unable to access file {name!r}."
23
23
  super().__init__(self.message)
24
24
 
25
25
 
26
26
  class OutputMatchError(Error):
27
- def __init__(self, name: str, message: str = "", differences: str = ""):
27
+ def __init__(self, name: str, message: str = "", differences: str = "") -> None:
28
28
  self.message = message or f"Rendered output does not match expected output for {name!r}."
29
29
  self.differences = differences
30
30
  super().__init__(self.message)
31
31
 
32
32
 
33
33
  class Jinja2TransformError(Error):
34
- def __init__(self, name: str, message: str = ""):
34
+ def __init__(self, name: str, message: str = "") -> None:
35
35
  self.message = message or f"Unexpected error happened while processing {name!r}."
36
36
  super().__init__(self.message)
37
37
 
38
38
 
39
39
  class Jinja2TransformUndefinedError(Error):
40
- def __init__(self, name: str, rtb: Traceback, errors: list[tuple[Frame, Syntax]], message: str = ""):
40
+ def __init__(self, name: str, rtb: Traceback, errors: list[tuple[Frame, Syntax]], message: str = "") -> None:
41
41
  self.rtb = rtb
42
42
  self.errors = errors
43
43
  self.message = message or f"Unable to render Jinja2 transform {name!r}."
@@ -45,18 +45,18 @@ class Jinja2TransformUndefinedError(Error):
45
45
 
46
46
 
47
47
  class CheckDefinitionError(Error):
48
- def __init__(self, name: str, message: str = ""):
48
+ def __init__(self, name: str, message: str = "") -> None:
49
49
  self.message = message or f"Check {name!r} is not properly defined."
50
50
  super().__init__(self.message)
51
51
 
52
52
 
53
53
  class CheckResultError(Error):
54
- def __init__(self, name: str, message: str = ""):
54
+ def __init__(self, name: str, message: str = "") -> None:
55
55
  self.message = message or f"Unexpected result for check {name!r}."
56
56
  super().__init__(self.message)
57
57
 
58
58
 
59
59
  class PythonTransformDefinitionError(Error):
60
- def __init__(self, name: str, message: str = ""):
60
+ def __init__(self, name: str, message: str = "") -> None:
61
61
  self.message = message or f"Python transform {name!r} is not properly defined."
62
62
  super().__init__(self.message)
@@ -25,7 +25,7 @@ class InfrahubItem(pytest.Item):
25
25
  resource_config: InfrahubRepositoryConfigElement,
26
26
  test: InfrahubTest,
27
27
  **kwargs: dict[str, Any],
28
- ):
28
+ ) -> None:
29
29
  super().__init__(*args, **kwargs) # type: ignore[arg-type]
30
30
  self.resource_name: str = resource_name
31
31
  self.resource_config: InfrahubRepositoryConfigElement = resource_config
@@ -27,7 +27,7 @@ class InfrahubCheckItem(InfrahubItem):
27
27
  resource_config: InfrahubRepositoryConfigElement,
28
28
  test: InfrahubTest,
29
29
  **kwargs: dict[str, Any],
30
- ):
30
+ ) -> None:
31
31
  super().__init__(*args, resource_name=resource_name, resource_config=resource_config, test=test, **kwargs)
32
32
 
33
33
  self.check_instance: InfrahubCheck
@@ -28,7 +28,7 @@ class InfrahubPythonTransformItem(InfrahubItem):
28
28
  resource_config: InfrahubRepositoryConfigElement,
29
29
  test: InfrahubTest,
30
30
  **kwargs: dict[str, Any],
31
- ):
31
+ ) -> None:
32
32
  super().__init__(*args, resource_name=resource_name, resource_config=resource_config, test=test, **kwargs)
33
33
 
34
34
  self.transform_instance: InfrahubTransform
@@ -7,7 +7,7 @@ from dulwich.repo import Repo
7
7
 
8
8
 
9
9
  class GitRepoManager:
10
- def __init__(self, root_directory: str, branch: str = "main"):
10
+ def __init__(self, root_directory: str, branch: str = "main") -> None:
11
11
  self.root_directory = root_directory
12
12
  self.branch = branch
13
13
  self.git: Repo = self.initialize_repo()
@@ -115,7 +115,7 @@ class InfrahubSchemaBase:
115
115
  client: InfrahubClient | InfrahubClientSync
116
116
  cache: dict[str, BranchSchema]
117
117
 
118
- def __init__(self, client: InfrahubClient | InfrahubClientSync):
118
+ def __init__(self, client: InfrahubClient | InfrahubClientSync) -> None:
119
119
  self.client = client
120
120
  self.cache = {}
121
121
 
@@ -209,6 +209,7 @@ class InfrahubObjectFileData(BaseModel):
209
209
  position=[idx + 1],
210
210
  branch=branch,
211
211
  default_schema_kind=self.kind,
212
+ parameters=self.parameters,
212
213
  )
213
214
 
214
215
  @classmethod
@@ -458,7 +459,6 @@ class InfrahubObjectFileData(BaseModel):
458
459
  data=value,
459
460
  branch=branch,
460
461
  default_schema_kind=default_schema_kind,
461
- parameters=parameters,
462
462
  )
463
463
  clean_data[key] = nodes[0]
464
464
 
@@ -470,7 +470,9 @@ class InfrahubObjectFileData(BaseModel):
470
470
  data=value,
471
471
  branch=branch,
472
472
  default_schema_kind=default_schema_kind,
473
- parameters=parameters,
473
+ parameters=InfrahubObjectParameters(**value.get("parameters"))
474
+ if "parameters" in value
475
+ else None,
474
476
  )
475
477
  clean_data[key] = nodes
476
478
 
@@ -509,7 +511,9 @@ class InfrahubObjectFileData(BaseModel):
509
511
  context=context,
510
512
  branch=branch,
511
513
  default_schema_kind=default_schema_kind,
512
- parameters=parameters,
514
+ parameters=InfrahubObjectParameters(**data[rel].get("parameters"))
515
+ if "parameters" in data[rel]
516
+ else None,
513
517
  )
514
518
 
515
519
  return node
@@ -2,24 +2,24 @@ from __future__ import annotations
2
2
 
3
3
 
4
4
  class TaskError(Exception):
5
- def __init__(self, message: str | None = None):
5
+ def __init__(self, message: str | None = None) -> None:
6
6
  self.message = message
7
7
  super().__init__(self.message)
8
8
 
9
9
 
10
10
  class TaskNotFoundError(TaskError):
11
- def __init__(self, id: str):
11
+ def __init__(self, id: str) -> None:
12
12
  self.message = f"Task with id {id} not found"
13
13
  super().__init__(self.message)
14
14
 
15
15
 
16
16
  class TooManyTasksError(TaskError):
17
- def __init__(self, expected_id: str, received_ids: list[str]):
17
+ def __init__(self, expected_id: str, received_ids: list[str]) -> None:
18
18
  self.message = f"Expected 1 task with id {expected_id}, but got {len(received_ids)}"
19
19
  super().__init__(self.message)
20
20
 
21
21
 
22
22
  class TaskNotCompletedError(TaskError):
23
- def __init__(self, id: str, message: str | None = None):
23
+ def __init__(self, id: str, message: str | None = None) -> None:
24
24
  self.message = message or f"Task with id {id} is not completed"
25
25
  super().__init__(self.message)
@@ -86,7 +86,7 @@ class InfraHubTaskManagerBase:
86
86
  class InfrahubTaskManager(InfraHubTaskManagerBase):
87
87
  client: InfrahubClient
88
88
 
89
- def __init__(self, client: InfrahubClient):
89
+ def __init__(self, client: InfrahubClient) -> None:
90
90
  self.client = client
91
91
 
92
92
  async def count(self, filters: TaskFilter | None = None) -> int:
@@ -321,7 +321,7 @@ class InfrahubTaskManager(InfraHubTaskManagerBase):
321
321
  class InfrahubTaskManagerSync(InfraHubTaskManagerBase):
322
322
  client: InfrahubClientSync
323
323
 
324
- def __init__(self, client: InfrahubClientSync):
324
+ def __init__(self, client: InfrahubClientSync) -> None:
325
325
  self.client = client
326
326
 
327
327
  def count(self, filters: TaskFilter | None = None) -> int:
@@ -49,12 +49,14 @@ class Task(BaseModel):
49
49
  related_nodes: list[TaskRelatedNode] = []
50
50
  logs: list[TaskLog] = []
51
51
 
52
- if data.get("related_nodes"):
53
- related_nodes = [TaskRelatedNode(**item) for item in data["related_nodes"]]
52
+ if "related_nodes" in data:
53
+ if data.get("related_nodes"):
54
+ related_nodes = [TaskRelatedNode(**item) for item in data["related_nodes"]]
54
55
  del data["related_nodes"]
55
56
 
56
- if data.get("logs"):
57
- logs = [TaskLog(**item["node"]) for item in data["logs"]["edges"]]
57
+ if "logs" in data:
58
+ if data.get("logs"):
59
+ logs = [TaskLog(**item["node"]) for item in data["logs"]["edges"]]
58
60
  del data["logs"]
59
61
 
60
62
  return cls(**data, related_nodes=related_nodes, logs=logs)
infrahub_sdk/timestamp.py CHANGED
@@ -29,7 +29,7 @@ REGEX_MAPPING = {
29
29
  class Timestamp:
30
30
  _obj: ZonedDateTime
31
31
 
32
- def __init__(self, value: str | ZonedDateTime | Timestamp | None = None):
32
+ def __init__(self, value: str | ZonedDateTime | Timestamp | None = None) -> None:
33
33
  if value and isinstance(value, ZonedDateTime):
34
34
  self._obj = value
35
35
  elif value and isinstance(value, self.__class__):
@@ -22,7 +22,7 @@ if TYPE_CHECKING:
22
22
 
23
23
 
24
24
  class LineDelimitedJSONExporter(ExporterInterface):
25
- def __init__(self, client: InfrahubClient, console: Console | None = None):
25
+ def __init__(self, client: InfrahubClient, console: Console | None = None) -> None:
26
26
  self.client = client
27
27
  self.console = console
28
28
 
@@ -31,7 +31,7 @@ class LineDelimitedJSONImporter(ImporterInterface):
31
31
  topological_sorter: InfrahubSchemaTopologicalSorter,
32
32
  continue_on_error: bool = False,
33
33
  console: Console | None = None,
34
- ):
34
+ ) -> None:
35
35
  self.client = client
36
36
  self.topological_sorter = topological_sorter
37
37
  self.continue_on_error = continue_on_error
@@ -27,7 +27,7 @@ class InfrahubTransform(InfrahubOperation):
27
27
  branch: str = "",
28
28
  root_directory: str = "",
29
29
  server_url: str = "",
30
- ):
30
+ ) -> None:
31
31
  super().__init__(
32
32
  client=client,
33
33
  infrahub_node=infrahub_node,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: infrahub-server
3
- Version: 1.5.0b2
3
+ Version: 1.5.1
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
@@ -24,7 +24,7 @@ Requires-Dist: copier (>=9.8.0,<10.0.0)
24
24
  Requires-Dist: dulwich (>=0.22.7,<0.23.0)
25
25
  Requires-Dist: email-validator (>=2.1,<2.2)
26
26
  Requires-Dist: fast-depends (>=2.4.12,<3.0.0)
27
- Requires-Dist: fastapi (==0.116.1)
27
+ Requires-Dist: fastapi (==0.121.1)
28
28
  Requires-Dist: fastapi-storages (>=0.3,<0.4)
29
29
  Requires-Dist: gitpython (>=3,<4)
30
30
  Requires-Dist: graphene (>=3.4,<3.5)