infrahub-server 1.1.8__py3-none-any.whl → 1.2.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/artifact.py +16 -4
- infrahub/api/dependencies.py +14 -6
- infrahub/api/diff/validation_models.py +7 -7
- infrahub/api/oauth2.py +0 -1
- infrahub/api/oidc.py +0 -1
- infrahub/api/query.py +18 -7
- infrahub/api/schema.py +33 -7
- infrahub/api/transformation.py +12 -5
- infrahub/{message_bus/messages/check_artifact_create.py → artifacts/models.py} +6 -6
- infrahub/{message_bus/operations/check/artifact.py → artifacts/tasks.py} +27 -28
- infrahub/cli/__init__.py +12 -10
- infrahub/cli/constants.py +3 -0
- infrahub/cli/db.py +166 -185
- infrahub/cli/events.py +8 -3
- infrahub/cli/git_agent.py +9 -7
- infrahub/cli/tasks.py +4 -6
- infrahub/cli/upgrade.py +146 -0
- infrahub/computed_attribute/gather.py +174 -0
- infrahub/computed_attribute/models.py +202 -11
- infrahub/computed_attribute/tasks.py +103 -421
- infrahub/computed_attribute/triggers.py +56 -0
- infrahub/config.py +39 -33
- infrahub/context.py +53 -0
- infrahub/core/account.py +9 -12
- infrahub/core/attribute.py +104 -75
- infrahub/core/branch/models.py +4 -4
- infrahub/core/branch/tasks.py +133 -125
- infrahub/core/changelog/__init__.py +0 -0
- infrahub/core/changelog/diff.py +291 -0
- infrahub/core/changelog/models.py +662 -0
- infrahub/core/constants/__init__.py +47 -2
- infrahub/core/constants/infrahubkind.py +3 -0
- infrahub/core/constants/schema.py +2 -0
- infrahub/core/constraint/node/runner.py +2 -2
- infrahub/core/diff/branch_differ.py +10 -10
- infrahub/core/diff/combiner.py +1 -1
- infrahub/core/diff/enricher/cardinality_one.py +1 -1
- infrahub/core/diff/enricher/hierarchy.py +5 -3
- infrahub/core/diff/enricher/labels.py +1 -1
- infrahub/core/diff/enricher/path_identifier.py +1 -2
- infrahub/core/diff/enricher/summary_counts.py +107 -0
- infrahub/core/diff/ipam_diff_parser.py +4 -5
- infrahub/core/diff/merger/merger.py +3 -1
- infrahub/core/diff/model/diff.py +27 -27
- infrahub/core/diff/model/path.py +13 -13
- infrahub/core/diff/query/all_conflicts.py +1 -1
- infrahub/core/diff/query/artifact.py +1 -1
- infrahub/core/diff/query/delete_query.py +1 -1
- infrahub/core/diff/query/diff_get.py +1 -1
- infrahub/core/diff/query/diff_summary.py +1 -1
- infrahub/core/diff/query/field_specifiers.py +1 -1
- infrahub/core/diff/query/field_summary.py +1 -1
- infrahub/core/diff/query/filters.py +2 -2
- infrahub/core/diff/query/get_conflict_query.py +1 -1
- infrahub/core/diff/query/has_conflicts_query.py +1 -1
- infrahub/core/diff/query/merge.py +23 -20
- infrahub/core/diff/query/merge_tracking_id.py +1 -1
- infrahub/core/diff/query/roots_metadata.py +1 -1
- infrahub/core/diff/query/save.py +3 -3
- infrahub/core/diff/query/summary_counts_enricher.py +2 -2
- infrahub/core/diff/query/time_range_query.py +1 -1
- infrahub/core/diff/query/update_conflict_query.py +1 -1
- infrahub/core/diff/query_parser.py +4 -4
- infrahub/core/diff/repository/deserializer.py +1 -1
- infrahub/core/diff/tasks.py +9 -8
- infrahub/core/enums.py +1 -1
- infrahub/core/graph/__init__.py +1 -1
- infrahub/core/initialization.py +1 -10
- infrahub/core/integrity/object_conflict/conflict_recorder.py +1 -1
- infrahub/core/ipam/constants.py +3 -4
- infrahub/core/ipam/reconciler.py +13 -13
- infrahub/core/ipam/tasks.py +2 -3
- infrahub/core/ipam/utilization.py +10 -13
- infrahub/core/manager.py +52 -47
- infrahub/core/merge.py +12 -9
- infrahub/core/migrations/__init__.py +1 -3
- infrahub/core/migrations/graph/__init__.py +7 -3
- infrahub/core/migrations/graph/m001_add_version_to_graph.py +1 -1
- infrahub/core/migrations/graph/m002_attribute_is_default.py +2 -2
- infrahub/core/migrations/graph/m003_relationship_parent_optional.py +2 -2
- infrahub/core/migrations/graph/m004_add_attr_documentation.py +1 -1
- infrahub/core/migrations/graph/m005_add_rel_read_only.py +1 -1
- infrahub/core/migrations/graph/m006_add_rel_on_delete.py +1 -1
- infrahub/core/migrations/graph/m007_add_rel_allow_override.py +1 -1
- infrahub/core/migrations/graph/m008_add_human_friendly_id.py +1 -1
- infrahub/core/migrations/graph/m009_add_generate_profile_attr.py +1 -1
- infrahub/core/migrations/graph/m010_add_generate_profile_attr_generic.py +1 -1
- infrahub/core/migrations/graph/m011_remove_profile_relationship_schema.py +2 -2
- infrahub/core/migrations/graph/m012_convert_account_generic.py +12 -23
- infrahub/core/migrations/graph/m013_convert_git_password_credential.py +7 -11
- infrahub/core/migrations/graph/m014_remove_index_attr_value.py +2 -2
- infrahub/core/migrations/graph/m015_diff_format_update.py +1 -1
- infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -1
- infrahub/core/migrations/graph/m017_add_core_profile.py +2 -6
- infrahub/core/migrations/graph/m018_uniqueness_nulls.py +3 -3
- infrahub/core/migrations/graph/m019_restore_rels_to_time.py +4 -4
- infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -3
- infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +51 -0
- infrahub/core/migrations/graph/m022_add_generate_template_attr.py +48 -0
- infrahub/core/migrations/query/attribute_add.py +3 -3
- infrahub/core/migrations/query/attribute_rename.py +1 -1
- infrahub/core/migrations/query/delete_element_in_schema.py +1 -1
- infrahub/core/migrations/query/node_duplicate.py +1 -1
- infrahub/core/migrations/query/relationship_duplicate.py +1 -1
- infrahub/core/migrations/query/schema_attribute_update.py +3 -3
- infrahub/core/migrations/schema/models.py +19 -4
- infrahub/core/migrations/schema/node_attribute_remove.py +1 -1
- infrahub/core/migrations/schema/node_remove.py +1 -1
- infrahub/core/migrations/schema/tasks.py +7 -7
- infrahub/core/migrations/shared.py +10 -12
- infrahub/core/models.py +13 -14
- infrahub/core/node/__init__.py +172 -57
- infrahub/core/node/base.py +3 -5
- infrahub/core/node/constraints/attribute_uniqueness.py +2 -2
- infrahub/core/node/constraints/grouped_uniqueness.py +5 -5
- infrahub/core/node/constraints/interface.py +1 -2
- infrahub/core/node/delete_validator.py +7 -9
- infrahub/core/node/ipam.py +10 -10
- infrahub/core/node/permissions.py +7 -7
- infrahub/core/node/resource_manager/ip_address_pool.py +6 -6
- infrahub/core/node/resource_manager/ip_prefix_pool.py +14 -11
- infrahub/core/node/resource_manager/number_pool.py +3 -3
- infrahub/core/node/standard.py +3 -5
- infrahub/core/path.py +12 -12
- infrahub/core/property.py +12 -12
- infrahub/core/protocols.py +11 -0
- infrahub/core/protocols_base.py +25 -23
- infrahub/core/query/__init__.py +35 -38
- infrahub/core/query/attribute.py +13 -13
- infrahub/core/query/branch.py +5 -5
- infrahub/core/query/delete.py +1 -1
- infrahub/core/query/diff.py +7 -7
- infrahub/core/query/ipam.py +4 -4
- infrahub/core/query/node.py +26 -24
- infrahub/core/query/relationship.py +143 -46
- infrahub/core/query/resource_manager.py +10 -10
- infrahub/core/query/standard_node.py +9 -9
- infrahub/core/query/subquery.py +9 -9
- infrahub/core/query/task.py +3 -3
- infrahub/core/query/task_log.py +1 -1
- infrahub/core/query/utils.py +5 -5
- infrahub/core/registry.py +13 -17
- infrahub/core/relationship/constraints/count.py +4 -5
- infrahub/core/relationship/constraints/peer_kind.py +4 -5
- infrahub/core/relationship/constraints/profiles_kind.py +2 -2
- infrahub/core/relationship/model.py +103 -67
- infrahub/core/schema/__init__.py +6 -4
- infrahub/core/schema/attribute_schema.py +16 -8
- infrahub/core/schema/basenode_schema.py +38 -26
- infrahub/core/schema/computed_attribute.py +3 -3
- infrahub/core/schema/definitions/core/__init__.py +147 -0
- infrahub/core/schema/definitions/core/account.py +171 -0
- infrahub/core/schema/definitions/core/artifact.py +136 -0
- infrahub/core/schema/definitions/core/builtin.py +24 -0
- infrahub/core/schema/definitions/core/check.py +68 -0
- infrahub/core/schema/definitions/core/core.py +17 -0
- infrahub/core/schema/definitions/core/generator.py +100 -0
- infrahub/core/schema/definitions/core/graphql_query.py +79 -0
- infrahub/core/schema/definitions/core/group.py +108 -0
- infrahub/core/schema/definitions/core/ipam.py +193 -0
- infrahub/core/schema/definitions/core/lineage.py +19 -0
- infrahub/core/schema/definitions/core/menu.py +48 -0
- infrahub/core/schema/definitions/core/permission.py +163 -0
- infrahub/core/schema/definitions/core/profile.py +18 -0
- infrahub/core/schema/definitions/core/propose_change.py +97 -0
- infrahub/core/schema/definitions/core/propose_change_comment.py +193 -0
- infrahub/core/schema/definitions/core/propose_change_validator.py +328 -0
- infrahub/core/schema/definitions/core/repository.py +286 -0
- infrahub/core/schema/definitions/core/resource_pool.py +170 -0
- infrahub/core/schema/definitions/core/template.py +27 -0
- infrahub/core/schema/definitions/core/transform.py +96 -0
- infrahub/core/schema/definitions/core/webhook.py +134 -0
- infrahub/core/schema/definitions/internal.py +32 -16
- infrahub/core/schema/dropdown.py +3 -4
- infrahub/core/schema/generated/attribute_schema.py +15 -18
- infrahub/core/schema/generated/base_node_schema.py +12 -14
- infrahub/core/schema/generated/genericnode_schema.py +5 -0
- infrahub/core/schema/generated/node_schema.py +8 -5
- infrahub/core/schema/generated/relationship_schema.py +9 -11
- infrahub/core/schema/generic_schema.py +6 -2
- infrahub/core/schema/manager.py +46 -43
- infrahub/core/schema/node_schema.py +6 -2
- infrahub/core/schema/profile_schema.py +4 -0
- infrahub/core/schema/relationship_schema.py +15 -7
- infrahub/core/schema/schema_branch.py +423 -89
- infrahub/core/schema/schema_branch_computed.py +41 -4
- infrahub/core/schema/template_schema.py +36 -0
- infrahub/core/task/task.py +3 -3
- infrahub/core/task/user_task.py +21 -19
- infrahub/core/timestamp.py +3 -3
- infrahub/core/utils.py +12 -12
- infrahub/core/validators/__init__.py +1 -3
- infrahub/core/validators/aggregated_checker.py +2 -2
- infrahub/core/validators/attribute/choices.py +3 -3
- infrahub/core/validators/attribute/enum.py +3 -3
- infrahub/core/validators/attribute/kind.py +3 -3
- infrahub/core/validators/attribute/length.py +3 -3
- infrahub/core/validators/attribute/optional.py +3 -3
- infrahub/core/validators/attribute/regex.py +3 -3
- infrahub/core/validators/attribute/unique.py +3 -3
- infrahub/core/validators/checks_runner.py +60 -0
- infrahub/core/validators/determiner.py +1 -3
- infrahub/core/validators/model.py +1 -3
- infrahub/core/validators/models/validate_migration.py +17 -4
- infrahub/core/validators/node/attribute.py +2 -2
- infrahub/core/validators/node/generate_profile.py +3 -3
- infrahub/core/validators/node/hierarchy.py +3 -3
- infrahub/core/validators/node/inherit_from.py +2 -2
- infrahub/core/validators/node/relationship.py +2 -2
- infrahub/core/validators/query.py +1 -1
- infrahub/core/validators/relationship/count.py +5 -5
- infrahub/core/validators/relationship/optional.py +3 -3
- infrahub/core/validators/relationship/peer.py +3 -3
- infrahub/core/validators/shared.py +2 -2
- infrahub/core/validators/tasks.py +8 -6
- infrahub/core/validators/uniqueness/checker.py +5 -6
- infrahub/core/validators/uniqueness/index.py +2 -2
- infrahub/core/validators/uniqueness/model.py +11 -11
- infrahub/core/validators/uniqueness/query.py +1 -1
- infrahub/database/__init__.py +28 -24
- infrahub/database/memgraph.py +1 -1
- infrahub/database/metrics.py +7 -1
- infrahub/dependencies/builder/diff/combiner.py +1 -1
- infrahub/dependencies/builder/diff/conflicts_enricher.py +1 -1
- infrahub/dependencies/builder/diff/deserializer.py +1 -1
- infrahub/dependencies/builder/diff/enricher/summary_counts.py +8 -0
- infrahub/dependencies/builder/diff/parent_node_adder.py +1 -1
- infrahub/dependencies/component/registry.py +2 -2
- infrahub/events/__init__.py +25 -2
- infrahub/events/artifact_action.py +64 -0
- infrahub/events/branch_action.py +57 -20
- infrahub/events/generator.py +71 -0
- infrahub/events/group_action.py +103 -0
- infrahub/events/models.py +160 -53
- infrahub/events/node_action.py +140 -23
- infrahub/events/repository_action.py +7 -20
- infrahub/events/schema_action.py +18 -10
- infrahub/events/utils.py +16 -0
- infrahub/events/validator_action.py +55 -0
- infrahub/exceptions.py +12 -3
- infrahub/generators/models.py +2 -3
- infrahub/generators/tasks.py +34 -15
- infrahub/git/base.py +10 -12
- infrahub/git/constants.py +0 -1
- infrahub/git/integrator.py +82 -57
- infrahub/git/models.py +101 -9
- infrahub/git/repository.py +9 -10
- infrahub/git/tasks.py +450 -112
- infrahub/git/utils.py +48 -0
- infrahub/git/worktree.py +1 -2
- infrahub/git_credential/askpass.py +1 -2
- infrahub/git_credential/helper.py +2 -3
- infrahub/graphql/analyzer.py +572 -11
- infrahub/graphql/app.py +47 -41
- infrahub/graphql/auth/query_permission_checker/anonymous_checker.py +5 -5
- infrahub/graphql/auth/query_permission_checker/default_branch_checker.py +4 -4
- infrahub/graphql/auth/query_permission_checker/merge_operation_checker.py +4 -4
- infrahub/graphql/auth/query_permission_checker/object_permission_checker.py +28 -35
- infrahub/graphql/auth/query_permission_checker/super_admin_checker.py +5 -5
- infrahub/graphql/context.py +39 -0
- infrahub/graphql/enums.py +1 -1
- infrahub/graphql/initialization.py +8 -1
- infrahub/graphql/loaders/node.py +3 -13
- infrahub/graphql/loaders/peers.py +77 -0
- infrahub/graphql/loaders/shared.py +13 -0
- infrahub/graphql/manager.py +75 -72
- infrahub/graphql/mutations/account.py +20 -13
- infrahub/graphql/mutations/artifact_definition.py +18 -14
- infrahub/graphql/mutations/branch.py +86 -40
- infrahub/graphql/mutations/computed_attribute.py +26 -18
- infrahub/graphql/mutations/diff.py +17 -8
- infrahub/graphql/mutations/diff_conflict.py +14 -8
- infrahub/graphql/mutations/generator.py +83 -0
- infrahub/graphql/mutations/graphql_query.py +21 -13
- infrahub/graphql/mutations/ipam.py +41 -39
- infrahub/graphql/mutations/main.py +226 -66
- infrahub/graphql/mutations/menu.py +12 -12
- infrahub/graphql/mutations/models.py +2 -4
- infrahub/graphql/mutations/node_getter/by_default_filter.py +1 -3
- infrahub/graphql/mutations/node_getter/by_hfid.py +1 -3
- infrahub/graphql/mutations/node_getter/by_id.py +1 -3
- infrahub/graphql/mutations/node_getter/interface.py +1 -2
- infrahub/graphql/mutations/proposed_change.py +39 -31
- infrahub/graphql/mutations/relationship.py +372 -129
- infrahub/graphql/mutations/repository.py +46 -40
- infrahub/graphql/mutations/resource_manager.py +26 -26
- infrahub/graphql/mutations/schema.py +70 -37
- infrahub/graphql/mutations/tasks.py +10 -7
- infrahub/graphql/mutations/webhook.py +137 -0
- infrahub/graphql/parser.py +5 -5
- infrahub/graphql/permissions.py +3 -10
- infrahub/graphql/queries/account.py +22 -18
- infrahub/graphql/queries/branch.py +6 -4
- infrahub/graphql/queries/diff/tree.py +67 -56
- infrahub/graphql/queries/event.py +115 -0
- infrahub/graphql/queries/internal.py +3 -3
- infrahub/graphql/queries/ipam.py +25 -20
- infrahub/graphql/queries/relationship.py +13 -12
- infrahub/graphql/queries/resource_manager.py +37 -25
- infrahub/graphql/queries/search.py +11 -10
- infrahub/graphql/queries/status.py +12 -9
- infrahub/graphql/queries/task.py +11 -9
- infrahub/graphql/resolvers/many_relationship.py +264 -0
- infrahub/graphql/resolvers/resolver.py +60 -139
- infrahub/graphql/resolvers/single_relationship.py +16 -10
- infrahub/graphql/schema.py +4 -0
- infrahub/graphql/subscription/__init__.py +1 -1
- infrahub/graphql/subscription/events.py +1 -1
- infrahub/graphql/subscription/graphql_query.py +10 -8
- infrahub/graphql/types/branch.py +2 -2
- infrahub/graphql/types/common.py +6 -1
- infrahub/graphql/types/context.py +12 -0
- infrahub/graphql/types/enums.py +2 -0
- infrahub/graphql/types/event.py +167 -0
- infrahub/graphql/types/interface.py +2 -2
- infrahub/graphql/types/node.py +5 -5
- infrahub/graphql/types/permission.py +2 -2
- infrahub/graphql/types/relationship.py +3 -3
- infrahub/graphql/types/standard_node.py +9 -11
- infrahub/graphql/utils.py +30 -184
- infrahub/groups/ancestors.py +29 -0
- infrahub/groups/parsers.py +107 -0
- infrahub/groups/tasks.py +2 -3
- infrahub/lock.py +21 -21
- infrahub/menu/generator.py +7 -8
- infrahub/menu/menu.py +107 -139
- infrahub/menu/models.py +121 -20
- infrahub/menu/repository.py +111 -0
- infrahub/menu/utils.py +5 -8
- infrahub/message_bus/__init__.py +11 -13
- infrahub/message_bus/messages/__init__.py +1 -25
- infrahub/message_bus/messages/check_generator_run.py +3 -3
- infrahub/message_bus/messages/event_branch_merge.py +3 -0
- infrahub/message_bus/messages/finalize_validator_execution.py +3 -0
- infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +6 -0
- infrahub/message_bus/messages/request_generatordefinition_check.py +2 -0
- infrahub/message_bus/messages/request_proposedchange_pipeline.py +2 -0
- infrahub/message_bus/messages/send_echo_request.py +1 -1
- infrahub/message_bus/operations/__init__.py +4 -15
- infrahub/message_bus/operations/check/__init__.py +2 -2
- infrahub/message_bus/operations/check/generator.py +2 -3
- infrahub/message_bus/operations/event/__init__.py +2 -2
- infrahub/message_bus/operations/event/branch.py +7 -3
- infrahub/message_bus/operations/event/worker.py +0 -3
- infrahub/message_bus/operations/finalize/validator.py +52 -2
- infrahub/message_bus/operations/git/file.py +2 -2
- infrahub/message_bus/operations/git/repository.py +1 -1
- infrahub/message_bus/operations/requests/__init__.py +0 -4
- infrahub/message_bus/operations/requests/generator_definition.py +22 -24
- infrahub/message_bus/operations/requests/proposed_change.py +39 -20
- infrahub/message_bus/operations/send/echo.py +1 -1
- infrahub/message_bus/types.py +1 -1
- infrahub/permissions/globals.py +15 -0
- infrahub/pools/number.py +2 -4
- infrahub/pools/prefix.py +29 -165
- infrahub/prefect_server/__init__.py +0 -0
- infrahub/prefect_server/app.py +18 -0
- infrahub/prefect_server/database.py +20 -0
- infrahub/prefect_server/events.py +28 -0
- infrahub/prefect_server/models.py +46 -0
- infrahub/proposed_change/models.py +18 -1
- infrahub/proposed_change/tasks.py +204 -53
- infrahub/pytest_plugin.py +13 -10
- infrahub/server.py +13 -12
- infrahub/services/__init__.py +148 -63
- infrahub/services/adapters/cache/__init__.py +11 -11
- infrahub/services/adapters/cache/nats.py +42 -25
- infrahub/services/adapters/cache/redis.py +3 -11
- infrahub/services/adapters/event/__init__.py +11 -19
- infrahub/services/adapters/http/__init__.py +0 -5
- infrahub/services/adapters/http/httpx.py +22 -15
- infrahub/services/adapters/message_bus/__init__.py +25 -8
- infrahub/services/adapters/message_bus/local.py +9 -7
- infrahub/services/adapters/message_bus/nats.py +14 -8
- infrahub/services/adapters/message_bus/rabbitmq.py +23 -10
- infrahub/services/adapters/workflow/__init__.py +11 -8
- infrahub/services/adapters/workflow/local.py +27 -6
- infrahub/services/adapters/workflow/worker.py +23 -7
- infrahub/services/component.py +43 -40
- infrahub/services/protocols.py +7 -7
- infrahub/services/scheduler.py +30 -29
- infrahub/storage.py +2 -4
- infrahub/task_manager/constants.py +1 -1
- infrahub/task_manager/event.py +275 -0
- infrahub/task_manager/models.py +147 -3
- infrahub/task_manager/task.py +1 -1
- infrahub/tasks/artifact.py +20 -21
- infrahub/tasks/registry.py +1 -1
- infrahub/telemetry/__init__.py +0 -0
- infrahub/telemetry/constants.py +9 -0
- infrahub/telemetry/database.py +86 -0
- infrahub/telemetry/models.py +65 -0
- infrahub/telemetry/task_manager.py +77 -0
- infrahub/telemetry/tasks.py +119 -0
- infrahub/telemetry/utils.py +11 -0
- infrahub/transformations/tasks.py +5 -7
- infrahub/trigger/__init__.py +0 -0
- infrahub/trigger/catalogue.py +13 -0
- infrahub/trigger/constants.py +1 -0
- infrahub/trigger/models.py +118 -0
- infrahub/trigger/setup.py +90 -0
- infrahub/trigger/tasks.py +36 -0
- infrahub/types.py +1 -1
- infrahub/utils.py +12 -2
- infrahub/validators/__init__.py +0 -0
- infrahub/validators/events.py +42 -0
- infrahub/validators/tasks.py +41 -0
- infrahub/webhook/gather.py +17 -0
- infrahub/webhook/models.py +180 -42
- infrahub/webhook/tasks.py +149 -203
- infrahub/webhook/triggers.py +44 -0
- infrahub/workers/infrahub_async.py +38 -27
- infrahub/workers/utils.py +63 -0
- infrahub/workflows/catalogue.py +98 -71
- infrahub/workflows/initialization.py +12 -8
- infrahub/workflows/models.py +29 -5
- infrahub/workflows/utils.py +11 -2
- infrahub_sdk/client.py +19 -0
- infrahub_sdk/context.py +13 -0
- infrahub_sdk/ctl/branch.py +3 -2
- infrahub_sdk/ctl/utils.py +0 -16
- infrahub_sdk/exceptions.py +6 -0
- infrahub_sdk/generator.py +3 -0
- infrahub_sdk/graphql.py +45 -13
- infrahub_sdk/node.py +66 -20
- infrahub_sdk/protocols.py +21 -8
- infrahub_sdk/protocols_base.py +32 -11
- infrahub_sdk/schema/__init__.py +14 -2
- infrahub_sdk/schema/main.py +7 -0
- infrahub_sdk/task/__init__.py +11 -0
- infrahub_sdk/task/constants.py +3 -0
- infrahub_sdk/task/exceptions.py +25 -0
- infrahub_sdk/task/manager.py +551 -0
- infrahub_sdk/task/models.py +74 -0
- infrahub_sdk/timestamp.py +142 -33
- infrahub_sdk/utils.py +29 -1
- {infrahub_server-1.1.8.dist-info → infrahub_server-1.2.0.dist-info}/METADATA +8 -6
- infrahub_server-1.2.0.dist-info/RECORD +746 -0
- infrahub_testcontainers/container.py +14 -4
- infrahub_testcontainers/docker-compose.test.yml +5 -8
- infrahub_testcontainers/helpers.py +5 -1
- infrahub/core/branch/constants.py +0 -2
- infrahub/core/schema/definitions/core.py +0 -2275
- infrahub/graphql/query.py +0 -52
- infrahub/message_bus/messages/check_repository_checkdefinition.py +0 -20
- infrahub/message_bus/messages/check_repository_mergeconflicts.py +0 -16
- infrahub/message_bus/messages/check_repository_usercheck.py +0 -26
- infrahub/message_bus/messages/event_branch_create.py +0 -11
- infrahub/message_bus/messages/event_branch_delete.py +0 -11
- infrahub/message_bus/messages/event_branch_rebased.py +0 -9
- infrahub/message_bus/messages/event_node_mutated.py +0 -15
- infrahub/message_bus/messages/event_schema_update.py +0 -9
- infrahub/message_bus/messages/request_artifactdefinition_check.py +0 -17
- infrahub/message_bus/messages/request_repository_checks.py +0 -12
- infrahub/message_bus/messages/request_repository_userchecks.py +0 -18
- infrahub/message_bus/operations/check/repository.py +0 -293
- infrahub/message_bus/operations/event/node.py +0 -20
- infrahub/message_bus/operations/event/schema.py +0 -17
- infrahub/message_bus/operations/requests/artifact_definition.py +0 -148
- infrahub/message_bus/operations/requests/repository.py +0 -133
- infrahub/schema/constants.py +0 -1
- infrahub/schema/tasks.py +0 -76
- infrahub/services/adapters/database/__init__.py +0 -9
- infrahub/tasks/telemetry.py +0 -127
- infrahub/webhook/constants.py +0 -3
- infrahub_server-1.1.8.dist-info/RECORD +0 -684
- /infrahub/{schema → artifacts}/__init__.py +0 -0
- {infrahub_server-1.1.8.dist-info → infrahub_server-1.2.0.dist-info}/LICENSE.txt +0 -0
- {infrahub_server-1.1.8.dist-info → infrahub_server-1.2.0.dist-info}/WHEEL +0 -0
- {infrahub_server-1.1.8.dist-info → infrahub_server-1.2.0.dist-info}/entry_points.txt +0 -0
infrahub/menu/models.py
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
6
|
+
from pydantic import BaseModel, Field, computed_field
|
|
7
7
|
from typing_extensions import Self
|
|
8
8
|
|
|
9
9
|
from infrahub.core.account import GlobalPermission
|
|
10
10
|
from infrahub.core.node import Node
|
|
11
11
|
from infrahub.core.protocols import CoreMenuItem
|
|
12
|
-
from infrahub.core.schema import GenericSchema, MainSchemaTypes, NodeSchema, ProfileSchema
|
|
12
|
+
from infrahub.core.schema import GenericSchema, MainSchemaTypes, NodeSchema, ProfileSchema, TemplateSchema
|
|
13
13
|
|
|
14
14
|
from .constants import MenuSection
|
|
15
15
|
|
|
@@ -17,8 +17,8 @@ if TYPE_CHECKING:
|
|
|
17
17
|
from infrahub.database import InfrahubDatabase
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def get_full_name(obj: CoreMenuItem | NodeSchema | GenericSchema | ProfileSchema) -> str:
|
|
21
|
-
if isinstance(obj,
|
|
20
|
+
def get_full_name(obj: CoreMenuItem | NodeSchema | GenericSchema | ProfileSchema | TemplateSchema) -> str:
|
|
21
|
+
if isinstance(obj, NodeSchema | GenericSchema | ProfileSchema | TemplateSchema):
|
|
22
22
|
return _get_full_name_schema(obj)
|
|
23
23
|
return _get_full_name_node(obj)
|
|
24
24
|
|
|
@@ -35,21 +35,26 @@ def _get_full_name_schema(node: MainSchemaTypes) -> str:
|
|
|
35
35
|
class MenuDict:
|
|
36
36
|
data: dict[str, MenuItemDict] = field(default_factory=dict)
|
|
37
37
|
|
|
38
|
+
def get_item_location(self, name: str) -> list[str]:
|
|
39
|
+
location, _ = self._find_child_item(name=name, children=self.data)
|
|
40
|
+
return location
|
|
41
|
+
|
|
38
42
|
def find_item(self, name: str) -> MenuItemDict | None:
|
|
39
|
-
|
|
43
|
+
_, item = self._find_child_item(name=name, children=self.data)
|
|
44
|
+
return item
|
|
40
45
|
|
|
41
46
|
@classmethod
|
|
42
|
-
def _find_child_item(cls, name: str, children: dict[str, MenuItemDict]) -> MenuItemDict | None:
|
|
47
|
+
def _find_child_item(cls, name: str, children: dict[str, MenuItemDict]) -> tuple[list[str], MenuItemDict | None]:
|
|
43
48
|
if name in children.keys():
|
|
44
|
-
return children[name]
|
|
49
|
+
return [], children[name]
|
|
45
50
|
|
|
46
51
|
for child in children.values():
|
|
47
52
|
if not child.children:
|
|
48
53
|
continue
|
|
49
|
-
found = cls._find_child_item(name=name, children=child.children)
|
|
54
|
+
position, found = cls._find_child_item(name=name, children=child.children)
|
|
50
55
|
if found:
|
|
51
|
-
return found
|
|
52
|
-
return None
|
|
56
|
+
return [str(child.identifier)] + position, found
|
|
57
|
+
return [], None
|
|
53
58
|
|
|
54
59
|
def to_rest(self) -> Menu:
|
|
55
60
|
data: dict[str, list[MenuItemList]] = {}
|
|
@@ -62,10 +67,15 @@ class MenuDict:
|
|
|
62
67
|
|
|
63
68
|
return Menu(sections=data)
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
@classmethod
|
|
71
|
+
def from_definition_list(cls, definitions: list[MenuItemDefinition]) -> Self:
|
|
72
|
+
menu = cls()
|
|
73
|
+
for definition in definitions:
|
|
74
|
+
menu.data[definition.full_name] = MenuItemDict.from_definition(definition=definition)
|
|
75
|
+
return menu
|
|
76
|
+
|
|
77
|
+
def get_all_identifiers(self) -> set[str]:
|
|
78
|
+
return {identifier for item in self.data.values() for identifier in item.get_all_identifiers()}
|
|
69
79
|
|
|
70
80
|
|
|
71
81
|
@dataclass
|
|
@@ -74,7 +84,11 @@ class Menu:
|
|
|
74
84
|
|
|
75
85
|
|
|
76
86
|
class MenuItem(BaseModel):
|
|
77
|
-
|
|
87
|
+
id: str | None = None
|
|
88
|
+
namespace: str = Field(..., description="Namespace of the menu item")
|
|
89
|
+
name: str = Field(..., description="Name of the menu item")
|
|
90
|
+
description: str = Field(default="", description="Description of the menu item")
|
|
91
|
+
protected: bool = Field(default=False, description="Whether the menu item is protected")
|
|
78
92
|
label: str = Field(..., description="Title of the menu item")
|
|
79
93
|
path: str = Field(default="", description="URL endpoint if applicable")
|
|
80
94
|
icon: str = Field(default="", description="The icon to show for the current view")
|
|
@@ -83,10 +97,27 @@ class MenuItem(BaseModel):
|
|
|
83
97
|
section: MenuSection = MenuSection.OBJECT
|
|
84
98
|
permissions: list[str] = Field(default_factory=list)
|
|
85
99
|
|
|
100
|
+
@computed_field
|
|
101
|
+
def identifier(self) -> str:
|
|
102
|
+
return f"{self.namespace}{self.name}"
|
|
103
|
+
|
|
104
|
+
def get_path(self) -> str | None:
|
|
105
|
+
if self.path:
|
|
106
|
+
return self.path
|
|
107
|
+
|
|
108
|
+
if self.kind:
|
|
109
|
+
return f"/objects/{self.kind}"
|
|
110
|
+
|
|
111
|
+
return None
|
|
112
|
+
|
|
86
113
|
@classmethod
|
|
87
114
|
def from_node(cls, obj: CoreMenuItem) -> Self:
|
|
88
115
|
return cls(
|
|
89
|
-
|
|
116
|
+
id=obj.get_id(),
|
|
117
|
+
name=obj.name.value,
|
|
118
|
+
namespace=obj.namespace.value,
|
|
119
|
+
protected=obj.protected.value,
|
|
120
|
+
description=obj.description.value or "",
|
|
90
121
|
label=obj.label.value or "",
|
|
91
122
|
icon=obj.icon.value or "",
|
|
92
123
|
order_weight=obj.order_weight.value,
|
|
@@ -96,10 +127,30 @@ class MenuItem(BaseModel):
|
|
|
96
127
|
permissions=obj.required_permissions.value or [],
|
|
97
128
|
)
|
|
98
129
|
|
|
130
|
+
async def to_node(self, db: InfrahubDatabase, parent: CoreMenuItem | None = None) -> CoreMenuItem:
|
|
131
|
+
obj = await Node.init(db=db, schema=CoreMenuItem)
|
|
132
|
+
await obj.new(
|
|
133
|
+
db=db,
|
|
134
|
+
namespace=self.namespace,
|
|
135
|
+
name=self.name,
|
|
136
|
+
label=self.label,
|
|
137
|
+
kind=self.kind,
|
|
138
|
+
path=self.get_path(),
|
|
139
|
+
description=self.description or None,
|
|
140
|
+
icon=self.icon or None,
|
|
141
|
+
protected=self.protected,
|
|
142
|
+
section=self.section.value,
|
|
143
|
+
order_weight=self.order_weight,
|
|
144
|
+
parent=parent.id if parent else None,
|
|
145
|
+
required_permissions=self.permissions,
|
|
146
|
+
)
|
|
147
|
+
return obj
|
|
148
|
+
|
|
99
149
|
@classmethod
|
|
100
|
-
def from_schema(cls, model: NodeSchema | GenericSchema | ProfileSchema) -> Self:
|
|
150
|
+
def from_schema(cls, model: NodeSchema | GenericSchema | ProfileSchema | TemplateSchema) -> Self:
|
|
101
151
|
return cls(
|
|
102
|
-
|
|
152
|
+
name=model.name,
|
|
153
|
+
namespace=model.namespace,
|
|
103
154
|
label=model.label or model.kind,
|
|
104
155
|
path=f"/objects/{model.kind}",
|
|
105
156
|
icon=model.icon or "",
|
|
@@ -111,8 +162,14 @@ class MenuItemDict(MenuItem):
|
|
|
111
162
|
hidden: bool = False
|
|
112
163
|
children: dict[str, MenuItemDict] = Field(default_factory=dict, description="Child objects")
|
|
113
164
|
|
|
165
|
+
def get_all_identifiers(self) -> set[str]:
|
|
166
|
+
identifiers: set[str] = {str(self.identifier)}
|
|
167
|
+
for child in self.children.values():
|
|
168
|
+
identifiers.update(child.get_all_identifiers())
|
|
169
|
+
return identifiers
|
|
170
|
+
|
|
114
171
|
def to_list(self) -> MenuItemList:
|
|
115
|
-
data = self.model_dump(exclude={"children"})
|
|
172
|
+
data = self.model_dump(exclude={"children", "id"})
|
|
116
173
|
unsorted_children = [child.to_list() for child in self.children.values() if child.hidden is False]
|
|
117
174
|
data["children"] = sorted(unsorted_children, key=lambda d: d.order_weight)
|
|
118
175
|
return MenuItemList(**data)
|
|
@@ -125,6 +182,35 @@ class MenuItemDict(MenuItem):
|
|
|
125
182
|
permissions.append(GlobalPermission.from_string(input=permission))
|
|
126
183
|
return permissions
|
|
127
184
|
|
|
185
|
+
def diff_attributes(self, other: Self) -> dict[str, Any]:
|
|
186
|
+
other_attributes = other.model_dump(exclude={"children"})
|
|
187
|
+
self_attributes = self.model_dump(exclude={"children"})
|
|
188
|
+
return {
|
|
189
|
+
key: value
|
|
190
|
+
for key, value in other_attributes.items()
|
|
191
|
+
if value != self_attributes[key] and key not in ["id", "children"]
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@classmethod
|
|
195
|
+
def from_definition(cls, definition: MenuItemDefinition) -> Self:
|
|
196
|
+
menu_item = cls(
|
|
197
|
+
name=definition.name,
|
|
198
|
+
namespace=definition.namespace,
|
|
199
|
+
label=definition.label,
|
|
200
|
+
path=definition.get_path() or "",
|
|
201
|
+
icon=definition.icon,
|
|
202
|
+
kind=definition.kind,
|
|
203
|
+
protected=definition.protected,
|
|
204
|
+
section=definition.section,
|
|
205
|
+
permissions=definition.permissions,
|
|
206
|
+
order_weight=definition.order_weight,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
for child in definition.children:
|
|
210
|
+
menu_item.children[child.full_name] = MenuItemDict.from_definition(definition=child)
|
|
211
|
+
|
|
212
|
+
return menu_item
|
|
213
|
+
|
|
128
214
|
|
|
129
215
|
class MenuItemList(MenuItem):
|
|
130
216
|
children: list[MenuItemList] = Field(default_factory=list, description="Child objects")
|
|
@@ -162,6 +248,21 @@ class MenuItemDefinition(BaseModel):
|
|
|
162
248
|
)
|
|
163
249
|
return obj
|
|
164
250
|
|
|
251
|
+
@classmethod
|
|
252
|
+
async def from_node(cls, node: CoreMenuItem) -> Self:
|
|
253
|
+
return cls(
|
|
254
|
+
namespace=node.namespace.value,
|
|
255
|
+
name=node.name.value,
|
|
256
|
+
label=node.label.value or "",
|
|
257
|
+
description=node.description.value or "",
|
|
258
|
+
icon=node.icon.value or "",
|
|
259
|
+
protected=node.protected.value,
|
|
260
|
+
path=node.path.value or "",
|
|
261
|
+
kind=node.kind.value or "",
|
|
262
|
+
section=node.section.value,
|
|
263
|
+
order_weight=node.order_weight.value,
|
|
264
|
+
)
|
|
265
|
+
|
|
165
266
|
def get_path(self) -> str | None:
|
|
166
267
|
if self.path:
|
|
167
268
|
return self.path
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from infrahub.core.manager import NodeManager
|
|
2
|
+
from infrahub.core.protocols import CoreMenuItem
|
|
3
|
+
from infrahub.database import InfrahubDatabase
|
|
4
|
+
|
|
5
|
+
from .models import MenuDict, MenuItemDefinition, MenuItemDict
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MenuRepository:
|
|
9
|
+
def __init__(self, db: InfrahubDatabase):
|
|
10
|
+
self.db = db
|
|
11
|
+
|
|
12
|
+
async def get_menu(self, nodes: dict[str, CoreMenuItem] | None = None) -> MenuDict:
|
|
13
|
+
menu_nodes = nodes or await self.get_menu_db()
|
|
14
|
+
return await self._convert_menu_from_db(nodes=menu_nodes)
|
|
15
|
+
|
|
16
|
+
async def _convert_menu_from_db(self, nodes: dict[str, CoreMenuItem]) -> MenuDict:
|
|
17
|
+
menu = MenuDict()
|
|
18
|
+
menu_by_ids = {menu_node.get_id(): MenuItemDict.from_node(menu_node) for menu_node in nodes.values()}
|
|
19
|
+
|
|
20
|
+
async def add_children(menu_item: MenuItemDict, menu_node: CoreMenuItem) -> MenuItemDict:
|
|
21
|
+
children = await menu_node.children.get_peers(db=self.db, peer_type=CoreMenuItem)
|
|
22
|
+
for child_id, child_node in children.items():
|
|
23
|
+
child_menu_item = menu_by_ids[child_id]
|
|
24
|
+
child = await add_children(child_menu_item, child_node)
|
|
25
|
+
menu_item.children[str(child.identifier)] = child
|
|
26
|
+
return menu_item
|
|
27
|
+
|
|
28
|
+
for menu_node in nodes.values():
|
|
29
|
+
menu_item = menu_by_ids[menu_node.get_id()]
|
|
30
|
+
parent = await menu_node.parent.get_peer(db=self.db, peer_type=CoreMenuItem)
|
|
31
|
+
if parent:
|
|
32
|
+
continue
|
|
33
|
+
|
|
34
|
+
children = await menu_node.children.get_peers(db=self.db, peer_type=CoreMenuItem)
|
|
35
|
+
for child_id, child_node in children.items():
|
|
36
|
+
child_menu_item = menu_by_ids[child_id]
|
|
37
|
+
child = await add_children(child_menu_item, child_node)
|
|
38
|
+
menu_item.children[str(child.identifier)] = child
|
|
39
|
+
|
|
40
|
+
menu.data[str(menu_item.identifier)] = menu_item
|
|
41
|
+
|
|
42
|
+
return menu
|
|
43
|
+
|
|
44
|
+
async def get_menu_db(self) -> dict[str, CoreMenuItem]:
|
|
45
|
+
menu_nodes = await NodeManager.query(
|
|
46
|
+
schema=CoreMenuItem,
|
|
47
|
+
filters={"namespace__value": "Builtin"},
|
|
48
|
+
prefetch_relationships=True,
|
|
49
|
+
db=self.db,
|
|
50
|
+
)
|
|
51
|
+
return {node.get_id(): node for node in menu_nodes}
|
|
52
|
+
|
|
53
|
+
async def create_menu(self, menu: list[MenuItemDefinition]) -> None:
|
|
54
|
+
for item in menu:
|
|
55
|
+
obj = await item.to_node(db=self.db)
|
|
56
|
+
await obj.save(db=self.db)
|
|
57
|
+
if item.children:
|
|
58
|
+
await self.create_menu_children(parent=obj, children=item.children)
|
|
59
|
+
|
|
60
|
+
async def create_menu_children(self, parent: CoreMenuItem, children: list[MenuItemDefinition]) -> None:
|
|
61
|
+
for child in children:
|
|
62
|
+
obj = await child.to_node(db=self.db, parent=parent)
|
|
63
|
+
await obj.save(db=self.db)
|
|
64
|
+
if child.children:
|
|
65
|
+
await self.create_menu_children(parent=obj, children=child.children)
|
|
66
|
+
|
|
67
|
+
async def update_menu(
|
|
68
|
+
self, existing_menu: MenuDict, new_menu: MenuDict, menu_nodes: dict[str, CoreMenuItem]
|
|
69
|
+
) -> None:
|
|
70
|
+
async def process_menu_item(menu_item: MenuItemDict, parent: CoreMenuItem | None) -> None:
|
|
71
|
+
existing_item = existing_menu.find_item(name=str(menu_item.identifier))
|
|
72
|
+
if existing_item and existing_item.id:
|
|
73
|
+
node = menu_nodes[existing_item.id]
|
|
74
|
+
await self.update_menu_item(
|
|
75
|
+
node=node, existing_menu_item=existing_item, new_menu_item=menu_item, parent=parent
|
|
76
|
+
)
|
|
77
|
+
else:
|
|
78
|
+
node = await self.create_menu_item(new_menu_item=menu_item, parent=parent)
|
|
79
|
+
|
|
80
|
+
for child_item in menu_item.children.values():
|
|
81
|
+
await process_menu_item(menu_item=child_item, parent=node)
|
|
82
|
+
|
|
83
|
+
for top_level_item in new_menu.data.values():
|
|
84
|
+
await process_menu_item(menu_item=top_level_item, parent=None)
|
|
85
|
+
|
|
86
|
+
# Delete items that are not in the new menu
|
|
87
|
+
menu_to_delete = existing_menu.get_all_identifiers() - new_menu.get_all_identifiers()
|
|
88
|
+
for item_to_delete in menu_to_delete:
|
|
89
|
+
existing_item = existing_menu.find_item(name=item_to_delete)
|
|
90
|
+
if existing_item and existing_item.id:
|
|
91
|
+
node = menu_nodes[existing_item.id]
|
|
92
|
+
await node.delete(db=self.db)
|
|
93
|
+
|
|
94
|
+
async def update_menu_item(
|
|
95
|
+
self,
|
|
96
|
+
node: CoreMenuItem,
|
|
97
|
+
existing_menu_item: MenuItemDict,
|
|
98
|
+
new_menu_item: MenuItemDict,
|
|
99
|
+
parent: CoreMenuItem | None,
|
|
100
|
+
) -> None:
|
|
101
|
+
attrs_to_update = existing_menu_item.diff_attributes(new_menu_item)
|
|
102
|
+
for attr_name, value in attrs_to_update.items():
|
|
103
|
+
attr = getattr(node, attr_name)
|
|
104
|
+
attr.value = value
|
|
105
|
+
await node.parent.update(data=parent, db=self.db) # type: ignore[arg-type]
|
|
106
|
+
await node.save(db=self.db)
|
|
107
|
+
|
|
108
|
+
async def create_menu_item(self, new_menu_item: MenuItemDict, parent: CoreMenuItem | None) -> CoreMenuItem:
|
|
109
|
+
obj = await new_menu_item.to_node(db=self.db, parent=parent)
|
|
110
|
+
await obj.save(db=self.db)
|
|
111
|
+
return obj
|
infrahub/menu/utils.py
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
from infrahub.core.protocols import CoreMenuItem
|
|
2
1
|
from infrahub.database import InfrahubDatabase
|
|
3
2
|
|
|
4
|
-
from .
|
|
3
|
+
from .menu import default_menu
|
|
4
|
+
from .repository import MenuRepository
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
async def
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
await obj.save(db=db)
|
|
11
|
-
if child.children:
|
|
12
|
-
await create_menu_children(db=db, parent=obj, children=child.children)
|
|
7
|
+
async def create_default_menu(db: InfrahubDatabase) -> None:
|
|
8
|
+
repository = MenuRepository(db=db)
|
|
9
|
+
await repository.create_menu(menu=default_menu)
|
infrahub/message_bus/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Any
|
|
3
|
+
from typing import Any
|
|
4
4
|
|
|
5
5
|
from pydantic import BaseModel, Field
|
|
6
6
|
|
|
@@ -11,21 +11,19 @@ from infrahub.log import set_log_data
|
|
|
11
11
|
|
|
12
12
|
class Meta(BaseModel):
|
|
13
13
|
request_id: str = ""
|
|
14
|
-
correlation_id:
|
|
15
|
-
reply_to:
|
|
16
|
-
initiator_id:
|
|
14
|
+
correlation_id: str | None = Field(default=None)
|
|
15
|
+
reply_to: str | None = Field(default=None)
|
|
16
|
+
initiator_id: str | None = Field(
|
|
17
17
|
default=None, description="The worker identity of the initial sender of this message"
|
|
18
18
|
)
|
|
19
|
-
retry_count:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
headers: Optional[dict[str, Any]] = Field(default=None)
|
|
23
|
-
validator_execution_id: Optional[str] = Field(
|
|
19
|
+
retry_count: int | None = Field(default=None, description="Indicates how many times this message has been retried.")
|
|
20
|
+
headers: dict[str, Any] | None = Field(default=None)
|
|
21
|
+
validator_execution_id: str | None = Field(
|
|
24
22
|
default=None, description="Validator execution ID related to this message"
|
|
25
23
|
)
|
|
26
|
-
check_execution_id:
|
|
24
|
+
check_execution_id: str | None = Field(default=None, description="Check execution ID related to this message")
|
|
27
25
|
priority: int = Field(default=3, description="Message Priority")
|
|
28
|
-
expiration:
|
|
26
|
+
expiration: int | None = Field(default=None, description="TTL before this message expires in seconds")
|
|
29
27
|
|
|
30
28
|
@classmethod
|
|
31
29
|
def default(cls) -> Meta:
|
|
@@ -89,9 +87,9 @@ class InfrahubResponse(InfrahubMessage):
|
|
|
89
87
|
|
|
90
88
|
passed: bool = True
|
|
91
89
|
routing_key: str
|
|
92
|
-
data:
|
|
90
|
+
data: dict | InfrahubResponseData = Field(default_factory=dict) # type: ignore[arg-type]
|
|
93
91
|
errors: list[str] = Field(default_factory=list)
|
|
94
|
-
initial_message:
|
|
92
|
+
initial_message: dict | None = Field(
|
|
95
93
|
default=None,
|
|
96
94
|
description="Initial message in dict format, the primary goal of this field is to provide additional context when there is an error",
|
|
97
95
|
)
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
from infrahub.message_bus import InfrahubMessage, InfrahubResponse
|
|
2
2
|
|
|
3
|
-
from .check_artifact_create import CheckArtifactCreate
|
|
4
3
|
from .check_generator_run import CheckGeneratorRun
|
|
5
|
-
from .check_repository_checkdefinition import CheckRepositoryCheckDefinition
|
|
6
|
-
from .check_repository_mergeconflicts import CheckRepositoryMergeConflicts
|
|
7
|
-
from .check_repository_usercheck import CheckRepositoryUserCheck
|
|
8
|
-
from .event_branch_create import EventBranchCreate
|
|
9
|
-
from .event_branch_delete import EventBranchDelete
|
|
10
4
|
from .event_branch_merge import EventBranchMerge
|
|
11
|
-
from .event_branch_rebased import EventBranchRebased
|
|
12
|
-
from .event_node_mutated import EventNodeMutated
|
|
13
|
-
from .event_schema_update import EventSchemaUpdate
|
|
14
5
|
from .event_worker_newprimaryapi import EventWorkerNewPrimaryAPI
|
|
15
6
|
from .finalize_validator_execution import FinalizeValidatorExecution
|
|
16
7
|
from .git_file_get import GitFileGet, GitFileGetResponse
|
|
@@ -19,25 +10,13 @@ from .proposed_change.request_proposedchange_refreshartifacts import RequestProp
|
|
|
19
10
|
from .refresh_git_fetch import RefreshGitFetch
|
|
20
11
|
from .refresh_registry_branches import RefreshRegistryBranches
|
|
21
12
|
from .refresh_registry_rebasedbranch import RefreshRegistryRebasedBranch
|
|
22
|
-
from .request_artifactdefinition_check import RequestArtifactDefinitionCheck
|
|
23
13
|
from .request_generatordefinition_check import RequestGeneratorDefinitionCheck
|
|
24
14
|
from .request_proposedchange_pipeline import RequestProposedChangePipeline
|
|
25
|
-
from .request_repository_checks import RequestRepositoryChecks
|
|
26
|
-
from .request_repository_userchecks import RequestRepositoryUserChecks
|
|
27
15
|
from .send_echo_request import SendEchoRequest, SendEchoRequestResponse
|
|
28
16
|
|
|
29
17
|
MESSAGE_MAP: dict[str, type[InfrahubMessage]] = {
|
|
30
|
-
"check.artifact.create": CheckArtifactCreate,
|
|
31
18
|
"check.generator.run": CheckGeneratorRun,
|
|
32
|
-
"check.repository.check_definition": CheckRepositoryCheckDefinition,
|
|
33
|
-
"check.repository.merge_conflicts": CheckRepositoryMergeConflicts,
|
|
34
|
-
"check.repository.user_check": CheckRepositoryUserCheck,
|
|
35
|
-
"event.branch.create": EventBranchCreate,
|
|
36
|
-
"event.branch.delete": EventBranchDelete,
|
|
37
19
|
"event.branch.merge": EventBranchMerge,
|
|
38
|
-
"event.branch.rebased": EventBranchRebased,
|
|
39
|
-
"event.node.mutated": EventNodeMutated,
|
|
40
|
-
"event.schema.update": EventSchemaUpdate,
|
|
41
20
|
"event.worker.new_primary_api": EventWorkerNewPrimaryAPI,
|
|
42
21
|
"finalize.validator.execution": FinalizeValidatorExecution,
|
|
43
22
|
"git.file.get": GitFileGet,
|
|
@@ -45,12 +24,9 @@ MESSAGE_MAP: dict[str, type[InfrahubMessage]] = {
|
|
|
45
24
|
"refresh.git.fetch": RefreshGitFetch,
|
|
46
25
|
"refresh.registry.branches": RefreshRegistryBranches,
|
|
47
26
|
"refresh.registry.rebased_branch": RefreshRegistryRebasedBranch,
|
|
48
|
-
"request.artifact_definition.check": RequestArtifactDefinitionCheck,
|
|
49
27
|
"request.generator_definition.check": RequestGeneratorDefinitionCheck,
|
|
50
28
|
"request.proposed_change.pipeline": RequestProposedChangePipeline,
|
|
51
29
|
"request.proposed_change.refresh_artifacts": RequestProposedChangeRefreshArtifacts,
|
|
52
|
-
"request.repository.checks": RequestRepositoryChecks,
|
|
53
|
-
"request.repository.user_checks": RequestRepositoryUserChecks,
|
|
54
30
|
"send.echo.request": SendEchoRequest,
|
|
55
31
|
}
|
|
56
32
|
|
|
@@ -63,7 +39,7 @@ PRIORITY_MAP = {
|
|
|
63
39
|
"check.artifact.create": 2,
|
|
64
40
|
"check.repository.check_definition": 2,
|
|
65
41
|
"check.repository.merge_conflicts": 2,
|
|
66
|
-
"
|
|
42
|
+
"send.echo.request": 5, # Currently only for testing purposes, will be removed once all message bus have been migrated to prefect
|
|
67
43
|
"event.branch.delete": 5,
|
|
68
44
|
"event.branch.merge": 5,
|
|
69
45
|
"event.schema.update": 5,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from pydantic import Field
|
|
4
2
|
|
|
3
|
+
from infrahub.context import InfrahubContext
|
|
5
4
|
from infrahub.generators.models import ProposedChangeGeneratorDefinition
|
|
6
5
|
from infrahub.message_bus import InfrahubMessage
|
|
7
6
|
|
|
@@ -10,7 +9,7 @@ class CheckGeneratorRun(InfrahubMessage):
|
|
|
10
9
|
"""A check that runs a generator."""
|
|
11
10
|
|
|
12
11
|
generator_definition: ProposedChangeGeneratorDefinition = Field(..., description="The Generator definition")
|
|
13
|
-
generator_instance:
|
|
12
|
+
generator_instance: str | None = Field(
|
|
14
13
|
default=None, description="The id of the generator instance if it previously existed"
|
|
15
14
|
)
|
|
16
15
|
commit: str = Field(..., description="The commit to target")
|
|
@@ -24,3 +23,4 @@ class CheckGeneratorRun(InfrahubMessage):
|
|
|
24
23
|
variables: dict = Field(..., description="Input variables when running the generator")
|
|
25
24
|
validator_id: str = Field(..., description="The ID of the validator")
|
|
26
25
|
proposed_change: str | None = Field(None, description="The unique ID of the Proposed Change")
|
|
26
|
+
context: InfrahubContext = Field(..., description="The Infrahub context")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pydantic import Field
|
|
2
2
|
|
|
3
|
+
from infrahub.context import InfrahubContext
|
|
3
4
|
from infrahub.message_bus import InfrahubMessage
|
|
4
5
|
|
|
5
6
|
|
|
@@ -8,3 +9,5 @@ class EventBranchMerge(InfrahubMessage):
|
|
|
8
9
|
|
|
9
10
|
source_branch: str = Field(..., description="The source branch")
|
|
10
11
|
target_branch: str = Field(..., description="The target branch")
|
|
12
|
+
|
|
13
|
+
context: InfrahubContext = Field(..., description="The context of the event")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pydantic import Field
|
|
2
2
|
|
|
3
|
+
from infrahub.context import InfrahubContext
|
|
3
4
|
from infrahub.message_bus import InfrahubMessage
|
|
4
5
|
|
|
5
6
|
|
|
@@ -10,3 +11,5 @@ class FinalizeValidatorExecution(InfrahubMessage):
|
|
|
10
11
|
validator_execution_id: str = Field(..., description="The id of current execution of the associated validator")
|
|
11
12
|
start_time: str = Field(..., description="Start time when the message was first created")
|
|
12
13
|
validator_type: str = Field(..., description="The type of validator to complete")
|
|
14
|
+
context: InfrahubContext = Field(..., description="The Infrahub context")
|
|
15
|
+
proposed_change: str = Field(..., description="The ID of the proposed change")
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
|
|
3
|
+
from infrahub.context import InfrahubContext
|
|
4
|
+
|
|
1
5
|
from .base_with_diff import BaseProposedChangeWithDiffMessage
|
|
2
6
|
|
|
3
7
|
|
|
4
8
|
class RequestProposedChangeRefreshArtifacts(BaseProposedChangeWithDiffMessage):
|
|
5
9
|
"""Sent trigger the refresh of artifacts that are impacted by the proposed change."""
|
|
10
|
+
|
|
11
|
+
context: InfrahubContext = Field(..., description="The context of the task")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pydantic import ConfigDict, Field
|
|
2
2
|
|
|
3
|
+
from infrahub.context import InfrahubContext
|
|
3
4
|
from infrahub.generators.models import ProposedChangeGeneratorDefinition
|
|
4
5
|
from infrahub.message_bus import InfrahubMessage
|
|
5
6
|
from infrahub.message_bus.types import ProposedChangeBranchDiff
|
|
@@ -16,3 +17,4 @@ class RequestGeneratorDefinitionCheck(InfrahubMessage):
|
|
|
16
17
|
source_branch: str = Field(..., description="The source branch")
|
|
17
18
|
source_branch_sync_with_git: bool = Field(..., description="Indicates if the source branch should sync with git")
|
|
18
19
|
destination_branch: str = Field(..., description="The target branch")
|
|
20
|
+
context: InfrahubContext = Field(..., description="The Infrahub context")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pydantic import Field
|
|
2
2
|
|
|
3
|
+
from infrahub.context import InfrahubContext
|
|
3
4
|
from infrahub.core.constants import CheckType
|
|
4
5
|
from infrahub.message_bus import InfrahubMessage
|
|
5
6
|
|
|
@@ -14,3 +15,4 @@ class RequestProposedChangePipeline(InfrahubMessage):
|
|
|
14
15
|
check_type: CheckType = Field(
|
|
15
16
|
default=CheckType.ALL, description="Can be used to restrict the pipeline to a specific type of job"
|
|
16
17
|
)
|
|
18
|
+
context: InfrahubContext = Field(..., description="The context of the task")
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
import ujson
|
|
4
2
|
from prefect import Flow
|
|
5
3
|
|
|
@@ -18,14 +16,8 @@ from infrahub.services import InfrahubServices
|
|
|
18
16
|
from infrahub.tasks.check import set_check_status
|
|
19
17
|
|
|
20
18
|
COMMAND_MAP = {
|
|
21
|
-
"check.artifact.create": check.artifact.create,
|
|
22
19
|
"check.generator.run": check.generator.run,
|
|
23
|
-
"check.repository.check_definition": check.repository.check_definition,
|
|
24
|
-
"check.repository.merge_conflicts": check.repository.merge_conflicts,
|
|
25
|
-
"check.repository.user_check": check.repository.user_check,
|
|
26
20
|
"event.branch.merge": event.branch.merge,
|
|
27
|
-
"event.node.mutated": event.node.mutated,
|
|
28
|
-
"event.schema.update": event.schema.update,
|
|
29
21
|
"event.worker.new_primary_api": event.worker.new_primary_api,
|
|
30
22
|
"finalize.validator.execution": finalize.validator.execution,
|
|
31
23
|
"git.file.get": git.file.get,
|
|
@@ -34,18 +26,15 @@ COMMAND_MAP = {
|
|
|
34
26
|
"refresh.registry.branches": refresh.registry.branches,
|
|
35
27
|
"refresh.registry.rebased_branch": refresh.registry.rebased_branch,
|
|
36
28
|
"request.generator_definition.check": requests.generator_definition.check,
|
|
37
|
-
"request.artifact_definition.check": requests.artifact_definition.check,
|
|
38
29
|
"request.proposed_change.pipeline": requests.proposed_change.pipeline,
|
|
39
30
|
"request.proposed_change.refresh_artifacts": requests.proposed_change.refresh_artifacts,
|
|
40
|
-
"request.repository.checks": requests.repository.checks,
|
|
41
|
-
"request.repository.user_checks": requests.repository.user_checks,
|
|
42
31
|
"send.echo.request": send.echo.request,
|
|
43
32
|
}
|
|
44
33
|
|
|
45
34
|
|
|
46
35
|
async def execute_message(
|
|
47
36
|
routing_key: str, message_body: bytes, service: InfrahubServices, skip_flow: bool = False
|
|
48
|
-
) ->
|
|
37
|
+
) -> MessageTTL | None:
|
|
49
38
|
message_data = ujson.loads(message_body)
|
|
50
39
|
message = messages.MESSAGE_MAP[routing_key](**message_data)
|
|
51
40
|
message.set_log_data(routing_key=routing_key)
|
|
@@ -54,15 +43,15 @@ async def execute_message(
|
|
|
54
43
|
if skip_flow and isinstance(func, Flow):
|
|
55
44
|
func = func.fn
|
|
56
45
|
await func(message=message, service=service)
|
|
57
|
-
except Exception as exc:
|
|
46
|
+
except Exception as exc:
|
|
58
47
|
if message.reply_requested:
|
|
59
48
|
response = RPCErrorResponse(errors=[str(exc)], initial_message=message.model_dump())
|
|
60
|
-
await service.
|
|
49
|
+
await service.message_bus.reply_if_initiator_meta(message=response, initiator=message)
|
|
61
50
|
return None
|
|
62
51
|
if message.reached_max_retries:
|
|
63
52
|
service.log.exception("Message failed after maximum number of retries", error=exc)
|
|
64
53
|
await set_check_status(message, conclusion="failure", service=service)
|
|
65
54
|
return None
|
|
66
55
|
message.increase_retry_count()
|
|
67
|
-
await service.send(message, delay=MessageTTL.FIVE, is_retry=True)
|
|
56
|
+
await service.message_bus.send(message, delay=MessageTTL.FIVE, is_retry=True)
|
|
68
57
|
return MessageTTL.FIVE
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from . import
|
|
1
|
+
from . import generator
|
|
2
2
|
|
|
3
|
-
__all__ = ["
|
|
3
|
+
__all__ = ["generator"]
|
|
@@ -14,8 +14,6 @@ from infrahub.services import InfrahubServices
|
|
|
14
14
|
from infrahub.tasks.check import set_check_status
|
|
15
15
|
from infrahub.workflows.utils import add_tags
|
|
16
16
|
|
|
17
|
-
# pylint: disable=duplicate-code
|
|
18
|
-
|
|
19
17
|
|
|
20
18
|
@flow(
|
|
21
19
|
name="git-repository-check-generator-run",
|
|
@@ -74,6 +72,7 @@ async def run(message: messages.CheckGeneratorRun, service: InfrahubServices) ->
|
|
|
74
72
|
convert_query_response=generator_definition.convert_query_response,
|
|
75
73
|
infrahub_node=InfrahubNode,
|
|
76
74
|
)
|
|
75
|
+
generator._init_client.request_context = message.context.to_request_context()
|
|
77
76
|
await generator.run(identifier=generator_definition.name)
|
|
78
77
|
generator_instance.status.value = GeneratorInstanceStatus.READY.value
|
|
79
78
|
except ModuleImportError as exc:
|
|
@@ -81,7 +80,7 @@ async def run(message: messages.CheckGeneratorRun, service: InfrahubServices) ->
|
|
|
81
80
|
generator_instance.status.value = GeneratorInstanceStatus.ERROR.value
|
|
82
81
|
check_message = f"Failed to import generator: {exc.message}"
|
|
83
82
|
log.exception(check_message, exc_info=exc)
|
|
84
|
-
except Exception as exc:
|
|
83
|
+
except Exception as exc:
|
|
85
84
|
conclusion = ValidatorConclusion.FAILURE
|
|
86
85
|
generator_instance.status.value = GeneratorInstanceStatus.ERROR.value
|
|
87
86
|
check_message = f"Failed to execute generator: {str(exc)}"
|