infrahub-server 1.2.1__py3-none-any.whl → 1.2.2__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/computed_attribute/tasks.py +63 -59
- infrahub/core/query/node.py +16 -5
- infrahub/exceptions.py +30 -2
- infrahub/git/base.py +80 -29
- infrahub/git/integrator.py +0 -24
- infrahub/trigger/tasks.py +19 -18
- infrahub/workflows/utils.py +5 -5
- infrahub_sdk/node.py +3 -1
- {infrahub_server-1.2.1.dist-info → infrahub_server-1.2.2.dist-info}/METADATA +1 -1
- {infrahub_server-1.2.1.dist-info → infrahub_server-1.2.2.dist-info}/RECORD +13 -13
- {infrahub_server-1.2.1.dist-info → infrahub_server-1.2.2.dist-info}/LICENSE.txt +0 -0
- {infrahub_server-1.2.1.dist-info → infrahub_server-1.2.2.dist-info}/WHEEL +0 -0
- {infrahub_server-1.2.1.dist-info → infrahub_server-1.2.2.dist-info}/entry_points.txt +0 -0
|
@@ -311,35 +311,36 @@ async def trigger_update_jinja2_computed_attributes(
|
|
|
311
311
|
async def computed_attribute_setup_jinja2(
|
|
312
312
|
service: InfrahubServices, context: InfrahubContext, branch_name: str | None = None, event_name: str | None = None
|
|
313
313
|
) -> None:
|
|
314
|
-
|
|
314
|
+
async with service.database.start_session() as db:
|
|
315
|
+
log = get_run_logger()
|
|
315
316
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
triggers = await gather_trigger_computed_attribute_jinja2()
|
|
321
|
-
|
|
322
|
-
for trigger in triggers:
|
|
323
|
-
if event_name != BranchDeletedEvent.event_name and trigger.branch == branch_name:
|
|
324
|
-
await service.workflow.submit_workflow(
|
|
325
|
-
workflow=TRIGGER_UPDATE_JINJA_COMPUTED_ATTRIBUTES,
|
|
326
|
-
context=context,
|
|
327
|
-
parameters={
|
|
328
|
-
"branch_name": trigger.branch,
|
|
329
|
-
"computed_attribute_name": trigger.computed_attribute.attribute.name,
|
|
330
|
-
"computed_attribute_kind": trigger.computed_attribute.kind,
|
|
331
|
-
},
|
|
332
|
-
)
|
|
317
|
+
if branch_name:
|
|
318
|
+
await add_tags(branches=[branch_name])
|
|
319
|
+
await wait_for_schema_to_converge(branch_name=branch_name, component=service.component, db=db, log=log)
|
|
333
320
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
321
|
+
triggers = await gather_trigger_computed_attribute_jinja2()
|
|
322
|
+
|
|
323
|
+
for trigger in triggers:
|
|
324
|
+
if event_name != BranchDeletedEvent.event_name and trigger.branch == branch_name:
|
|
325
|
+
await service.workflow.submit_workflow(
|
|
326
|
+
workflow=TRIGGER_UPDATE_JINJA_COMPUTED_ATTRIBUTES,
|
|
327
|
+
context=context,
|
|
328
|
+
parameters={
|
|
329
|
+
"branch_name": trigger.branch,
|
|
330
|
+
"computed_attribute_name": trigger.computed_attribute.attribute.name,
|
|
331
|
+
"computed_attribute_kind": trigger.computed_attribute.kind,
|
|
332
|
+
},
|
|
333
|
+
)
|
|
341
334
|
|
|
342
|
-
|
|
335
|
+
# Configure all ComputedAttrJinja2Trigger in Prefect
|
|
336
|
+
async with get_client(sync_client=False) as prefect_client:
|
|
337
|
+
await setup_triggers(
|
|
338
|
+
client=prefect_client,
|
|
339
|
+
triggers=triggers,
|
|
340
|
+
trigger_type=TriggerType.COMPUTED_ATTR_JINJA2,
|
|
341
|
+
) # type: ignore[misc]
|
|
342
|
+
|
|
343
|
+
log.info(f"{len(triggers)} Computed Attribute for Jinja2 automation configuration completed")
|
|
343
344
|
|
|
344
345
|
|
|
345
346
|
@flow(
|
|
@@ -353,46 +354,49 @@ async def computed_attribute_setup_python(
|
|
|
353
354
|
event_name: str | None = None,
|
|
354
355
|
commit: str | None = None, # noqa: ARG001
|
|
355
356
|
) -> None:
|
|
356
|
-
|
|
357
|
+
async with service.database.start_session() as db:
|
|
358
|
+
log = get_run_logger()
|
|
359
|
+
|
|
360
|
+
branch_name = branch_name or registry.default_branch
|
|
357
361
|
|
|
358
|
-
|
|
362
|
+
if branch_name:
|
|
363
|
+
await add_tags(branches=[branch_name])
|
|
364
|
+
await wait_for_schema_to_converge(branch_name=branch_name, component=service.component, db=db, log=log)
|
|
359
365
|
|
|
360
|
-
|
|
361
|
-
await add_tags(branches=[branch_name])
|
|
362
|
-
await wait_for_schema_to_converge(branch_name=branch_name, service=service, log=log)
|
|
366
|
+
triggers_python, triggers_python_query = await gather_trigger_computed_attribute_python(db=db)
|
|
363
367
|
|
|
364
|
-
|
|
368
|
+
for trigger in triggers_python:
|
|
369
|
+
if event_name != BranchDeletedEvent.event_name and trigger.branch == branch_name:
|
|
370
|
+
log.info(
|
|
371
|
+
f"Triggering update for {trigger.computed_attribute.computed_attribute.attribute.name} on {branch_name}"
|
|
372
|
+
)
|
|
373
|
+
await service.workflow.submit_workflow(
|
|
374
|
+
workflow=TRIGGER_UPDATE_PYTHON_COMPUTED_ATTRIBUTES,
|
|
375
|
+
context=context,
|
|
376
|
+
parameters={
|
|
377
|
+
"branch_name": branch_name,
|
|
378
|
+
"computed_attribute_name": trigger.computed_attribute.computed_attribute.attribute.name,
|
|
379
|
+
"computed_attribute_kind": trigger.computed_attribute.computed_attribute.kind,
|
|
380
|
+
},
|
|
381
|
+
)
|
|
365
382
|
|
|
366
|
-
|
|
367
|
-
|
|
383
|
+
async with get_client(sync_client=False) as prefect_client:
|
|
384
|
+
await setup_triggers(
|
|
385
|
+
client=prefect_client,
|
|
386
|
+
triggers=triggers_python,
|
|
387
|
+
trigger_type=TriggerType.COMPUTED_ATTR_PYTHON,
|
|
388
|
+
) # type: ignore[misc]
|
|
389
|
+
log.info(f"{len(triggers_python)} Computed Attribute for Python automation configuration completed")
|
|
390
|
+
|
|
391
|
+
await setup_triggers(
|
|
392
|
+
client=prefect_client,
|
|
393
|
+
triggers=triggers_python_query,
|
|
394
|
+
trigger_type=TriggerType.COMPUTED_ATTR_PYTHON_QUERY,
|
|
395
|
+
) # type: ignore[misc]
|
|
368
396
|
log.info(
|
|
369
|
-
f"
|
|
370
|
-
)
|
|
371
|
-
await service.workflow.submit_workflow(
|
|
372
|
-
workflow=TRIGGER_UPDATE_PYTHON_COMPUTED_ATTRIBUTES,
|
|
373
|
-
context=context,
|
|
374
|
-
parameters={
|
|
375
|
-
"branch_name": branch_name,
|
|
376
|
-
"computed_attribute_name": trigger.computed_attribute.computed_attribute.attribute.name,
|
|
377
|
-
"computed_attribute_kind": trigger.computed_attribute.computed_attribute.kind,
|
|
378
|
-
},
|
|
397
|
+
f"{len(triggers_python_query)} Computed Attribute for Python Query automation configuration completed"
|
|
379
398
|
)
|
|
380
399
|
|
|
381
|
-
async with get_client(sync_client=False) as prefect_client:
|
|
382
|
-
await setup_triggers(
|
|
383
|
-
client=prefect_client,
|
|
384
|
-
triggers=triggers_python,
|
|
385
|
-
trigger_type=TriggerType.COMPUTED_ATTR_PYTHON,
|
|
386
|
-
) # type: ignore[misc]
|
|
387
|
-
log.info(f"{len(triggers_python)} Computed Attribute for Python automation configuration completed")
|
|
388
|
-
|
|
389
|
-
await setup_triggers(
|
|
390
|
-
client=prefect_client,
|
|
391
|
-
triggers=triggers_python_query,
|
|
392
|
-
trigger_type=TriggerType.COMPUTED_ATTR_PYTHON_QUERY,
|
|
393
|
-
) # type: ignore[misc]
|
|
394
|
-
log.info(f"{len(triggers_python_query)} Computed Attribute for Python Query automation configuration completed")
|
|
395
|
-
|
|
396
400
|
|
|
397
401
|
@flow(
|
|
398
402
|
name="query-computed-attribute-transform-targets",
|
infrahub/core/query/node.py
CHANGED
|
@@ -8,6 +8,7 @@ from enum import Enum
|
|
|
8
8
|
from typing import TYPE_CHECKING, Any, AsyncIterator, Generator
|
|
9
9
|
|
|
10
10
|
from infrahub import config
|
|
11
|
+
from infrahub.core import registry
|
|
11
12
|
from infrahub.core.constants import (
|
|
12
13
|
AttributeDBNodeType,
|
|
13
14
|
RelationshipDirection,
|
|
@@ -713,14 +714,24 @@ class NodeGetKindQuery(Query):
|
|
|
713
714
|
super().__init__(**kwargs)
|
|
714
715
|
|
|
715
716
|
async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa: ARG002
|
|
717
|
+
self.params["ids"] = self.ids
|
|
716
718
|
query = """
|
|
717
|
-
|
|
718
|
-
|
|
719
|
+
MATCH (n:Node)-[r:IS_PART_OF {status: "active"}]->(:Root)
|
|
720
|
+
WHERE toString(n.uuid) IN $ids
|
|
721
|
+
"""
|
|
722
|
+
# only add the branch filter logic if a branch is included in the query parameters
|
|
723
|
+
if branch := getattr(self, "branch", None):
|
|
724
|
+
branch = await registry.get_branch(db=db, branch=branch)
|
|
725
|
+
branch_filter, branch_params = branch.get_query_filter_path(at=self.at)
|
|
726
|
+
self.params.update(branch_params)
|
|
727
|
+
query += f"AND {branch_filter}"
|
|
728
|
+
query += """
|
|
729
|
+
WITH n.uuid AS node_id, n.kind AS node_kind
|
|
730
|
+
ORDER BY r.from DESC
|
|
731
|
+
WITH node_id, head(collect(node_kind)) AS node_kind
|
|
719
732
|
"""
|
|
720
733
|
self.add_to_query(query)
|
|
721
|
-
self.
|
|
722
|
-
|
|
723
|
-
self.return_labels = ["n.uuid AS node_id", "n.kind AS node_kind"]
|
|
734
|
+
self.return_labels = ["node_id", "node_kind"]
|
|
724
735
|
|
|
725
736
|
async def get_node_kind_map(self) -> dict[str, str]:
|
|
726
737
|
node_kind_map: dict[str, str] = {}
|
infrahub/exceptions.py
CHANGED
|
@@ -76,6 +76,32 @@ class RepositoryError(Error):
|
|
|
76
76
|
super().__init__(self.message)
|
|
77
77
|
|
|
78
78
|
|
|
79
|
+
class RepositoryConnectionError(RepositoryError):
|
|
80
|
+
def __init__(self, identifier: str, message: str | None = None) -> None:
|
|
81
|
+
super().__init__(
|
|
82
|
+
identifier=identifier,
|
|
83
|
+
message=message
|
|
84
|
+
or f"Unable to clone the repository {identifier}, please check the address and the credential",
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class RepositoryCredentialsError(RepositoryError):
|
|
89
|
+
def __init__(self, identifier: str, message: str | None = None) -> None:
|
|
90
|
+
super().__init__(
|
|
91
|
+
identifier=identifier,
|
|
92
|
+
message=message or f"Authentication failed for {identifier}, please validate the credentials.",
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class RepositoryInvalidBranchError(RepositoryError):
|
|
97
|
+
def __init__(self, identifier: str, branch_name: str, location: str, message: str | None = None) -> None:
|
|
98
|
+
super().__init__(
|
|
99
|
+
identifier=identifier,
|
|
100
|
+
message=message
|
|
101
|
+
or f"The branch {branch_name} isn't a valid branch for the repository {identifier} at {location}.",
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
79
105
|
class RepositoryInvalidFileSystemError(RepositoryError):
|
|
80
106
|
def __init__(
|
|
81
107
|
self,
|
|
@@ -83,9 +109,11 @@ class RepositoryInvalidFileSystemError(RepositoryError):
|
|
|
83
109
|
directory: Path,
|
|
84
110
|
message: str | None = None,
|
|
85
111
|
) -> None:
|
|
86
|
-
super().__init__(
|
|
112
|
+
super().__init__(
|
|
113
|
+
identifier=identifier,
|
|
114
|
+
message=message or f"Invalid file system for {identifier}, Local directory {directory} missing.",
|
|
115
|
+
)
|
|
87
116
|
self.directory = directory
|
|
88
|
-
self.message = message or f"Invalid file system for {identifier}, Local directory {directory} missing."
|
|
89
117
|
|
|
90
118
|
|
|
91
119
|
class CommitNotFoundError(Error):
|
infrahub/git/base.py
CHANGED
|
@@ -17,13 +17,16 @@ from pydantic import BaseModel, ConfigDict, Field
|
|
|
17
17
|
from pydantic import ValidationError as PydanticValidationError
|
|
18
18
|
|
|
19
19
|
from infrahub.core.branch import Branch
|
|
20
|
-
from infrahub.core.constants import InfrahubKind
|
|
20
|
+
from infrahub.core.constants import InfrahubKind, RepositoryOperationalStatus, RepositorySyncStatus
|
|
21
21
|
from infrahub.core.registry import registry
|
|
22
22
|
from infrahub.exceptions import (
|
|
23
23
|
CommitNotFoundError,
|
|
24
24
|
FileOutOfRepositoryError,
|
|
25
|
+
RepositoryConnectionError,
|
|
26
|
+
RepositoryCredentialsError,
|
|
25
27
|
RepositoryError,
|
|
26
28
|
RepositoryFileNotFoundError,
|
|
29
|
+
RepositoryInvalidBranchError,
|
|
27
30
|
RepositoryInvalidFileSystemError,
|
|
28
31
|
)
|
|
29
32
|
from infrahub.git.constants import BRANCHES_DIRECTORY_NAME, COMMITS_DIRECTORY_NAME, TEMPORARY_DIRECTORY_NAME
|
|
@@ -200,6 +203,54 @@ class InfrahubRepositoryBase(BaseModel, ABC):
|
|
|
200
203
|
"""Return the path to the directory where the temp worktrees of all the commits pending validation are stored."""
|
|
201
204
|
return self.directory_root / TEMPORARY_DIRECTORY_NAME
|
|
202
205
|
|
|
206
|
+
async def _update_operational_status(self, status: RepositoryOperationalStatus) -> None:
|
|
207
|
+
update_status = """
|
|
208
|
+
mutation UpdateRepositoryStatus(
|
|
209
|
+
$repo_id: String!,
|
|
210
|
+
$status: String!,
|
|
211
|
+
) {
|
|
212
|
+
CoreGenericRepositoryUpdate(
|
|
213
|
+
data: {
|
|
214
|
+
id: $repo_id,
|
|
215
|
+
operational_status: { value: $status },
|
|
216
|
+
}
|
|
217
|
+
) {
|
|
218
|
+
ok
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
"""
|
|
222
|
+
|
|
223
|
+
await self.sdk.execute_graphql(
|
|
224
|
+
branch_name=self.infrahub_branch_name or registry.default_branch,
|
|
225
|
+
query=update_status,
|
|
226
|
+
variables={"repo_id": str(self.id), "status": status.value},
|
|
227
|
+
tracker="mutation-repository-update-operational-status",
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
async def _update_sync_status(self, branch_name: str, status: RepositorySyncStatus) -> None:
|
|
231
|
+
update_status = """
|
|
232
|
+
mutation UpdateRepositoryStatus(
|
|
233
|
+
$repo_id: String!,
|
|
234
|
+
$status: String!,
|
|
235
|
+
) {
|
|
236
|
+
CoreGenericRepositoryUpdate(
|
|
237
|
+
data: {
|
|
238
|
+
id: $repo_id,
|
|
239
|
+
sync_status: { value: $status },
|
|
240
|
+
}
|
|
241
|
+
) {
|
|
242
|
+
ok
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
"""
|
|
246
|
+
|
|
247
|
+
await self.sdk.execute_graphql(
|
|
248
|
+
branch_name=branch_name,
|
|
249
|
+
query=update_status,
|
|
250
|
+
variables={"repo_id": str(self.id), "status": status.value},
|
|
251
|
+
tracker="mutation-repository-update-admin-status",
|
|
252
|
+
)
|
|
253
|
+
|
|
203
254
|
def get_git_repo_main(self) -> Repo:
|
|
204
255
|
"""Return Git Repo object of the main repository.
|
|
205
256
|
|
|
@@ -340,7 +391,7 @@ class InfrahubRepositoryBase(BaseModel, ABC):
|
|
|
340
391
|
repo = Repo.clone_from(self.location, self.directory_default)
|
|
341
392
|
repo.git.checkout(checkout_ref or self.default_branch)
|
|
342
393
|
except GitCommandError as exc:
|
|
343
|
-
self._raise_enriched_error(error=exc)
|
|
394
|
+
await self._raise_enriched_error(error=exc)
|
|
344
395
|
|
|
345
396
|
self.has_origin = True
|
|
346
397
|
|
|
@@ -572,7 +623,7 @@ class InfrahubRepositoryBase(BaseModel, ABC):
|
|
|
572
623
|
try:
|
|
573
624
|
br_repo.remotes.origin.pull(branch_name)
|
|
574
625
|
except GitCommandError as exc:
|
|
575
|
-
self._raise_enriched_error(error=exc, branch_name=branch_name)
|
|
626
|
+
await self._raise_enriched_error(error=exc, branch_name=branch_name)
|
|
576
627
|
self.create_commit_worktree(str(br_repo.head.reference.commit))
|
|
577
628
|
log.debug(
|
|
578
629
|
f"Branch {branch_name} created in Git, tracking remote branch {remote_branch[0]}.",
|
|
@@ -668,7 +719,9 @@ class InfrahubRepositoryBase(BaseModel, ABC):
|
|
|
668
719
|
try:
|
|
669
720
|
repo.remotes.origin.fetch()
|
|
670
721
|
except GitCommandError as exc:
|
|
671
|
-
self._raise_enriched_error(error=exc)
|
|
722
|
+
await self._raise_enriched_error(error=exc)
|
|
723
|
+
|
|
724
|
+
await self._update_operational_status(status=RepositoryOperationalStatus.ONLINE)
|
|
672
725
|
|
|
673
726
|
return True
|
|
674
727
|
|
|
@@ -765,7 +818,7 @@ class InfrahubRepositoryBase(BaseModel, ABC):
|
|
|
765
818
|
commit_before = str(repo.head.commit)
|
|
766
819
|
repo.remotes.origin.pull(branch_name)
|
|
767
820
|
except GitCommandError as exc:
|
|
768
|
-
self._raise_enriched_error(error=exc, branch_name=branch_name)
|
|
821
|
+
await self._raise_enriched_error(error=exc, branch_name=branch_name)
|
|
769
822
|
|
|
770
823
|
commit_after = str(repo.head.commit)
|
|
771
824
|
|
|
@@ -862,37 +915,41 @@ class InfrahubRepositoryBase(BaseModel, ABC):
|
|
|
862
915
|
except GitCommandError as exc:
|
|
863
916
|
cls._raise_enriched_error_static(name=name, location=url, error=exc)
|
|
864
917
|
|
|
865
|
-
def _raise_enriched_error(self, error: GitCommandError, branch_name: str | None = None) -> NoReturn:
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
918
|
+
async def _raise_enriched_error(self, error: GitCommandError, branch_name: str | None = None) -> NoReturn:
|
|
919
|
+
try:
|
|
920
|
+
self._raise_enriched_error_static(
|
|
921
|
+
error=error, name=self.name, location=self.location, branch_name=branch_name or self.default_branch
|
|
922
|
+
)
|
|
923
|
+
except RepositoryError as exc:
|
|
924
|
+
await self._update_operational_status(
|
|
925
|
+
status={
|
|
926
|
+
RepositoryConnectionError: RepositoryOperationalStatus.ERROR_CONNECTION,
|
|
927
|
+
RepositoryCredentialsError: RepositoryOperationalStatus.ERROR_CRED,
|
|
928
|
+
}.get(type(exc), RepositoryOperationalStatus.ERROR)
|
|
929
|
+
)
|
|
930
|
+
raise
|
|
869
931
|
|
|
870
932
|
@staticmethod
|
|
871
933
|
def _raise_enriched_error_static(
|
|
872
934
|
error: GitCommandError, name: str, location: str, branch_name: str | None = None
|
|
873
935
|
) -> NoReturn:
|
|
874
936
|
if "Repository not found" in error.stderr or "does not appear to be a git" in error.stderr:
|
|
875
|
-
raise
|
|
876
|
-
identifier=name,
|
|
877
|
-
message=f"Unable to clone the repository {name}, please check the address and the credential",
|
|
878
|
-
) from error
|
|
937
|
+
raise RepositoryConnectionError(identifier=name) from error
|
|
879
938
|
|
|
880
939
|
if "error: pathspec" in error.stderr:
|
|
881
|
-
raise
|
|
882
|
-
identifier=name,
|
|
883
|
-
message=f"The branch {branch_name} isn't a valid branch for the repository {name} at {location}.",
|
|
884
|
-
) from error
|
|
940
|
+
raise RepositoryInvalidBranchError(identifier=name, branch_name=branch_name, location=location) from error
|
|
885
941
|
|
|
886
942
|
if "SSL certificate problem" in error.stderr or "server certificate verification failed" in error.stderr:
|
|
887
|
-
raise
|
|
888
|
-
identifier=name,
|
|
889
|
-
message=f"SSL verification failed for {name}, please validate the certificate chain.",
|
|
943
|
+
raise RepositoryConnectionError(
|
|
944
|
+
identifier=name, message=f"SSL verification failed for {name}, please validate the certificate chain."
|
|
890
945
|
) from error
|
|
891
946
|
|
|
892
947
|
if "authentication failed for" in error.stderr.lower():
|
|
893
|
-
raise
|
|
894
|
-
|
|
895
|
-
|
|
948
|
+
raise RepositoryCredentialsError(identifier=name) from error
|
|
949
|
+
|
|
950
|
+
if "fatal: could not read Username for" in error.stderr and "terminal prompts disable" in error.stderr:
|
|
951
|
+
raise RepositoryCredentialsError(
|
|
952
|
+
identifier=name, message=f"Unable to correctly lookup credentials for repository {name} ({location})."
|
|
896
953
|
) from error
|
|
897
954
|
|
|
898
955
|
if any(err in error.stderr for err in ("Need to specify how to reconcile", "because you have unmerged files")):
|
|
@@ -901,12 +958,6 @@ class InfrahubRepositoryBase(BaseModel, ABC):
|
|
|
901
958
|
message=f"Unable to pull the branch {branch_name} for repository {name}, there are conflicts that must be resolved.",
|
|
902
959
|
) from error
|
|
903
960
|
|
|
904
|
-
if "fatal: could not read Username for" in error.stderr and "terminal prompts disable" in error.stderr:
|
|
905
|
-
raise RepositoryError(
|
|
906
|
-
identifier=name,
|
|
907
|
-
message=f"Unable to correctly lookup credentials for repository {name} ({location}).",
|
|
908
|
-
) from error
|
|
909
|
-
|
|
910
961
|
raise RepositoryError(identifier=name, message=error.stderr) from error
|
|
911
962
|
|
|
912
963
|
def _get_mapped_remote_branch(self, branch_name: str) -> str:
|
infrahub/git/integrator.py
CHANGED
|
@@ -212,30 +212,6 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
212
212
|
)
|
|
213
213
|
)
|
|
214
214
|
|
|
215
|
-
async def _update_sync_status(self, branch_name: str, status: RepositorySyncStatus) -> None:
|
|
216
|
-
update_status = """
|
|
217
|
-
mutation UpdateRepositoryStatus(
|
|
218
|
-
$repo_id: String!,
|
|
219
|
-
$status: String!,
|
|
220
|
-
) {
|
|
221
|
-
CoreGenericRepositoryUpdate(
|
|
222
|
-
data: {
|
|
223
|
-
id: $repo_id,
|
|
224
|
-
sync_status: { value: $status },
|
|
225
|
-
}
|
|
226
|
-
) {
|
|
227
|
-
ok
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
"""
|
|
231
|
-
|
|
232
|
-
await self.sdk.execute_graphql(
|
|
233
|
-
branch_name=branch_name,
|
|
234
|
-
query=update_status,
|
|
235
|
-
variables={"repo_id": str(self.id), "status": status.value},
|
|
236
|
-
tracker="mutation-repository-update-admin-status",
|
|
237
|
-
)
|
|
238
|
-
|
|
239
215
|
@task(name="import-jinja2-tansforms", task_run_name="Import Jinja2 transform", cache_policy=NONE) # type: ignore[arg-type]
|
|
240
216
|
async def import_jinja2_transforms(
|
|
241
217
|
self,
|
infrahub/trigger/tasks.py
CHANGED
|
@@ -14,23 +14,24 @@ from .setup import setup_triggers
|
|
|
14
14
|
|
|
15
15
|
@flow(name="trigger-configure-all", flow_run_name="Configure all triggers")
|
|
16
16
|
async def trigger_configure_all(service: InfrahubServices) -> None:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
async with service.database.start_session() as db:
|
|
18
|
+
webhook_trigger = await gather_trigger_webhook(db=db)
|
|
19
|
+
computed_attribute_j2_triggers = await gather_trigger_computed_attribute_jinja2()
|
|
20
|
+
(
|
|
21
|
+
computed_attribute_python_triggers,
|
|
22
|
+
computed_attribute_python_query_triggers,
|
|
23
|
+
) = await gather_trigger_computed_attribute_python(db=db)
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
async with get_client(sync_client=False) as prefect_client:
|
|
33
|
-
await setup_triggers(
|
|
34
|
-
client=prefect_client,
|
|
35
|
-
triggers=triggers,
|
|
25
|
+
triggers = (
|
|
26
|
+
computed_attribute_j2_triggers
|
|
27
|
+
+ computed_attribute_python_triggers
|
|
28
|
+
+ computed_attribute_python_query_triggers
|
|
29
|
+
+ builtin_triggers
|
|
30
|
+
+ webhook_trigger
|
|
36
31
|
)
|
|
32
|
+
|
|
33
|
+
async with get_client(sync_client=False) as prefect_client:
|
|
34
|
+
await setup_triggers(
|
|
35
|
+
client=prefect_client,
|
|
36
|
+
triggers=triggers,
|
|
37
|
+
)
|
infrahub/workflows/utils.py
CHANGED
|
@@ -15,7 +15,8 @@ from .constants import TAG_NAMESPACE, WorkflowTag
|
|
|
15
15
|
if TYPE_CHECKING:
|
|
16
16
|
import logging
|
|
17
17
|
|
|
18
|
-
from infrahub.
|
|
18
|
+
from infrahub.database import InfrahubDatabase
|
|
19
|
+
from infrahub.services import InfrahubComponent
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
async def add_tags(
|
|
@@ -56,7 +57,7 @@ async def add_related_node_tag(node_id: str) -> None:
|
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
async def wait_for_schema_to_converge(
|
|
59
|
-
branch_name: str,
|
|
60
|
+
branch_name: str, component: InfrahubComponent, db: InfrahubDatabase, log: logging.Logger | logging.LoggerAdapter
|
|
60
61
|
) -> None:
|
|
61
62
|
has_converged = False
|
|
62
63
|
branch_id = branch_name
|
|
@@ -67,7 +68,7 @@ async def wait_for_schema_to_converge(
|
|
|
67
68
|
max_iterations = delay * 5 * 30
|
|
68
69
|
iteration = 0
|
|
69
70
|
while not has_converged:
|
|
70
|
-
workers = await
|
|
71
|
+
workers = await component.list_workers(branch=branch_id, schema_hash=True)
|
|
71
72
|
|
|
72
73
|
hashes = {worker.schema_hash for worker in workers if worker.active}
|
|
73
74
|
if len(hashes) == 1:
|
|
@@ -79,8 +80,7 @@ async def wait_for_schema_to_converge(
|
|
|
79
80
|
log.warning(
|
|
80
81
|
f"Schema had not converged after {delay * iteration:.2f} seconds, refreshing schema on local worker manually"
|
|
81
82
|
)
|
|
82
|
-
|
|
83
|
-
await refresh_branches(db=db)
|
|
83
|
+
await refresh_branches(db=db)
|
|
84
84
|
return
|
|
85
85
|
|
|
86
86
|
iteration += 1
|
infrahub_sdk/node.py
CHANGED
|
@@ -1418,8 +1418,10 @@ class InfrahubNode(InfrahubNodeBase):
|
|
|
1418
1418
|
) -> None:
|
|
1419
1419
|
mutation_query = self._generate_mutation_query()
|
|
1420
1420
|
|
|
1421
|
+
# Upserting means we may want to create, meaning payload contains all mandatory fields required for a creation,
|
|
1422
|
+
# so hfid is just redondant information. Currently, upsert mutation has performance overhead if `hfid` is filled.
|
|
1421
1423
|
if allow_upsert:
|
|
1422
|
-
input_data = self._generate_input_data(exclude_hfid=
|
|
1424
|
+
input_data = self._generate_input_data(exclude_hfid=True, request_context=request_context)
|
|
1423
1425
|
mutation_name = f"{self._schema.kind}Upsert"
|
|
1424
1426
|
tracker = f"mutation-{str(self._schema.kind).lower()}-upsert"
|
|
1425
1427
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: infrahub-server
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
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
|
Home-page: https://opsmill.com
|
|
6
6
|
License: AGPL-3.0-only
|
|
@@ -38,7 +38,7 @@ infrahub/computed_attribute/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
38
38
|
infrahub/computed_attribute/constants.py,sha256=oTMPEfRuf2mcfCkBpRLWRALO6nsLHpFm9jJGu0lowS4,446
|
|
39
39
|
infrahub/computed_attribute/gather.py,sha256=TSv6_CWZH1DYRv430jzyJpFJWKzwPGka5wFiL1jJ9rM,8096
|
|
40
40
|
infrahub/computed_attribute/models.py,sha256=-jS47FBYfbZptd0knzSm_m4GFFnQGMC09QNey1MQt04,12804
|
|
41
|
-
infrahub/computed_attribute/tasks.py,sha256=
|
|
41
|
+
infrahub/computed_attribute/tasks.py,sha256=5LR_mZI-nCpYqTY177w6pb2i5BHSRpxE1dMj647TNL8,17344
|
|
42
42
|
infrahub/computed_attribute/triggers.py,sha256=ve1cUj0CZ7dU1VtZkxET9LD8StszKIL9mCkTZpCeUaI,2304
|
|
43
43
|
infrahub/config.py,sha256=9IqZqt9WS9w3vOgfwexv-XrNuI3w4_f4knLuJSJETt4,34025
|
|
44
44
|
infrahub/context.py,sha256=8SZRKSECkkcsNNzDaKEUJ7Nyr0EzUfToAy969LXjQVk,1554
|
|
@@ -200,7 +200,7 @@ infrahub/core/query/branch.py,sha256=5U0YRAcJUnWYwJWRJVhUG0_VRa18_NtDhp02VLKotM0
|
|
|
200
200
|
infrahub/core/query/delete.py,sha256=_PL97nz-ybF0JqDSYlTPhIa4oCxwPiFerwd8Wjw-x-8,1918
|
|
201
201
|
infrahub/core/query/diff.py,sha256=-hMyXsKfsBmxmSnboF-hN8IYa0aTPXJRUocMtOyyRs4,31987
|
|
202
202
|
infrahub/core/query/ipam.py,sha256=s8bLw5qnfKf2pUKv8AYkxsL0ILnVH4l2Zi3fpiREoPk,28187
|
|
203
|
-
infrahub/core/query/node.py,sha256
|
|
203
|
+
infrahub/core/query/node.py,sha256=-gpEaJHND7MjpNT33EkMArEDoVGkienMa4E5QJT6Hgg,61784
|
|
204
204
|
infrahub/core/query/relationship.py,sha256=b6_kfwzttfVHJ0_Ej3dRUg62cWs3wwZvp-YLlSubnQE,42567
|
|
205
205
|
infrahub/core/query/resource_manager.py,sha256=rVksmyFSTGwiq0ZFp2I8kGuMI_F2__c9wE7LgYYeqow,12728
|
|
206
206
|
infrahub/core/query/standard_node.py,sha256=stQfJqLaeqouaZtrlJhc9MsJUnW3tfheXrWHsM1vp7Q,4511
|
|
@@ -379,15 +379,15 @@ infrahub/events/repository_action.py,sha256=5x0boObzGipVb_QGQfNOXBrtENs-SNAjrutt
|
|
|
379
379
|
infrahub/events/schema_action.py,sha256=IvsCvEWsnl7CArJT5DqBn7nF7xmE8JdOHdcVqjeLWGk,1429
|
|
380
380
|
infrahub/events/utils.py,sha256=JmyKKKDjyD3LS9LlY9_AetL8hBb8EdEfRlreUihskTs,649
|
|
381
381
|
infrahub/events/validator_action.py,sha256=nQJH-RWcgr3-tzmIldvPmu5O7dUAmv1qQnuxxypBEto,1881
|
|
382
|
-
infrahub/exceptions.py,sha256=
|
|
382
|
+
infrahub/exceptions.py,sha256=cbM-f_2U-5ZFVZ_MaaXgs64k4M7uJ7fqDU2iCRoWlYY,11861
|
|
383
383
|
infrahub/generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
384
384
|
infrahub/generators/models.py,sha256=9qhSfsoG-uYux35HClAxSq7TRfkosqN3i_eQkeTokLs,1916
|
|
385
385
|
infrahub/generators/tasks.py,sha256=2G03bs8C0zS7uyGwthq0t3HO1J-4cAOa6CaxLgsAWUE,9469
|
|
386
386
|
infrahub/git/__init__.py,sha256=KeQ9U8UI5jDj6KB6j00Oal7MZmtOD9vKqVgiezG_EQA,281
|
|
387
|
-
infrahub/git/base.py,sha256=
|
|
387
|
+
infrahub/git/base.py,sha256=WTYJ_LqiUhlaMs9QGt1X6pZrsCwmfUZ3eeZYOfZ9mts,38717
|
|
388
388
|
infrahub/git/constants.py,sha256=XpzcAkXbsgXZgrXey74id1sXV8Q6EHb_4FNw7BndxyY,106
|
|
389
389
|
infrahub/git/directory.py,sha256=fozxLXXJPweHG95yQwQkR5yy3sfTdmHiczCAJnsUX54,861
|
|
390
|
-
infrahub/git/integrator.py,sha256=
|
|
390
|
+
infrahub/git/integrator.py,sha256=GNb0IOClpsm0EyCWTHbqA-Ewt4CCKOypZcbarzDJKRI,57556
|
|
391
391
|
infrahub/git/models.py,sha256=TwiJnknL3nRaFybttLIoVGC9Pqd5smxM4Lh7zTxaqmE,11961
|
|
392
392
|
infrahub/git/repository.py,sha256=mjYeH3pKWRM3UuvcwRCWeE793FuPbSdY8VF1IYK-BxA,11603
|
|
393
393
|
infrahub/git/tasks.py,sha256=EvquEalnUbZHvtFBZBt2BNsHILXCxzBWBKIbR7pgyGk,37102
|
|
@@ -617,7 +617,7 @@ infrahub/trigger/catalogue.py,sha256=jnMs0i6MureKREyFvGop3eWIlcszSDE5UuayODTEDBc
|
|
|
617
617
|
infrahub/trigger/constants.py,sha256=u9_5A6gIUIrprzfEdwseYk2yTkwU0VPCjZTwL8b3T6s,22
|
|
618
618
|
infrahub/trigger/models.py,sha256=FQ7VDu9l1GL-zDrRLz8yIlWZSc0ugI8k0kjjvB21VA8,3805
|
|
619
619
|
infrahub/trigger/setup.py,sha256=cq3PgJ3VVNufKGX63RXUA-nkhAqjhGapZtPP5bzJuxY,3727
|
|
620
|
-
infrahub/trigger/tasks.py,sha256=
|
|
620
|
+
infrahub/trigger/tasks.py,sha256=NAGzdR314AHuvU1Juznh53T87iidJgXybeO1bYHmCzY,1420
|
|
621
621
|
infrahub/types.py,sha256=qKmmmL1UGCAJ2O2P9YES9uEvrr0uVXt9KSLtktg_hsU,11322
|
|
622
622
|
infrahub/utils.py,sha256=3p_bXmRGOTnXIMG9fZ9mFsKdBw2fU3VBFJT3YHrbvyw,2704
|
|
623
623
|
infrahub/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -638,7 +638,7 @@ infrahub/workflows/catalogue.py,sha256=2HgFnrhwQYmV_AVNrsS69QTZEtJ4rUI8A9Tc2SkTg
|
|
|
638
638
|
infrahub/workflows/constants.py,sha256=7je2FF7tJH6x_ZNqHKZfQX91X7I5gmD8OECN3dE_eqI,651
|
|
639
639
|
infrahub/workflows/initialization.py,sha256=BJjSt9uz7fuNr2aahGbLdy1RUKw8AjxKrZ81cJswbxY,3219
|
|
640
640
|
infrahub/workflows/models.py,sha256=uGBNla2xJqKnqARdq21vhXGHxM2ozDqioeBvT7zg3Jo,3439
|
|
641
|
-
infrahub/workflows/utils.py,sha256=
|
|
641
|
+
infrahub/workflows/utils.py,sha256=DhN_NbpaJ_-I4a8GGtKcTfYf8EEJSuRX7PaO06dis-w,2730
|
|
642
642
|
infrahub_sdk/__init__.py,sha256=weZAa06Ar0NO5IOKLQICtCceHUCKQxbkBxHebqQGJ1o,401
|
|
643
643
|
infrahub_sdk/_importer.py,sha256=8oHTMxa_AMO_qbfb3UXNfjSr31S5YJTcqe-YMrixY_E,2257
|
|
644
644
|
infrahub_sdk/analyzer.py,sha256=UDJN372vdAiuAv2TEyPUlsSVoUfZN6obWkIokNNaHbA,4148
|
|
@@ -679,7 +679,7 @@ infrahub_sdk/generator.py,sha256=bxyJ4CpolwzwCbunqA8eVshx-LzlPr-NMDndywZm-2Y,553
|
|
|
679
679
|
infrahub_sdk/graphql.py,sha256=zrxRveg8-t0FbLtOEMDiiW0vqtBHc2qaFRkiHF9Bp6g,7019
|
|
680
680
|
infrahub_sdk/groups.py,sha256=GL14ByW4GHrkqOLJ-_vGhu6bkYDxljqPtkErcQVehv0,711
|
|
681
681
|
infrahub_sdk/jinja2.py,sha256=lTfV9E_P5gApaX6RW9M8U8oixQi-0H3U8wcs8fdGVaU,1150
|
|
682
|
-
infrahub_sdk/node.py,sha256=
|
|
682
|
+
infrahub_sdk/node.py,sha256=GZ7yO-tfcSR-fYdcrWZ0mElVdesly04sduT5x9bCe0U,89554
|
|
683
683
|
infrahub_sdk/object_store.py,sha256=d-EDnxPpw_7BsbjbGbH50rjt-1-Ojj2zNrhFansP5hA,4299
|
|
684
684
|
infrahub_sdk/playback.py,sha256=ubkY1LiW_wFwm4auerdQ0zFJcFJZ1SYQT6-d4bxzaLg,1906
|
|
685
685
|
infrahub_sdk/protocols.py,sha256=LyiZcUvcT-ibgWYyYELjAPyAv42kxdhAPyFfac-RIZo,21569
|
|
@@ -747,8 +747,8 @@ infrahub_testcontainers/models.py,sha256=R735sO9i6D1TTtwlB0rweN3rWmZMYoSFfk1zt5X
|
|
|
747
747
|
infrahub_testcontainers/performance_test.py,sha256=82g4hfDuEesV7T8U12UjMV7ujZQMy_q30CSNQCdDVlQ,5993
|
|
748
748
|
infrahub_testcontainers/plugin.py,sha256=vk33oG44MA2zxZwqMsS8_CkScm5LwuwwFmSOtmeAdMU,5357
|
|
749
749
|
infrahub_testcontainers/prometheus.yml,sha256=610xQEyj3xuVJMzPkC4m1fRnCrjGpiRBrXA2ytCLa54,599
|
|
750
|
-
infrahub_server-1.2.
|
|
751
|
-
infrahub_server-1.2.
|
|
752
|
-
infrahub_server-1.2.
|
|
753
|
-
infrahub_server-1.2.
|
|
754
|
-
infrahub_server-1.2.
|
|
750
|
+
infrahub_server-1.2.2.dist-info/LICENSE.txt,sha256=TfPDBt3ar0uv_f9cqCDMZ5rIzW3CY8anRRd4PkL6ejs,34522
|
|
751
|
+
infrahub_server-1.2.2.dist-info/METADATA,sha256=bL37X-uQOrAJB1mH89BKaq0Zo-nIebAQxV8LlQ5iC54,8155
|
|
752
|
+
infrahub_server-1.2.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
753
|
+
infrahub_server-1.2.2.dist-info/entry_points.txt,sha256=UXIeFWDsrV-4IllNvUEd6KieYGzQfn9paga2YyABOQI,393
|
|
754
|
+
infrahub_server-1.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|