infrahub-server 1.3.7__py3-none-any.whl → 1.3.8__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.
- infrahub/core/diff/model/path.py +0 -39
- infrahub/core/schema/node_schema.py +0 -5
- infrahub/core/schema/schema_branch.py +2 -2
- infrahub/graphql/app.py +2 -1
- infrahub/graphql/queries/diff/tree.py +53 -2
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.3.8.dist-info}/METADATA +1 -1
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.3.8.dist-info}/RECORD +10 -10
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.3.8.dist-info}/LICENSE.txt +0 -0
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.3.8.dist-info}/WHEEL +0 -0
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.3.8.dist-info}/entry_points.txt +0 -0
infrahub/core/diff/model/path.py
CHANGED
|
@@ -22,8 +22,6 @@ if TYPE_CHECKING:
|
|
|
22
22
|
from neo4j.graph import Relationship as Neo4jRelationship
|
|
23
23
|
from whenever import TimeDelta
|
|
24
24
|
|
|
25
|
-
from infrahub.graphql.initialization import GraphqlContext
|
|
26
|
-
|
|
27
25
|
|
|
28
26
|
@dataclass
|
|
29
27
|
class TimeRange:
|
|
@@ -314,12 +312,6 @@ class EnrichedDiffRelationship(BaseSummary):
|
|
|
314
312
|
)
|
|
315
313
|
|
|
316
314
|
|
|
317
|
-
@dataclass
|
|
318
|
-
class ParentNodeInfo:
|
|
319
|
-
node: EnrichedDiffNode
|
|
320
|
-
relationship_name: str = "undefined"
|
|
321
|
-
|
|
322
|
-
|
|
323
315
|
@dataclass
|
|
324
316
|
class EnrichedDiffNode(BaseSummary):
|
|
325
317
|
identifier: NodeIdentifier
|
|
@@ -364,37 +356,6 @@ class EnrichedDiffNode(BaseSummary):
|
|
|
364
356
|
rel.clear_conflicts()
|
|
365
357
|
self.conflict = None
|
|
366
358
|
|
|
367
|
-
def get_parent_info(self, graphql_context: GraphqlContext | None = None) -> ParentNodeInfo | None:
|
|
368
|
-
for r in self.relationships:
|
|
369
|
-
for n in r.nodes:
|
|
370
|
-
relationship_name: str = "undefined"
|
|
371
|
-
|
|
372
|
-
if not graphql_context:
|
|
373
|
-
return ParentNodeInfo(node=n, relationship_name=relationship_name)
|
|
374
|
-
|
|
375
|
-
node_schema = graphql_context.db.schema.get(name=self.kind)
|
|
376
|
-
rel_schema = node_schema.get_relationship(name=r.name)
|
|
377
|
-
|
|
378
|
-
parent_schema = graphql_context.db.schema.get(name=n.kind)
|
|
379
|
-
rels_parent = parent_schema.get_relationships_by_identifier(id=rel_schema.get_identifier())
|
|
380
|
-
|
|
381
|
-
if rels_parent and len(rels_parent) == 1:
|
|
382
|
-
relationship_name = rels_parent[0].name
|
|
383
|
-
elif rels_parent and len(rels_parent) > 1:
|
|
384
|
-
for rel_parent in rels_parent:
|
|
385
|
-
if (
|
|
386
|
-
rel_schema.direction == RelationshipDirection.INBOUND
|
|
387
|
-
and rel_parent.direction == RelationshipDirection.OUTBOUND
|
|
388
|
-
) or (
|
|
389
|
-
rel_schema.direction == RelationshipDirection.OUTBOUND
|
|
390
|
-
and rel_parent.direction == RelationshipDirection.INBOUND
|
|
391
|
-
):
|
|
392
|
-
relationship_name = rel_parent.name
|
|
393
|
-
break
|
|
394
|
-
|
|
395
|
-
return ParentNodeInfo(node=n, relationship_name=relationship_name)
|
|
396
|
-
return None
|
|
397
|
-
|
|
398
359
|
def get_all_child_nodes(self) -> set[EnrichedDiffNode]:
|
|
399
360
|
all_children = set()
|
|
400
361
|
for r in self.relationships:
|
|
@@ -53,11 +53,6 @@ class NodeSchema(GeneratedNodeSchema):
|
|
|
53
53
|
f"{self.kind}.{attribute.name} inherited from {interface.namespace}{interface.name} must be the same kind "
|
|
54
54
|
f'["{interface_attr.kind}", "{attribute.kind}"]'
|
|
55
55
|
)
|
|
56
|
-
if attribute.optional != interface_attr.optional:
|
|
57
|
-
raise ValueError(
|
|
58
|
-
f"{self.kind}.{attribute.name} inherited from {interface.namespace}{interface.name} must have the same value for property "
|
|
59
|
-
f'"optional" ["{interface_attr.optional}", "{attribute.optional}"]'
|
|
60
|
-
)
|
|
61
56
|
|
|
62
57
|
for relationship in self.relationships:
|
|
63
58
|
if (
|
|
@@ -226,8 +226,8 @@ class SchemaBranch:
|
|
|
226
226
|
def update(self, schema: SchemaBranch) -> None:
|
|
227
227
|
"""Update another SchemaBranch into this one."""
|
|
228
228
|
|
|
229
|
-
local_kinds =
|
|
230
|
-
other_kinds =
|
|
229
|
+
local_kinds = self.all_names
|
|
230
|
+
other_kinds = schema.all_names
|
|
231
231
|
|
|
232
232
|
in_both, _, other_only = compare_lists(list1=local_kinds, list2=other_kinds)
|
|
233
233
|
|
infrahub/graphql/app.py
CHANGED
|
@@ -231,6 +231,7 @@ class InfrahubGraphQLApp:
|
|
|
231
231
|
operation_name=operation_name,
|
|
232
232
|
branch=branch,
|
|
233
233
|
)
|
|
234
|
+
impacted_models = analyzed_query.query_report.impacted_models
|
|
234
235
|
|
|
235
236
|
await self._evaluate_permissions(
|
|
236
237
|
db=db,
|
|
@@ -282,7 +283,7 @@ class InfrahubGraphQLApp:
|
|
|
282
283
|
GRAPHQL_QUERY_HEIGHT_METRICS.labels(**labels).observe(await analyzed_query.calculate_height())
|
|
283
284
|
# GRAPHQL_QUERY_VARS_METRICS.labels(**labels).observe(len(analyzed_query.variables))
|
|
284
285
|
GRAPHQL_TOP_LEVEL_QUERIES_METRICS.labels(**labels).observe(analyzed_query.nbr_queries)
|
|
285
|
-
GRAPHQL_QUERY_OBJECTS_METRICS.labels(**labels).observe(len(
|
|
286
|
+
GRAPHQL_QUERY_OBJECTS_METRICS.labels(**labels).observe(len(impacted_models))
|
|
286
287
|
|
|
287
288
|
_, errors = analyzed_query.is_valid
|
|
288
289
|
if errors:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from dataclasses import dataclass
|
|
3
4
|
from typing import TYPE_CHECKING, Any
|
|
4
5
|
|
|
5
6
|
from graphene import Argument, Boolean, DateTime, Field, InputObjectType, Int, List, NonNull, ObjectType, String
|
|
@@ -7,7 +8,7 @@ from graphene import Enum as GrapheneEnum
|
|
|
7
8
|
from infrahub_sdk.utils import extract_fields
|
|
8
9
|
|
|
9
10
|
from infrahub.core import registry
|
|
10
|
-
from infrahub.core.constants import DiffAction, RelationshipCardinality
|
|
11
|
+
from infrahub.core.constants import DiffAction, RelationshipCardinality, RelationshipDirection
|
|
11
12
|
from infrahub.core.constants.database import DatabaseEdgeType
|
|
12
13
|
from infrahub.core.diff.model.path import NameTrackingId
|
|
13
14
|
from infrahub.core.diff.query.filters import EnrichedDiffQueryFilters
|
|
@@ -38,6 +39,12 @@ GrapheneDiffActionEnum = GrapheneEnum.from_enum(DiffAction)
|
|
|
38
39
|
GrapheneCardinalityEnum = GrapheneEnum.from_enum(RelationshipCardinality)
|
|
39
40
|
|
|
40
41
|
|
|
42
|
+
@dataclass
|
|
43
|
+
class ParentNodeInfo:
|
|
44
|
+
node: EnrichedDiffNode
|
|
45
|
+
relationship_name: str
|
|
46
|
+
|
|
47
|
+
|
|
41
48
|
class ConflictDetails(ObjectType):
|
|
42
49
|
uuid = String(required=True)
|
|
43
50
|
base_branch_action = Field(GrapheneDiffActionEnum, required=True)
|
|
@@ -145,9 +152,16 @@ class DiffTreeSummary(DiffSummaryCounts):
|
|
|
145
152
|
|
|
146
153
|
|
|
147
154
|
class DiffTreeResolver:
|
|
155
|
+
def __init__(self) -> None:
|
|
156
|
+
self.source_branch_name: str | None = None
|
|
157
|
+
|
|
158
|
+
def initialize(self, enriched_diff_root: EnrichedDiffRoot) -> None:
|
|
159
|
+
self.source_branch_name = enriched_diff_root.diff_branch_name
|
|
160
|
+
|
|
148
161
|
async def to_diff_tree(
|
|
149
162
|
self, enriched_diff_root: EnrichedDiffRoot, graphql_context: GraphqlContext | None = None
|
|
150
163
|
) -> DiffTree:
|
|
164
|
+
self.initialize(enriched_diff_root=enriched_diff_root)
|
|
151
165
|
all_nodes = list(enriched_diff_root.nodes)
|
|
152
166
|
tree_nodes = [self.to_diff_node(enriched_node=e_node, graphql_context=graphql_context) for e_node in all_nodes]
|
|
153
167
|
name = None
|
|
@@ -166,6 +180,43 @@ class DiffTreeResolver:
|
|
|
166
180
|
num_conflicts=enriched_diff_root.num_conflicts,
|
|
167
181
|
)
|
|
168
182
|
|
|
183
|
+
def _get_parent_info(
|
|
184
|
+
self, diff_node: EnrichedDiffNode, graphql_context: GraphqlContext | None = None
|
|
185
|
+
) -> ParentNodeInfo | None:
|
|
186
|
+
for r in diff_node.relationships:
|
|
187
|
+
for n in r.nodes:
|
|
188
|
+
relationship_name: str = "undefined"
|
|
189
|
+
|
|
190
|
+
if not graphql_context or not self.source_branch_name:
|
|
191
|
+
return ParentNodeInfo(node=n, relationship_name=relationship_name)
|
|
192
|
+
|
|
193
|
+
node_schema = graphql_context.db.schema.get(
|
|
194
|
+
name=diff_node.kind, branch=self.source_branch_name, duplicate=False
|
|
195
|
+
)
|
|
196
|
+
rel_schema = node_schema.get_relationship(name=r.name)
|
|
197
|
+
|
|
198
|
+
parent_schema = graphql_context.db.schema.get(
|
|
199
|
+
name=n.kind, branch=self.source_branch_name, duplicate=False
|
|
200
|
+
)
|
|
201
|
+
rels_parent = parent_schema.get_relationships_by_identifier(id=rel_schema.get_identifier())
|
|
202
|
+
|
|
203
|
+
if rels_parent and len(rels_parent) == 1:
|
|
204
|
+
relationship_name = rels_parent[0].name
|
|
205
|
+
elif rels_parent and len(rels_parent) > 1:
|
|
206
|
+
for rel_parent in rels_parent:
|
|
207
|
+
if (
|
|
208
|
+
rel_schema.direction == RelationshipDirection.INBOUND
|
|
209
|
+
and rel_parent.direction == RelationshipDirection.OUTBOUND
|
|
210
|
+
) or (
|
|
211
|
+
rel_schema.direction == RelationshipDirection.OUTBOUND
|
|
212
|
+
and rel_parent.direction == RelationshipDirection.INBOUND
|
|
213
|
+
):
|
|
214
|
+
relationship_name = rel_parent.name
|
|
215
|
+
break
|
|
216
|
+
|
|
217
|
+
return ParentNodeInfo(node=n, relationship_name=relationship_name)
|
|
218
|
+
return None
|
|
219
|
+
|
|
169
220
|
def to_diff_node(self, enriched_node: EnrichedDiffNode, graphql_context: GraphqlContext | None = None) -> DiffNode:
|
|
170
221
|
diff_attributes = [
|
|
171
222
|
self.to_diff_attribute(enriched_attribute=e_attr, graphql_context=graphql_context)
|
|
@@ -181,7 +232,7 @@ class DiffTreeResolver:
|
|
|
181
232
|
conflict = self.to_diff_conflict(enriched_conflict=enriched_node.conflict, graphql_context=graphql_context)
|
|
182
233
|
|
|
183
234
|
parent = None
|
|
184
|
-
if parent_info :=
|
|
235
|
+
if parent_info := self._get_parent_info(diff_node=enriched_node, graphql_context=graphql_context):
|
|
185
236
|
parent = DiffNodeParent(
|
|
186
237
|
uuid=parent_info.node.uuid,
|
|
187
238
|
kind=parent_info.node.kind,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: infrahub-server
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.8
|
|
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
|
|
@@ -108,7 +108,7 @@ infrahub/core/diff/merger/serializer.py,sha256=N5BJ5I2NkB5RtEMuhDfScM7v19PGCbuXC
|
|
|
108
108
|
infrahub/core/diff/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
109
109
|
infrahub/core/diff/model/diff.py,sha256=eS2TjZf9aWTZDvQ479t6C6iXXPtmBqulxA2jWxnEDuU,9501
|
|
110
110
|
infrahub/core/diff/model/field_specifiers_map.py,sha256=59zsMRuYyb9OJEpH9BZQ9kf2DUiDOM3VtuDGvSK6dJQ,2632
|
|
111
|
-
infrahub/core/diff/model/path.py,sha256=
|
|
111
|
+
infrahub/core/diff/model/path.py,sha256=lcKTS7hKvu3Rul0k_vxJTrz7G83HhPPedXlthKkr9ag,28844
|
|
112
112
|
infrahub/core/diff/models.py,sha256=wmOzW4xQ5YreDCr_i56YMFtxbM4-LRgZort49fGJ0BQ,441
|
|
113
113
|
infrahub/core/diff/parent_node_adder.py,sha256=AFq2KJHGgUVem4WCg-9Qi9h6TTwt-JID1uGYGBrIZxQ,2840
|
|
114
114
|
infrahub/core/diff/payload_builder.py,sha256=5R_QuPM5P_uQONmTDbtpIjhshs_OJCcXLnVYjWw-78Q,2094
|
|
@@ -294,10 +294,10 @@ infrahub/core/schema/generated/node_schema.py,sha256=PMgbQX1PC5ixQsjOFw_bcEfa4tx
|
|
|
294
294
|
infrahub/core/schema/generated/relationship_schema.py,sha256=F198_LNmQRV0xSEBPRA3vBAioEItpYZVNApOmdb8_E4,5851
|
|
295
295
|
infrahub/core/schema/generic_schema.py,sha256=4qXhCm4G_MgDqxZOut_AJwatU4onXBECKeS1UZcusr8,1340
|
|
296
296
|
infrahub/core/schema/manager.py,sha256=Vz6EJo8pDq9u5apRU7wgFMtcsCHDEt9BHwS0VRlctAc,32776
|
|
297
|
-
infrahub/core/schema/node_schema.py,sha256=
|
|
297
|
+
infrahub/core/schema/node_schema.py,sha256=cc2LQ36Eq_phjK2plfWx4GWLSDznyLcUXMCQmbPIo9Q,5784
|
|
298
298
|
infrahub/core/schema/profile_schema.py,sha256=cOPSOt5KLgQ0nbqrAN_o33hY_pUtrKmiwSbY_YpVolI,1092
|
|
299
299
|
infrahub/core/schema/relationship_schema.py,sha256=R-1iC1d70bBW0vWhgJhDB0_J3tRpOqcJmmLzh39NuYs,8501
|
|
300
|
-
infrahub/core/schema/schema_branch.py,sha256=
|
|
300
|
+
infrahub/core/schema/schema_branch.py,sha256=IGT_pg3KUQcXaKf6fIvrWKzFy4e60u06aDqG0o9001Q,106060
|
|
301
301
|
infrahub/core/schema/schema_branch_computed.py,sha256=14UUsQJDLMHkYhg7QMqeLiTF3PO8c8rGa90ul3F2ZZo,10629
|
|
302
302
|
infrahub/core/schema/template_schema.py,sha256=O-PBS9IRM4JX6PxeoyZKwqZ0u0SdQ2zxWMc01PJ2_EA,1084
|
|
303
303
|
infrahub/core/task/__init__.py,sha256=Ied1NvKGJUDmff27z_-yWW8ArenHxGvSvQTaQyx1iHs,128
|
|
@@ -445,7 +445,7 @@ infrahub/graphql/analyzer.py,sha256=TAWo4AWMr33MFjK3YcYBxXSjdwRHxU2HzpIuY9tTHqU,
|
|
|
445
445
|
infrahub/graphql/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
446
446
|
infrahub/graphql/api/dependencies.py,sha256=-NMUA_N4tWcVpS6ksCebAyza-JTmHqyYY_QZizgBR1c,1690
|
|
447
447
|
infrahub/graphql/api/endpoints.py,sha256=wH9eO3CFT-eoSe1Y32BhU9mIf6smEnPeP3tAxZkdt4g,1510
|
|
448
|
-
infrahub/graphql/app.py,sha256=
|
|
448
|
+
infrahub/graphql/app.py,sha256=ZoxFravB96Ax3DrQZM0MaK-OsWkFk6Rb-bao7IEE6TI,21177
|
|
449
449
|
infrahub/graphql/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
450
450
|
infrahub/graphql/auth/query_permission_checker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
451
451
|
infrahub/graphql/auth/query_permission_checker/anonymous_checker.py,sha256=ibsmGyOelLJbN2Kfkmffv-5D79h7tRc1Fez5tauFY8w,1377
|
|
@@ -502,7 +502,7 @@ infrahub/graphql/queries/account.py,sha256=VB3HtLXf8s7VJxoA4G0ISBvn9hkQ9oTavKfRw
|
|
|
502
502
|
infrahub/graphql/queries/branch.py,sha256=hEZF8xJHyXUOQOkWrfjbfrVhIrK70vKMeBGaLLnHQGY,792
|
|
503
503
|
infrahub/graphql/queries/convert_object_type_mapping.py,sha256=zLav6Eod0OqLgj4PY7q8fCUE-idYYHFQXf_G-siAgyI,1169
|
|
504
504
|
infrahub/graphql/queries/diff/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
505
|
-
infrahub/graphql/queries/diff/tree.py,sha256=
|
|
505
|
+
infrahub/graphql/queries/diff/tree.py,sha256=DcO8cRd-V3Z66tYYgiNa0CqNW8Z8JwFVJk-0DP3pME4,25278
|
|
506
506
|
infrahub/graphql/queries/event.py,sha256=9kHi37WmM4bwGgnIPaPLVOaXp124tn10v60kNx5C7aU,4204
|
|
507
507
|
infrahub/graphql/queries/internal.py,sha256=pcGLpLrY1fC_HxHNs8NAFjr5FTFzcgRlS1F7b65gqfE,647
|
|
508
508
|
infrahub/graphql/queries/ipam.py,sha256=peN--58IhLgS06O44AEthefEkaVDc7f38Sib3JyGKu4,4106
|
|
@@ -810,8 +810,8 @@ infrahub_testcontainers/models.py,sha256=ASYyvl7d_WQz_i7y8-3iab9hwwmCl3OCJavqVbe
|
|
|
810
810
|
infrahub_testcontainers/performance_test.py,sha256=hvwiy6tc_lWniYqGkqfOXVGAmA_IV15VOZqbiD9ezno,6149
|
|
811
811
|
infrahub_testcontainers/plugin.py,sha256=I3RuZQ0dARyKHuqCf0y1Yj731P2Mwf3BJUehRJKeWrs,5645
|
|
812
812
|
infrahub_testcontainers/prometheus.yml,sha256=610xQEyj3xuVJMzPkC4m1fRnCrjGpiRBrXA2ytCLa54,599
|
|
813
|
-
infrahub_server-1.3.
|
|
814
|
-
infrahub_server-1.3.
|
|
815
|
-
infrahub_server-1.3.
|
|
816
|
-
infrahub_server-1.3.
|
|
817
|
-
infrahub_server-1.3.
|
|
813
|
+
infrahub_server-1.3.8.dist-info/LICENSE.txt,sha256=7GQO7kxVoQYnZtFrjZBKLRXbrGwwwimHPPOJtqXsozQ,11340
|
|
814
|
+
infrahub_server-1.3.8.dist-info/METADATA,sha256=AM93SvBG4Wl4D53wWQ9ktQPK0ZqIa87Osu0e0EWFOBg,8189
|
|
815
|
+
infrahub_server-1.3.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
816
|
+
infrahub_server-1.3.8.dist-info/entry_points.txt,sha256=UXIeFWDsrV-4IllNvUEd6KieYGzQfn9paga2YyABOQI,393
|
|
817
|
+
infrahub_server-1.3.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|