infrahub-server 1.3.7__py3-none-any.whl → 1.4.0__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/api/internal.py +5 -0
- infrahub/artifacts/tasks.py +17 -22
- infrahub/branch/merge_mutation_checker.py +38 -0
- infrahub/cli/__init__.py +2 -2
- infrahub/cli/context.py +7 -3
- infrahub/cli/db.py +5 -16
- infrahub/cli/upgrade.py +10 -29
- infrahub/computed_attribute/tasks.py +36 -46
- infrahub/config.py +57 -6
- infrahub/constants/environment.py +1 -0
- infrahub/core/attribute.py +15 -7
- infrahub/core/branch/tasks.py +43 -41
- infrahub/core/constants/__init__.py +21 -6
- infrahub/core/constants/infrahubkind.py +2 -0
- infrahub/core/diff/coordinator.py +3 -1
- infrahub/core/diff/model/path.py +0 -39
- infrahub/core/diff/repository/repository.py +0 -8
- infrahub/core/diff/tasks.py +11 -8
- infrahub/core/graph/__init__.py +1 -1
- infrahub/core/graph/index.py +1 -2
- infrahub/core/graph/schema.py +50 -29
- infrahub/core/initialization.py +81 -47
- infrahub/core/ipam/tasks.py +4 -3
- infrahub/core/merge.py +8 -10
- infrahub/core/migrations/__init__.py +2 -0
- infrahub/core/migrations/graph/__init__.py +4 -0
- infrahub/core/migrations/graph/m036_drop_attr_value_index.py +45 -0
- infrahub/core/migrations/graph/m037_index_attr_vals.py +577 -0
- infrahub/core/migrations/query/attribute_add.py +27 -2
- infrahub/core/migrations/schema/attribute_kind_update.py +156 -0
- infrahub/core/migrations/schema/tasks.py +6 -5
- infrahub/core/models.py +5 -1
- infrahub/core/node/proposed_change.py +43 -0
- infrahub/core/protocols.py +12 -0
- infrahub/core/query/attribute.py +32 -14
- infrahub/core/query/diff.py +11 -0
- infrahub/core/query/ipam.py +13 -7
- infrahub/core/query/node.py +51 -10
- infrahub/core/query/resource_manager.py +3 -3
- infrahub/core/schema/basenode_schema.py +8 -0
- infrahub/core/schema/definitions/core/__init__.py +10 -1
- infrahub/core/schema/definitions/core/ipam.py +28 -2
- infrahub/core/schema/definitions/core/propose_change.py +15 -0
- infrahub/core/schema/definitions/core/webhook.py +3 -0
- infrahub/core/schema/definitions/internal.py +1 -1
- infrahub/core/schema/generated/attribute_schema.py +1 -1
- infrahub/core/schema/generic_schema.py +10 -0
- infrahub/core/schema/manager.py +10 -1
- infrahub/core/schema/node_schema.py +22 -22
- infrahub/core/schema/profile_schema.py +8 -0
- infrahub/core/schema/schema_branch.py +11 -7
- infrahub/core/schema/template_schema.py +8 -0
- infrahub/core/validators/attribute/kind.py +5 -1
- infrahub/core/validators/checks_runner.py +5 -5
- infrahub/core/validators/determiner.py +22 -2
- infrahub/core/validators/tasks.py +6 -7
- infrahub/core/validators/uniqueness/checker.py +4 -2
- infrahub/core/validators/uniqueness/model.py +1 -0
- infrahub/core/validators/uniqueness/query.py +57 -7
- infrahub/database/__init__.py +2 -1
- infrahub/events/__init__.py +20 -0
- infrahub/events/constants.py +7 -0
- infrahub/events/generator.py +29 -2
- infrahub/events/proposed_change_action.py +203 -0
- infrahub/generators/tasks.py +24 -20
- infrahub/git/base.py +4 -7
- infrahub/git/integrator.py +21 -12
- infrahub/git/repository.py +15 -30
- infrahub/git/tasks.py +121 -106
- infrahub/graphql/app.py +2 -1
- infrahub/graphql/field_extractor.py +69 -0
- infrahub/graphql/manager.py +15 -11
- infrahub/graphql/mutations/account.py +2 -2
- infrahub/graphql/mutations/action.py +8 -2
- infrahub/graphql/mutations/artifact_definition.py +4 -1
- infrahub/graphql/mutations/branch.py +10 -5
- infrahub/graphql/mutations/graphql_query.py +2 -1
- infrahub/graphql/mutations/main.py +14 -8
- infrahub/graphql/mutations/menu.py +2 -1
- infrahub/graphql/mutations/proposed_change.py +230 -8
- infrahub/graphql/mutations/relationship.py +5 -0
- infrahub/graphql/mutations/repository.py +2 -1
- infrahub/graphql/mutations/tasks.py +7 -9
- infrahub/graphql/mutations/webhook.py +4 -1
- infrahub/graphql/parser.py +15 -6
- infrahub/graphql/queries/__init__.py +10 -1
- infrahub/graphql/queries/account.py +3 -3
- infrahub/graphql/queries/branch.py +2 -2
- infrahub/graphql/queries/diff/tree.py +56 -5
- infrahub/graphql/queries/event.py +13 -3
- infrahub/graphql/queries/ipam.py +23 -1
- infrahub/graphql/queries/proposed_change.py +84 -0
- infrahub/graphql/queries/relationship.py +2 -2
- infrahub/graphql/queries/resource_manager.py +3 -3
- infrahub/graphql/queries/search.py +3 -2
- infrahub/graphql/queries/status.py +3 -2
- infrahub/graphql/queries/task.py +2 -2
- infrahub/graphql/resolvers/ipam.py +440 -0
- infrahub/graphql/resolvers/many_relationship.py +4 -3
- infrahub/graphql/resolvers/resolver.py +5 -5
- infrahub/graphql/resolvers/single_relationship.py +3 -2
- infrahub/graphql/schema.py +25 -5
- infrahub/graphql/types/__init__.py +2 -2
- infrahub/graphql/types/attribute.py +3 -3
- infrahub/graphql/types/event.py +68 -0
- infrahub/groups/tasks.py +6 -6
- infrahub/lock.py +3 -2
- infrahub/menu/generator.py +8 -0
- infrahub/message_bus/operations/__init__.py +9 -12
- infrahub/message_bus/operations/git/file.py +6 -5
- infrahub/message_bus/operations/git/repository.py +12 -20
- infrahub/message_bus/operations/refresh/registry.py +15 -9
- infrahub/message_bus/operations/send/echo.py +7 -4
- infrahub/message_bus/types.py +1 -0
- infrahub/permissions/__init__.py +2 -1
- infrahub/permissions/constants.py +13 -0
- infrahub/permissions/globals.py +31 -2
- infrahub/permissions/manager.py +8 -5
- infrahub/pools/prefix.py +7 -5
- infrahub/prefect_server/app.py +31 -0
- infrahub/prefect_server/bootstrap.py +18 -0
- infrahub/proposed_change/action_checker.py +206 -0
- infrahub/proposed_change/approval_revoker.py +40 -0
- infrahub/proposed_change/branch_diff.py +3 -1
- infrahub/proposed_change/checker.py +45 -0
- infrahub/proposed_change/constants.py +32 -2
- infrahub/proposed_change/tasks.py +182 -150
- infrahub/py.typed +0 -0
- infrahub/server.py +29 -17
- infrahub/services/__init__.py +13 -28
- infrahub/services/adapters/cache/__init__.py +4 -0
- infrahub/services/adapters/cache/nats.py +2 -0
- infrahub/services/adapters/cache/redis.py +3 -0
- infrahub/services/adapters/message_bus/__init__.py +0 -2
- infrahub/services/adapters/message_bus/local.py +1 -2
- infrahub/services/adapters/message_bus/nats.py +6 -8
- infrahub/services/adapters/message_bus/rabbitmq.py +7 -9
- infrahub/services/adapters/workflow/__init__.py +1 -0
- infrahub/services/adapters/workflow/local.py +1 -8
- infrahub/services/component.py +2 -1
- infrahub/task_manager/event.py +56 -0
- infrahub/task_manager/models.py +9 -0
- infrahub/tasks/artifact.py +6 -7
- infrahub/tasks/check.py +4 -7
- infrahub/telemetry/tasks.py +15 -18
- infrahub/transformations/tasks.py +10 -6
- infrahub/trigger/tasks.py +4 -3
- infrahub/types.py +4 -0
- infrahub/validators/events.py +7 -7
- infrahub/validators/tasks.py +6 -7
- infrahub/webhook/models.py +45 -45
- infrahub/webhook/tasks.py +25 -24
- infrahub/workers/dependencies.py +143 -0
- infrahub/workers/infrahub_async.py +19 -43
- infrahub/workflows/catalogue.py +16 -2
- infrahub/workflows/initialization.py +5 -4
- infrahub/workflows/models.py +2 -0
- infrahub_sdk/client.py +2 -2
- infrahub_sdk/ctl/repository.py +51 -0
- infrahub_sdk/ctl/schema.py +9 -9
- infrahub_sdk/node/node.py +2 -2
- infrahub_sdk/pytest_plugin/items/graphql_query.py +1 -1
- infrahub_sdk/schema/repository.py +1 -1
- infrahub_sdk/testing/docker.py +1 -1
- infrahub_sdk/utils.py +2 -2
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.4.0.dist-info}/METADATA +7 -5
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.4.0.dist-info}/RECORD +174 -158
- infrahub_testcontainers/container.py +17 -0
- infrahub_testcontainers/docker-compose-cluster.test.yml +56 -1
- infrahub_testcontainers/docker-compose.test.yml +56 -1
- infrahub_testcontainers/helpers.py +4 -1
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.4.0.dist-info}/LICENSE.txt +0 -0
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.4.0.dist-info}/WHEEL +0 -0
- {infrahub_server-1.3.7.dist-info → infrahub_server-1.4.0.dist-info}/entry_points.txt +0 -0
infrahub/git/integrator.py
CHANGED
|
@@ -50,6 +50,7 @@ from infrahub.events.repository_action import CommitUpdatedEvent
|
|
|
50
50
|
from infrahub.exceptions import CheckError, RepositoryInvalidFileSystemError, TransformError
|
|
51
51
|
from infrahub.git.base import InfrahubRepositoryBase, extract_repo_file_information
|
|
52
52
|
from infrahub.log import get_logger
|
|
53
|
+
from infrahub.workers.dependencies import get_event_service
|
|
53
54
|
from infrahub.workflows.utils import add_tags
|
|
54
55
|
|
|
55
56
|
if TYPE_CHECKING:
|
|
@@ -62,7 +63,6 @@ if TYPE_CHECKING:
|
|
|
62
63
|
|
|
63
64
|
from infrahub.artifacts.models import CheckArtifactCreate
|
|
64
65
|
from infrahub.git.models import RequestArtifactGenerate
|
|
65
|
-
from infrahub.services import InfrahubServices
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
class ArtifactGenerateResult(BaseModel):
|
|
@@ -141,8 +141,8 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
141
141
|
"""
|
|
142
142
|
|
|
143
143
|
@classmethod
|
|
144
|
-
async def init(cls,
|
|
145
|
-
self = cls(
|
|
144
|
+
async def init(cls, commit: str | None = None, **kwargs: Any) -> Self:
|
|
145
|
+
self = cls(**kwargs)
|
|
146
146
|
log = get_logger()
|
|
147
147
|
try:
|
|
148
148
|
self.validate_local_directories()
|
|
@@ -216,7 +216,8 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
216
216
|
raise error
|
|
217
217
|
|
|
218
218
|
infrahub_branch = registry.get_branch_from_registry(branch=infrahub_branch_name)
|
|
219
|
-
await
|
|
219
|
+
event_service = await get_event_service()
|
|
220
|
+
await event_service.send(
|
|
220
221
|
CommitUpdatedEvent(
|
|
221
222
|
commit=commit,
|
|
222
223
|
repository_name=self.name,
|
|
@@ -436,10 +437,18 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
436
437
|
branch_wt = self.get_worktree(identifier=commit or branch_name)
|
|
437
438
|
log = get_run_logger()
|
|
438
439
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
# Check for both .infrahub.yml and .infrahub.yaml, prefer .yml if both exist
|
|
441
|
+
config_file_yml = branch_wt.directory / ".infrahub.yml"
|
|
442
|
+
config_file_yaml = branch_wt.directory / ".infrahub.yaml"
|
|
443
|
+
|
|
444
|
+
if config_file_yml.is_file():
|
|
445
|
+
config_file = config_file_yml
|
|
446
|
+
config_file_name = ".infrahub.yml"
|
|
447
|
+
elif config_file_yaml.is_file():
|
|
448
|
+
config_file = config_file_yaml
|
|
449
|
+
config_file_name = ".infrahub.yaml"
|
|
450
|
+
else:
|
|
451
|
+
log.debug("Unable to find the configuration file (.infrahub.yml or .infrahub.yaml), skipping")
|
|
443
452
|
return None
|
|
444
453
|
|
|
445
454
|
config_file_content = config_file.read_text(encoding="utf-8")
|
|
@@ -1264,7 +1273,6 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
1264
1273
|
infrahub_node=InfrahubNode,
|
|
1265
1274
|
)
|
|
1266
1275
|
return await transform.run(data=data)
|
|
1267
|
-
|
|
1268
1276
|
except ModuleNotFoundError as exc:
|
|
1269
1277
|
error_msg = f"Unable to load the transform file {location}"
|
|
1270
1278
|
log.error(error_msg)
|
|
@@ -1314,11 +1322,11 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
1314
1322
|
artifact_content = await self.execute_python_transform.with_options(
|
|
1315
1323
|
timeout_seconds=transformation.timeout.value
|
|
1316
1324
|
)(
|
|
1325
|
+
client=self.sdk,
|
|
1317
1326
|
branch_name=branch_name,
|
|
1318
1327
|
commit=commit,
|
|
1319
1328
|
location=transformation_location,
|
|
1320
1329
|
data=response,
|
|
1321
|
-
client=self.sdk,
|
|
1322
1330
|
convert_query_response=transformation.convert_query_response.value,
|
|
1323
1331
|
) # type: ignore[misc]
|
|
1324
1332
|
|
|
@@ -1374,11 +1382,11 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
1374
1382
|
) # type: ignore[misc]
|
|
1375
1383
|
elif message.transform_type == InfrahubKind.TRANSFORMPYTHON:
|
|
1376
1384
|
artifact_content = await self.execute_python_transform.with_options(timeout_seconds=message.timeout)(
|
|
1385
|
+
client=self.sdk,
|
|
1377
1386
|
branch_name=message.branch_name,
|
|
1378
1387
|
commit=message.commit,
|
|
1379
1388
|
location=message.transform_location,
|
|
1380
1389
|
data=response,
|
|
1381
|
-
client=self.sdk,
|
|
1382
1390
|
convert_query_response=message.convert_query_response,
|
|
1383
1391
|
) # type: ignore[misc]
|
|
1384
1392
|
|
|
@@ -1421,7 +1429,8 @@ class InfrahubRepositoryIntegrator(InfrahubRepositoryBase):
|
|
|
1421
1429
|
storage_id_previous=previous_storage_id,
|
|
1422
1430
|
)
|
|
1423
1431
|
|
|
1424
|
-
await
|
|
1432
|
+
event_service = await get_event_service()
|
|
1433
|
+
await event_service.send(event=event)
|
|
1425
1434
|
return ArtifactGenerateResult(changed=True, checksum=checksum, storage_id=storage_id, artifact_id=artifact.id)
|
|
1426
1435
|
|
|
1427
1436
|
|
infrahub/git/repository.py
CHANGED
|
@@ -4,6 +4,8 @@ from typing import TYPE_CHECKING, Any
|
|
|
4
4
|
|
|
5
5
|
from git.exc import BadName, GitCommandError
|
|
6
6
|
from infrahub_sdk.exceptions import GraphQLError
|
|
7
|
+
from prefect import task
|
|
8
|
+
from prefect.cache_policies import NONE
|
|
7
9
|
from pydantic import Field
|
|
8
10
|
|
|
9
11
|
from infrahub.core.constants import InfrahubKind, RepositoryInternalStatus
|
|
@@ -12,7 +14,7 @@ from infrahub.git.integrator import InfrahubRepositoryIntegrator
|
|
|
12
14
|
from infrahub.log import get_logger
|
|
13
15
|
|
|
14
16
|
if TYPE_CHECKING:
|
|
15
|
-
from
|
|
17
|
+
from infrahub_sdk.client import InfrahubClient
|
|
16
18
|
|
|
17
19
|
log = get_logger()
|
|
18
20
|
|
|
@@ -25,10 +27,8 @@ class InfrahubRepository(InfrahubRepositoryIntegrator):
|
|
|
25
27
|
"""
|
|
26
28
|
|
|
27
29
|
@classmethod
|
|
28
|
-
async def new(
|
|
29
|
-
|
|
30
|
-
) -> InfrahubRepository:
|
|
31
|
-
self = cls(service=service, **kwargs)
|
|
30
|
+
async def new(cls, update_commit_value: bool = True, **kwargs: Any) -> InfrahubRepository:
|
|
31
|
+
self = cls(**kwargs)
|
|
32
32
|
await self.create_locally(
|
|
33
33
|
infrahub_branch_name=self.infrahub_branch_name, update_commit_value=update_commit_value
|
|
34
34
|
)
|
|
@@ -209,11 +209,11 @@ class InfrahubReadOnlyRepository(InfrahubRepositoryIntegrator):
|
|
|
209
209
|
ref: str | None = Field(None, description="Ref to track on the external repository")
|
|
210
210
|
|
|
211
211
|
@classmethod
|
|
212
|
-
async def new(cls,
|
|
212
|
+
async def new(cls, **kwargs: Any) -> InfrahubReadOnlyRepository:
|
|
213
213
|
if "ref" not in kwargs or "infrahub_branch_name" not in kwargs:
|
|
214
214
|
raise ValueError("ref and infrahub_branch_name are mandatory to initialize a new Read-Only repository")
|
|
215
215
|
|
|
216
|
-
self = cls(
|
|
216
|
+
self = cls(**kwargs)
|
|
217
217
|
await self.create_locally(checkout_ref=self.ref, infrahub_branch_name=self.infrahub_branch_name)
|
|
218
218
|
log.info("Created new repository locally.", repository=self.name)
|
|
219
219
|
return self
|
|
@@ -248,33 +248,18 @@ class InfrahubReadOnlyRepository(InfrahubRepositoryIntegrator):
|
|
|
248
248
|
await self.update_commit_value(branch_name=self.infrahub_branch_name, commit=commit)
|
|
249
249
|
|
|
250
250
|
|
|
251
|
+
@task(
|
|
252
|
+
name="Fetch repository commit",
|
|
253
|
+
description="Retrieve a git repository at a given commit, if it does not already exist locally",
|
|
254
|
+
cache_policy=NONE,
|
|
255
|
+
)
|
|
251
256
|
async def get_initialized_repo(
|
|
252
|
-
|
|
257
|
+
client: InfrahubClient, repository_id: str, name: str, repository_kind: str, commit: str | None = None
|
|
253
258
|
) -> InfrahubReadOnlyRepository | InfrahubRepository:
|
|
254
259
|
if repository_kind == InfrahubKind.REPOSITORY:
|
|
255
|
-
return await InfrahubRepository.init(
|
|
256
|
-
id=repository_id, name=name, commit=commit, client=service._client, service=service
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
if repository_kind == InfrahubKind.READONLYREPOSITORY:
|
|
260
|
-
return await InfrahubReadOnlyRepository.init(
|
|
261
|
-
id=repository_id, name=name, commit=commit, client=service._client, service=service
|
|
262
|
-
)
|
|
263
|
-
|
|
264
|
-
raise NotImplementedError(f"The repository kind {repository_kind} has not been implemented")
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
async def initialize_repo(
|
|
268
|
-
location: str, repository_id: str, name: str, service: InfrahubServices, repository_kind: str
|
|
269
|
-
) -> InfrahubReadOnlyRepository | InfrahubRepository:
|
|
270
|
-
if repository_kind == InfrahubKind.REPOSITORY:
|
|
271
|
-
return await InfrahubRepository.new(
|
|
272
|
-
location=location, id=repository_id, name=name, client=service._client, service=service
|
|
273
|
-
)
|
|
260
|
+
return await InfrahubRepository.init(id=repository_id, name=name, commit=commit, client=client)
|
|
274
261
|
|
|
275
262
|
if repository_kind == InfrahubKind.READONLYREPOSITORY:
|
|
276
|
-
return await InfrahubReadOnlyRepository.
|
|
277
|
-
location=location, id=repository_id, name=name, client=service._client, service=service
|
|
278
|
-
)
|
|
263
|
+
return await InfrahubReadOnlyRepository.init(id=repository_id, name=name, commit=commit, client=client)
|
|
279
264
|
|
|
280
265
|
raise NotImplementedError(f"The repository kind {repository_kind} has not been implemented")
|