infrahub-server 1.1.7__py3-none-any.whl → 1.2.0b1__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 +8 -0
- infrahub/api/oauth2.py +0 -1
- infrahub/api/oidc.py +0 -1
- infrahub/api/query.py +18 -7
- infrahub/api/schema.py +32 -6
- infrahub/api/transformation.py +12 -5
- infrahub/{message_bus/messages/check_artifact_create.py → artifacts/models.py} +5 -3
- infrahub/{message_bus/operations/check/artifact.py → artifacts/tasks.py} +26 -25
- infrahub/cli/__init__.py +0 -2
- infrahub/cli/db.py +6 -7
- infrahub/cli/events.py +8 -3
- infrahub/cli/git_agent.py +9 -7
- infrahub/cli/tasks.py +4 -6
- infrahub/computed_attribute/models.py +1 -1
- infrahub/computed_attribute/tasks.py +64 -17
- infrahub/computed_attribute/triggers.py +90 -0
- infrahub/config.py +1 -1
- infrahub/context.py +39 -0
- infrahub/core/account.py +5 -8
- infrahub/core/attribute.py +50 -21
- infrahub/core/branch/models.py +4 -4
- infrahub/core/branch/tasks.py +130 -125
- infrahub/core/changelog/__init__.py +0 -0
- infrahub/core/changelog/diff.py +283 -0
- infrahub/core/changelog/models.py +499 -0
- infrahub/core/constants/__init__.py +43 -2
- infrahub/core/constants/infrahubkind.py +1 -0
- infrahub/core/constants/schema.py +2 -0
- infrahub/core/diff/combiner.py +1 -1
- infrahub/core/diff/enricher/cardinality_one.py +6 -1
- infrahub/core/diff/enricher/hierarchy.py +22 -7
- infrahub/core/diff/enricher/labels.py +6 -1
- infrahub/core/diff/enricher/path_identifier.py +5 -1
- infrahub/core/diff/enricher/summary_counts.py +107 -0
- infrahub/core/diff/merger/merger.py +3 -1
- infrahub/core/diff/model/path.py +34 -11
- infrahub/core/diff/parent_node_adder.py +78 -0
- infrahub/core/diff/payload_builder.py +13 -2
- 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 +3 -3
- 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 +191 -185
- infrahub/core/diff/query/summary_counts_enricher.py +52 -5
- infrahub/core/diff/query/time_range_query.py +1 -1
- infrahub/core/diff/query/update_conflict_query.py +1 -1
- infrahub/core/diff/repository/deserializer.py +9 -4
- infrahub/core/diff/repository/repository.py +156 -38
- infrahub/core/diff/tasks.py +13 -12
- infrahub/core/enums.py +1 -1
- infrahub/core/graph/__init__.py +1 -1
- infrahub/core/graph/index.py +3 -0
- infrahub/core/integrity/object_conflict/conflict_recorder.py +1 -1
- infrahub/core/ipam/reconciler.py +1 -1
- infrahub/core/ipam/tasks.py +2 -3
- infrahub/core/manager.py +20 -15
- infrahub/core/merge.py +5 -2
- infrahub/core/migrations/graph/__init__.py +4 -0
- 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 +1 -1
- infrahub/core/migrations/graph/m018_uniqueness_nulls.py +2 -2
- infrahub/core/migrations/graph/m019_restore_rels_to_time.py +256 -0
- infrahub/core/migrations/graph/m020_add_generate_template_attr.py +48 -0
- infrahub/core/migrations/query/attribute_add.py +1 -1
- 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 +39 -19
- infrahub/core/migrations/query/relationship_duplicate.py +1 -1
- infrahub/core/migrations/query/schema_attribute_update.py +1 -1
- infrahub/core/migrations/schema/node_attribute_remove.py +1 -1
- infrahub/core/migrations/schema/node_remove.py +27 -13
- infrahub/core/migrations/schema/tasks.py +5 -5
- infrahub/core/migrations/shared.py +4 -4
- infrahub/core/models.py +7 -8
- infrahub/core/node/__init__.py +164 -45
- infrahub/core/node/base.py +1 -1
- infrahub/core/node/delete_validator.py +4 -4
- infrahub/core/node/ipam.py +7 -7
- infrahub/core/node/resource_manager/ip_prefix_pool.py +8 -5
- infrahub/core/node/standard.py +3 -5
- infrahub/core/property.py +1 -1
- infrahub/core/protocols.py +6 -0
- infrahub/core/protocols_base.py +4 -2
- infrahub/core/query/__init__.py +2 -5
- infrahub/core/query/attribute.py +9 -9
- infrahub/core/query/branch.py +5 -5
- infrahub/core/query/delete.py +1 -1
- infrahub/core/query/diff.py +4 -4
- infrahub/core/query/ipam.py +4 -4
- infrahub/core/query/node.py +11 -12
- infrahub/core/query/relationship.py +211 -25
- infrahub/core/query/resource_manager.py +10 -10
- infrahub/core/query/standard_node.py +6 -6
- 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 +0 -2
- infrahub/core/relationship/constraints/count.py +1 -1
- infrahub/core/relationship/constraints/peer_kind.py +1 -1
- infrahub/core/relationship/model.py +76 -38
- infrahub/core/schema/__init__.py +6 -4
- infrahub/core/schema/attribute_schema.py +8 -0
- infrahub/core/schema/basenode_schema.py +13 -3
- infrahub/core/schema/definitions/core/__init__.py +153 -0
- infrahub/core/schema/definitions/core/account.py +168 -0
- infrahub/core/schema/definitions/core/artifact.py +127 -0
- infrahub/core/schema/definitions/core/builtin.py +21 -0
- infrahub/core/schema/definitions/core/check.py +60 -0
- infrahub/core/schema/definitions/core/generator.py +96 -0
- infrahub/core/schema/definitions/core/graphql_query.py +77 -0
- infrahub/core/schema/definitions/core/group.py +105 -0
- infrahub/core/schema/definitions/core/ipam.py +252 -0
- infrahub/core/schema/definitions/core/lineage.py +17 -0
- infrahub/core/schema/definitions/core/menu.py +46 -0
- infrahub/core/schema/definitions/core/permission.py +161 -0
- infrahub/core/schema/definitions/core/profile.py +29 -0
- infrahub/core/schema/definitions/core/propose_change.py +88 -0
- infrahub/core/schema/definitions/core/propose_change_comment.py +188 -0
- infrahub/core/schema/definitions/core/propose_change_validator.py +326 -0
- infrahub/core/schema/definitions/core/repository.py +280 -0
- infrahub/core/schema/definitions/core/resource_pool.py +180 -0
- infrahub/core/schema/definitions/core/template.py +12 -0
- infrahub/core/schema/definitions/core/transform.py +87 -0
- infrahub/core/schema/definitions/core/webhook.py +108 -0
- infrahub/core/schema/definitions/internal.py +16 -0
- infrahub/core/schema/generated/genericnode_schema.py +5 -0
- infrahub/core/schema/generated/node_schema.py +5 -0
- infrahub/core/schema/generic_schema.py +5 -1
- infrahub/core/schema/manager.py +45 -42
- infrahub/core/schema/node_schema.py +4 -0
- infrahub/core/schema/profile_schema.py +4 -0
- infrahub/core/schema/relationship_schema.py +10 -2
- infrahub/core/schema/schema_branch.py +260 -16
- infrahub/core/schema/template_schema.py +36 -0
- infrahub/core/task/user_task.py +7 -5
- infrahub/core/timestamp.py +3 -3
- infrahub/core/utils.py +2 -2
- infrahub/core/validators/attribute/choices.py +1 -1
- infrahub/core/validators/attribute/enum.py +1 -1
- infrahub/core/validators/attribute/kind.py +1 -1
- infrahub/core/validators/attribute/length.py +1 -1
- infrahub/core/validators/attribute/optional.py +1 -1
- infrahub/core/validators/attribute/regex.py +1 -1
- infrahub/core/validators/attribute/unique.py +1 -1
- infrahub/core/validators/checks_runner.py +37 -0
- infrahub/core/validators/node/generate_profile.py +1 -1
- infrahub/core/validators/node/hierarchy.py +1 -1
- infrahub/core/validators/query.py +1 -1
- infrahub/core/validators/relationship/count.py +1 -1
- infrahub/core/validators/relationship/optional.py +1 -1
- infrahub/core/validators/relationship/peer.py +1 -1
- infrahub/core/validators/tasks.py +8 -6
- infrahub/core/validators/uniqueness/query.py +1 -1
- infrahub/database/__init__.py +3 -2
- infrahub/database/memgraph.py +1 -1
- infrahub/dependencies/builder/diff/combiner.py +1 -1
- infrahub/dependencies/builder/diff/conflicts_enricher.py +1 -1
- infrahub/dependencies/builder/diff/deserializer.py +4 -2
- infrahub/dependencies/builder/diff/enricher/hierarchy.py +3 -1
- infrahub/dependencies/builder/diff/enricher/summary_counts.py +8 -0
- infrahub/dependencies/builder/diff/parent_node_adder.py +8 -0
- infrahub/events/artifact_action.py +76 -0
- infrahub/events/branch_action.py +50 -21
- infrahub/events/group_action.py +117 -0
- infrahub/events/models.py +164 -51
- infrahub/events/node_action.py +70 -8
- infrahub/events/repository_action.py +8 -8
- infrahub/events/schema_action.py +21 -8
- infrahub/exceptions.py +9 -0
- infrahub/generators/models.py +1 -0
- infrahub/generators/tasks.py +34 -15
- infrahub/git/base.py +3 -5
- infrahub/git/constants.py +0 -1
- infrahub/git/integrator.py +60 -36
- infrahub/git/models.py +80 -1
- infrahub/git/repository.py +7 -8
- infrahub/git/tasks.py +432 -112
- infrahub/git_credential/helper.py +2 -3
- infrahub/graphql/analyzer.py +572 -11
- infrahub/graphql/app.py +34 -26
- 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 +33 -0
- infrahub/graphql/enums.py +1 -1
- infrahub/graphql/initialization.py +5 -1
- infrahub/graphql/loaders/node.py +2 -2
- infrahub/graphql/manager.py +63 -63
- infrahub/graphql/mutations/account.py +20 -13
- infrahub/graphql/mutations/artifact_definition.py +16 -12
- infrahub/graphql/mutations/branch.py +86 -40
- infrahub/graphql/mutations/computed_attribute.py +24 -15
- infrahub/graphql/mutations/diff.py +33 -17
- infrahub/graphql/mutations/diff_conflict.py +14 -8
- infrahub/graphql/mutations/generator.py +83 -0
- infrahub/graphql/mutations/graphql_query.py +19 -11
- infrahub/graphql/mutations/ipam.py +25 -23
- infrahub/graphql/mutations/main.py +233 -45
- infrahub/graphql/mutations/menu.py +10 -10
- infrahub/graphql/mutations/proposed_change.py +36 -28
- infrahub/graphql/mutations/relationship.py +341 -130
- infrahub/graphql/mutations/repository.py +41 -35
- infrahub/graphql/mutations/resource_manager.py +26 -26
- infrahub/graphql/mutations/schema.py +66 -33
- infrahub/graphql/mutations/tasks.py +10 -7
- infrahub/graphql/parser.py +1 -1
- 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 +63 -52
- infrahub/graphql/queries/event.py +115 -0
- infrahub/graphql/queries/internal.py +3 -3
- infrahub/graphql/queries/ipam.py +23 -18
- infrahub/graphql/queries/relationship.py +11 -10
- infrahub/graphql/queries/resource_manager.py +37 -25
- infrahub/graphql/queries/search.py +9 -8
- infrahub/graphql/queries/status.py +12 -9
- infrahub/graphql/queries/task.py +11 -9
- infrahub/graphql/resolvers/resolver.py +69 -43
- 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 +8 -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 +158 -0
- infrahub/graphql/types/interface.py +2 -2
- infrahub/graphql/types/node.py +3 -3
- 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 +28 -182
- infrahub/groups/tasks.py +2 -3
- infrahub/lock.py +21 -21
- infrahub/menu/generator.py +0 -1
- infrahub/menu/menu.py +116 -138
- infrahub/menu/models.py +4 -4
- infrahub/message_bus/__init__.py +11 -13
- infrahub/message_bus/messages/__init__.py +0 -14
- infrahub/message_bus/messages/check_generator_run.py +1 -3
- infrahub/message_bus/messages/event_branch_merge.py +3 -0
- infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +6 -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 -13
- infrahub/message_bus/operations/check/__init__.py +2 -2
- infrahub/message_bus/operations/check/generator.py +1 -3
- infrahub/message_bus/operations/event/branch.py +7 -3
- infrahub/message_bus/operations/event/schema.py +1 -1
- infrahub/message_bus/operations/event/worker.py +0 -3
- infrahub/message_bus/operations/finalize/validator.py +1 -1
- 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 +2 -4
- infrahub/message_bus/operations/requests/proposed_change.py +37 -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/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 +195 -53
- infrahub/pytest_plugin.py +4 -4
- 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 +10 -18
- 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 +261 -0
- infrahub/task_manager/models.py +147 -3
- infrahub/task_manager/task.py +1 -1
- infrahub/tasks/artifact.py +19 -18
- infrahub/tasks/registry.py +1 -1
- infrahub/tasks/telemetry.py +13 -14
- infrahub/transformations/tasks.py +3 -5
- infrahub/trigger/__init__.py +0 -0
- infrahub/trigger/catalogue.py +16 -0
- infrahub/trigger/constants.py +9 -0
- infrahub/trigger/models.py +105 -0
- infrahub/trigger/tasks.py +91 -0
- infrahub/types.py +1 -1
- infrahub/utils.py +1 -1
- infrahub/webhook/constants.py +0 -2
- infrahub/webhook/models.py +161 -40
- infrahub/webhook/tasks.py +123 -202
- infrahub/webhook/triggers.py +27 -0
- infrahub/workers/infrahub_async.py +36 -25
- infrahub/workers/utils.py +63 -0
- infrahub/workflows/catalogue.py +71 -52
- infrahub/workflows/initialization.py +14 -8
- infrahub/workflows/models.py +28 -4
- infrahub/workflows/utils.py +1 -1
- infrahub_sdk/batch.py +2 -2
- infrahub_sdk/client.py +8 -0
- infrahub_sdk/config.py +1 -1
- infrahub_sdk/ctl/branch.py +3 -2
- infrahub_sdk/ctl/check.py +4 -4
- infrahub_sdk/ctl/cli_commands.py +16 -11
- infrahub_sdk/ctl/exceptions.py +0 -6
- infrahub_sdk/ctl/exporter.py +1 -1
- infrahub_sdk/ctl/generator.py +5 -5
- infrahub_sdk/ctl/importer.py +3 -2
- infrahub_sdk/ctl/menu.py +1 -1
- infrahub_sdk/ctl/object.py +1 -1
- infrahub_sdk/ctl/repository.py +23 -15
- infrahub_sdk/ctl/schema.py +2 -2
- infrahub_sdk/ctl/utils.py +6 -21
- infrahub_sdk/ctl/validate.py +2 -1
- infrahub_sdk/data.py +1 -1
- infrahub_sdk/exceptions.py +12 -0
- infrahub_sdk/generator.py +3 -0
- infrahub_sdk/node.py +5 -8
- infrahub_sdk/protocols.py +20 -8
- infrahub_sdk/schema/__init__.py +14 -5
- infrahub_sdk/schema/main.py +7 -0
- infrahub_sdk/task/__init__.py +1 -0
- infrahub_sdk/task/constants.py +3 -0
- infrahub_sdk/task/exceptions.py +25 -0
- infrahub_sdk/task/manager.py +545 -0
- infrahub_sdk/task/models.py +74 -0
- infrahub_sdk/testing/docker.py +30 -0
- infrahub_sdk/timestamp.py +134 -33
- infrahub_sdk/transfer/exporter/json.py +1 -1
- infrahub_sdk/utils.py +39 -1
- infrahub_sdk/yaml.py +2 -3
- {infrahub_server-1.1.7.dist-info → infrahub_server-1.2.0b1.dist-info}/METADATA +7 -6
- {infrahub_server-1.1.7.dist-info → infrahub_server-1.2.0b1.dist-info}/RECORD +383 -339
- infrahub_testcontainers/container.py +2 -3
- infrahub_testcontainers/docker-compose.test.yml +2 -2
- infrahub/core/branch/constants.py +0 -2
- infrahub/core/schema/definitions/core.py +0 -2274
- 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/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/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_sdk/ctl/_file.py +0 -13
- /infrahub/{schema → artifacts}/__init__.py +0 -0
- {infrahub_server-1.1.7.dist-info → infrahub_server-1.2.0b1.dist-info}/LICENSE.txt +0 -0
- {infrahub_server-1.1.7.dist-info → infrahub_server-1.2.0b1.dist-info}/WHEEL +0 -0
- {infrahub_server-1.1.7.dist-info → infrahub_server-1.2.0b1.dist-info}/entry_points.txt +0 -0
infrahub/workflows/catalogue.py
CHANGED
|
@@ -5,12 +5,6 @@ from .models import WorkerPoolDefinition, WorkflowDefinition
|
|
|
5
5
|
|
|
6
6
|
INFRAHUB_WORKER_POOL = WorkerPoolDefinition(name="infrahub-worker", description="Default Pool for internal tasks")
|
|
7
7
|
|
|
8
|
-
WEBHOOK_SEND = WorkflowDefinition(
|
|
9
|
-
name="event-send-webhook",
|
|
10
|
-
type=WorkflowType.USER,
|
|
11
|
-
module="infrahub.webhook.tasks",
|
|
12
|
-
function="send_webhook",
|
|
13
|
-
)
|
|
14
8
|
|
|
15
9
|
TRANSFORM_JINJA2_RENDER = WorkflowDefinition(
|
|
16
10
|
name="transform_render_jinja2_template",
|
|
@@ -319,27 +313,6 @@ REQUEST_PROPOSED_CHANGE_USER_TESTS = WorkflowDefinition(
|
|
|
319
313
|
function="run_proposed_change_user_tests",
|
|
320
314
|
)
|
|
321
315
|
|
|
322
|
-
AUTOMATION_BRANCH_ACTIONS = WorkflowDefinition(
|
|
323
|
-
name="branch-actions-setup",
|
|
324
|
-
type=WorkflowType.CORE,
|
|
325
|
-
module="infrahub.core.branch.tasks",
|
|
326
|
-
function="branch_actions_setup",
|
|
327
|
-
)
|
|
328
|
-
|
|
329
|
-
AUTOMATION_SCHEMA_UPDATED = WorkflowDefinition(
|
|
330
|
-
name="schema-updated-setup",
|
|
331
|
-
type=WorkflowType.CORE,
|
|
332
|
-
module="infrahub.schema.tasks",
|
|
333
|
-
function="schema_updated_setup",
|
|
334
|
-
)
|
|
335
|
-
|
|
336
|
-
AUTOMATION_GIT_UPDATED = WorkflowDefinition(
|
|
337
|
-
name="git-commit-automation-setup",
|
|
338
|
-
type=WorkflowType.CORE,
|
|
339
|
-
module="infrahub.git.tasks",
|
|
340
|
-
function="setup_commit_automation",
|
|
341
|
-
)
|
|
342
|
-
|
|
343
316
|
GIT_REPOSITORIES_DIFF_NAMES_ONLY = WorkflowDefinition(
|
|
344
317
|
name="git-repository-diff-names-only",
|
|
345
318
|
type=WorkflowType.INTERNAL,
|
|
@@ -370,25 +343,75 @@ REQUEST_PROPOSED_CHANGE_REPOSITORY_CHECKS = WorkflowDefinition(
|
|
|
370
343
|
function="repository_checks",
|
|
371
344
|
)
|
|
372
345
|
|
|
373
|
-
|
|
374
|
-
name="
|
|
346
|
+
REQUEST_ARTIFACT_DEFINITION_CHECK = WorkflowDefinition(
|
|
347
|
+
name="artifacts-generation-validation",
|
|
348
|
+
type=WorkflowType.INTERNAL,
|
|
349
|
+
module="infrahub.proposed_change.tasks",
|
|
350
|
+
function="validate_artifacts_generation",
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
WEBHOOK_PROCESS = WorkflowDefinition(
|
|
354
|
+
name="webhook-process",
|
|
375
355
|
type=WorkflowType.USER,
|
|
376
356
|
module="infrahub.webhook.tasks",
|
|
377
|
-
function="
|
|
357
|
+
function="webhook_process",
|
|
378
358
|
)
|
|
379
359
|
|
|
380
|
-
|
|
381
|
-
name="webhook-
|
|
382
|
-
type=WorkflowType.
|
|
360
|
+
WEBHOOK_CONFIGURE_ONE = WorkflowDefinition(
|
|
361
|
+
name="webhook-setup-automation-one",
|
|
362
|
+
type=WorkflowType.CORE,
|
|
383
363
|
module="infrahub.webhook.tasks",
|
|
384
|
-
function="
|
|
364
|
+
function="configure_webhook_one",
|
|
385
365
|
)
|
|
386
366
|
|
|
387
|
-
|
|
388
|
-
name="webhook-setup-
|
|
389
|
-
type=WorkflowType.
|
|
367
|
+
WEBHOOK_CONFIGURE_ALL = WorkflowDefinition(
|
|
368
|
+
name="webhook-setup-automation-all",
|
|
369
|
+
type=WorkflowType.CORE,
|
|
370
|
+
cron=f"{random.randint(0, 59)} 3 * * *",
|
|
390
371
|
module="infrahub.webhook.tasks",
|
|
391
|
-
function="
|
|
372
|
+
function="configure_webhook_all",
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
GIT_REPOSITORIES_CHECK_ARTIFACT_CREATE = WorkflowDefinition(
|
|
376
|
+
name="git-repository-check-artifact-create",
|
|
377
|
+
type=WorkflowType.USER,
|
|
378
|
+
module="infrahub.artifacts.tasks",
|
|
379
|
+
function="create",
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
GIT_REPOSITORY_USER_CHECKS_DEFINITIONS_TRIGGER = WorkflowDefinition(
|
|
383
|
+
name="git-repository-user-checks-definition-trigger",
|
|
384
|
+
type=WorkflowType.USER,
|
|
385
|
+
module="infrahub.git.tasks",
|
|
386
|
+
function="trigger_repository_user_checks_definitions",
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
GIT_REPOSITORY_USER_CHECK_RUN = WorkflowDefinition(
|
|
390
|
+
name="git-repository-run-user-check",
|
|
391
|
+
type=WorkflowType.USER,
|
|
392
|
+
module="infrahub.git.tasks",
|
|
393
|
+
function="run_user_check",
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
GIT_REPOSITORY_USER_CHECKS_TRIGGER = WorkflowDefinition(
|
|
397
|
+
name="git-repository-trigger-user-checks",
|
|
398
|
+
type=WorkflowType.USER,
|
|
399
|
+
module="infrahub.git.tasks",
|
|
400
|
+
function="trigger_user_checks",
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
GIT_REPOSITORY_INTERNAL_CHECKS_TRIGGER = WorkflowDefinition(
|
|
404
|
+
name="git-repository-trigger-internal-checks",
|
|
405
|
+
type=WorkflowType.USER,
|
|
406
|
+
module="infrahub.git.tasks",
|
|
407
|
+
function="trigger_internal_checks",
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
GIT_REPOSITORY_MERGE_CONFLICTS_CHECKS_RUN = WorkflowDefinition(
|
|
411
|
+
name="git-repository-check-merge-conflict",
|
|
412
|
+
type=WorkflowType.USER,
|
|
413
|
+
module="infrahub.git.tasks",
|
|
414
|
+
function="run_check_merge_conflicts",
|
|
392
415
|
)
|
|
393
416
|
|
|
394
417
|
|
|
@@ -396,10 +419,6 @@ worker_pools = [INFRAHUB_WORKER_POOL]
|
|
|
396
419
|
|
|
397
420
|
workflows = [
|
|
398
421
|
ANONYMOUS_TELEMETRY_SEND,
|
|
399
|
-
AUTOMATION_BRANCH_ACTIONS,
|
|
400
|
-
AUTOMATION_GIT_UPDATED,
|
|
401
|
-
AUTOMATION_SCHEMA_UPDATED,
|
|
402
|
-
AUTOMATION_SETUP_WEBHOOK_CONFIGURATION_TRIGGER,
|
|
403
422
|
BRANCH_CANCEL_PROPOSED_CHANGES,
|
|
404
423
|
BRANCH_CREATE,
|
|
405
424
|
BRANCH_DELETE,
|
|
@@ -413,6 +432,7 @@ workflows = [
|
|
|
413
432
|
DIFF_REFRESH,
|
|
414
433
|
DIFF_REFRESH_ALL,
|
|
415
434
|
DIFF_UPDATE,
|
|
435
|
+
GIT_REPOSITORIES_CHECK_ARTIFACT_CREATE,
|
|
416
436
|
GIT_REPOSITORIES_CREATE_BRANCH,
|
|
417
437
|
GIT_REPOSITORIES_DIFF_NAMES_ONLY,
|
|
418
438
|
GIT_REPOSITORIES_IMPORT_OBJECTS,
|
|
@@ -421,11 +441,17 @@ workflows = [
|
|
|
421
441
|
GIT_REPOSITORIES_SYNC,
|
|
422
442
|
GIT_REPOSITORY_ADD,
|
|
423
443
|
GIT_REPOSITORY_ADD_READ_ONLY,
|
|
444
|
+
GIT_REPOSITORY_INTERNAL_CHECKS_TRIGGER,
|
|
445
|
+
GIT_REPOSITORY_MERGE_CONFLICTS_CHECKS_RUN,
|
|
446
|
+
GIT_REPOSITORY_USER_CHECKS_DEFINITIONS_TRIGGER,
|
|
447
|
+
GIT_REPOSITORY_USER_CHECKS_TRIGGER,
|
|
448
|
+
GIT_REPOSITORY_USER_CHECK_RUN,
|
|
424
449
|
GRAPHQL_QUERY_GROUP_UPDATE,
|
|
425
450
|
IPAM_RECONCILIATION,
|
|
426
451
|
PROCESS_COMPUTED_MACRO,
|
|
427
452
|
PROPOSED_CHANGE_MERGE,
|
|
428
453
|
QUERY_COMPUTED_ATTRIBUTE_TRANSFORM_TARGETS,
|
|
454
|
+
REQUEST_ARTIFACT_DEFINITION_CHECK,
|
|
429
455
|
REQUEST_ARTIFACT_DEFINITION_GENERATE,
|
|
430
456
|
REQUEST_ARTIFACT_GENERATE,
|
|
431
457
|
REQUEST_GENERATOR_DEFINITION_RUN,
|
|
@@ -444,14 +470,7 @@ workflows = [
|
|
|
444
470
|
TRIGGER_UPDATE_JINJA_COMPUTED_ATTRIBUTES,
|
|
445
471
|
TRIGGER_UPDATE_PYTHON_COMPUTED_ATTRIBUTES,
|
|
446
472
|
UPDATE_COMPUTED_ATTRIBUTE_TRANSFORM,
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
]
|
|
451
|
-
|
|
452
|
-
automation_setup_workflows = [
|
|
453
|
-
AUTOMATION_BRANCH_ACTIONS,
|
|
454
|
-
AUTOMATION_GIT_UPDATED,
|
|
455
|
-
AUTOMATION_SCHEMA_UPDATED,
|
|
456
|
-
AUTOMATION_SETUP_WEBHOOK_CONFIGURATION_TRIGGER,
|
|
473
|
+
WEBHOOK_CONFIGURE_ALL,
|
|
474
|
+
WEBHOOK_CONFIGURE_ONE,
|
|
475
|
+
WEBHOOK_PROCESS,
|
|
457
476
|
]
|
|
@@ -7,12 +7,16 @@ from prefect.exceptions import ObjectAlreadyExists
|
|
|
7
7
|
from prefect.logging import get_run_logger
|
|
8
8
|
|
|
9
9
|
from infrahub import config
|
|
10
|
+
from infrahub.trigger.catalogue import builtin_triggers
|
|
11
|
+
from infrahub.trigger.constants import DEPRECATED_STATIC_TRIGGER_NAMES
|
|
12
|
+
from infrahub.trigger.models import TriggerType
|
|
13
|
+
from infrahub.trigger.tasks import setup_triggers
|
|
10
14
|
|
|
11
|
-
from .catalogue import
|
|
15
|
+
from .catalogue import worker_pools, workflows
|
|
12
16
|
from .models import TASK_RESULT_STORAGE_NAME
|
|
13
17
|
|
|
14
18
|
|
|
15
|
-
@task(name="task-manager-setup-worker-pools", task_run_name="Setup Worker pools", cache_policy=NONE)
|
|
19
|
+
@task(name="task-manager-setup-worker-pools", task_run_name="Setup Worker pools", cache_policy=NONE) # type: ignore[arg-type]
|
|
16
20
|
async def setup_worker_pools(client: PrefectClient) -> None:
|
|
17
21
|
log = get_run_logger()
|
|
18
22
|
for worker in worker_pools:
|
|
@@ -28,7 +32,7 @@ async def setup_worker_pools(client: PrefectClient) -> None:
|
|
|
28
32
|
log.warning(f"Work pool {worker.name} already present ")
|
|
29
33
|
|
|
30
34
|
|
|
31
|
-
@task(name="task-manager-setup-deployments", task_run_name="Setup Deployments", cache_policy=NONE)
|
|
35
|
+
@task(name="task-manager-setup-deployments", task_run_name="Setup Deployments", cache_policy=NONE) # type: ignore[arg-type]
|
|
32
36
|
async def setup_deployments(client: PrefectClient) -> None:
|
|
33
37
|
log = get_run_logger()
|
|
34
38
|
for workflow in workflows:
|
|
@@ -38,12 +42,8 @@ async def setup_deployments(client: PrefectClient) -> None:
|
|
|
38
42
|
await workflow.save(client=client, work_pool=work_pool)
|
|
39
43
|
log.info(f"Flow {workflow.name}, created successfully ... ")
|
|
40
44
|
|
|
41
|
-
for automation_setup_workflow in automation_setup_workflows:
|
|
42
|
-
automation_setup = automation_setup_workflow.get_function()
|
|
43
|
-
await automation_setup()
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
@task(name="task-manager-setup-blocks", task_run_name="Setup Blocks", cache_policy=NONE)
|
|
46
|
+
@task(name="task-manager-setup-blocks", task_run_name="Setup Blocks", cache_policy=NONE) # type: ignore[arg-type]
|
|
47
47
|
async def setup_blocks() -> None:
|
|
48
48
|
log = get_run_logger()
|
|
49
49
|
|
|
@@ -71,3 +71,9 @@ async def setup_task_manager() -> None:
|
|
|
71
71
|
await setup_blocks()
|
|
72
72
|
await setup_worker_pools(client=client)
|
|
73
73
|
await setup_deployments(client=client)
|
|
74
|
+
await setup_triggers(
|
|
75
|
+
client=client,
|
|
76
|
+
triggers=builtin_triggers,
|
|
77
|
+
trigger_type=TriggerType.BUILTIN,
|
|
78
|
+
deprecated_triggers=DEPRECATED_STATIC_TRIGGER_NAMES,
|
|
79
|
+
)
|
infrahub/workflows/models.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import importlib
|
|
2
|
-
|
|
2
|
+
import inspect
|
|
3
|
+
from typing import Any, Awaitable, TypeVar
|
|
3
4
|
from uuid import UUID
|
|
4
5
|
|
|
6
|
+
from prefect import Flow
|
|
5
7
|
from prefect.client.orchestration import PrefectClient
|
|
6
8
|
from prefect.client.schemas.actions import DeploymentScheduleCreate
|
|
7
9
|
from prefect.client.schemas.objects import FlowRun
|
|
@@ -33,6 +35,12 @@ class WorkflowInfo(BaseModel):
|
|
|
33
35
|
return cls(id=flow_run.id, info=flow_run)
|
|
34
36
|
|
|
35
37
|
|
|
38
|
+
class WorkflowParameter(BaseModel):
|
|
39
|
+
name: str
|
|
40
|
+
type: str
|
|
41
|
+
required: bool
|
|
42
|
+
|
|
43
|
+
|
|
36
44
|
class WorkflowDefinition(BaseModel):
|
|
37
45
|
name: str
|
|
38
46
|
type: WorkflowType = WorkflowType.INTERNAL
|
|
@@ -72,9 +80,25 @@ class WorkflowDefinition(BaseModel):
|
|
|
72
80
|
data["work_pool_name"] = work_pool.name
|
|
73
81
|
return await client.create_deployment(flow_id=flow_id, **data)
|
|
74
82
|
|
|
75
|
-
def
|
|
83
|
+
def load_function(self) -> Flow[Any, Awaitable]:
|
|
76
84
|
module = importlib.import_module(self.module)
|
|
77
85
|
return getattr(module, self.function)
|
|
78
86
|
|
|
79
|
-
def
|
|
80
|
-
self.
|
|
87
|
+
def get_parameters(self) -> dict[str, WorkflowParameter]:
|
|
88
|
+
fn = self.load_function()
|
|
89
|
+
signature = inspect.signature(fn.fn)
|
|
90
|
+
required_params = fn.parameters.required
|
|
91
|
+
|
|
92
|
+
ANNOTATIONS_TO_EXCLUDE = ["InfrahubServices"]
|
|
93
|
+
|
|
94
|
+
params = {}
|
|
95
|
+
for item in signature.parameters.values():
|
|
96
|
+
# Workflow signature will return a string if 'from __future__ import annotations' is used
|
|
97
|
+
# Otherwise it will return a type object
|
|
98
|
+
annotation = item.annotation if isinstance(item.annotation, str) else item.annotation.__name__
|
|
99
|
+
if annotation in ANNOTATIONS_TO_EXCLUDE:
|
|
100
|
+
continue
|
|
101
|
+
param = WorkflowParameter(name=item.name, type=annotation, required=item.name in required_params)
|
|
102
|
+
params[item.name] = param
|
|
103
|
+
|
|
104
|
+
return params
|
infrahub/workflows/utils.py
CHANGED
infrahub_sdk/batch.py
CHANGED
|
@@ -30,7 +30,7 @@ class BatchTaskSync:
|
|
|
30
30
|
result = None
|
|
31
31
|
try:
|
|
32
32
|
result = self.task(*self.args, **self.kwargs)
|
|
33
|
-
except Exception as exc:
|
|
33
|
+
except Exception as exc:
|
|
34
34
|
if return_exceptions:
|
|
35
35
|
return self.node, exc
|
|
36
36
|
raise exc
|
|
@@ -44,7 +44,7 @@ async def execute_batch_task_in_pool(
|
|
|
44
44
|
async with semaphore:
|
|
45
45
|
try:
|
|
46
46
|
result = await task.task(*task.args, **task.kwargs)
|
|
47
|
-
except Exception as exc:
|
|
47
|
+
except Exception as exc:
|
|
48
48
|
if return_exceptions:
|
|
49
49
|
return (task.node, exc)
|
|
50
50
|
raise exc
|
infrahub_sdk/client.py
CHANGED
|
@@ -50,6 +50,7 @@ from .queries import QUERY_USER, get_commit_update_mutation
|
|
|
50
50
|
from .query_groups import InfrahubGroupContext, InfrahubGroupContextSync
|
|
51
51
|
from .schema import InfrahubSchema, InfrahubSchemaSync, NodeSchemaAPI
|
|
52
52
|
from .store import NodeStore, NodeStoreSync
|
|
53
|
+
from .task.manager import InfrahubTaskManager, InfrahubTaskManagerSync
|
|
53
54
|
from .timestamp import Timestamp
|
|
54
55
|
from .types import AsyncRequester, HTTPMethod, Order, SyncRequester
|
|
55
56
|
from .utils import decode_json, get_user_permissions, is_valid_uuid
|
|
@@ -268,6 +269,7 @@ class InfrahubClient(BaseClient):
|
|
|
268
269
|
self.branch = InfrahubBranchManager(self)
|
|
269
270
|
self.object_store = ObjectStore(self)
|
|
270
271
|
self.store = NodeStore()
|
|
272
|
+
self.task = InfrahubTaskManager(self)
|
|
271
273
|
self.concurrent_execution_limit = asyncio.Semaphore(self.max_concurrent_execution)
|
|
272
274
|
self._request_method: AsyncRequester = self.config.requester or self._default_request_method
|
|
273
275
|
self.group_context = InfrahubGroupContext(self)
|
|
@@ -1500,6 +1502,11 @@ class InfrahubClient(BaseClient):
|
|
|
1500
1502
|
|
|
1501
1503
|
|
|
1502
1504
|
class InfrahubClientSync(BaseClient):
|
|
1505
|
+
schema: InfrahubSchemaSync
|
|
1506
|
+
branch: InfrahubBranchManagerSync
|
|
1507
|
+
object_store: ObjectStoreSync
|
|
1508
|
+
store: NodeStoreSync
|
|
1509
|
+
task: InfrahubTaskManagerSync
|
|
1503
1510
|
group_context: InfrahubGroupContextSync
|
|
1504
1511
|
|
|
1505
1512
|
def _initialize(self) -> None:
|
|
@@ -1507,6 +1514,7 @@ class InfrahubClientSync(BaseClient):
|
|
|
1507
1514
|
self.branch = InfrahubBranchManagerSync(self)
|
|
1508
1515
|
self.object_store = ObjectStoreSync(self)
|
|
1509
1516
|
self.store = NodeStoreSync()
|
|
1517
|
+
self.task = InfrahubTaskManagerSync(self)
|
|
1510
1518
|
self._request_method: SyncRequester = self.config.sync_requester or self._default_request_method
|
|
1511
1519
|
self.group_context = InfrahubGroupContextSync(self)
|
|
1512
1520
|
|
infrahub_sdk/config.py
CHANGED
|
@@ -113,7 +113,7 @@ class ConfigBase(BaseSettings):
|
|
|
113
113
|
|
|
114
114
|
@model_validator(mode="after")
|
|
115
115
|
def validate_proxy_config(self) -> Self:
|
|
116
|
-
if self.proxy and self.proxy_mounts.is_set:
|
|
116
|
+
if self.proxy and self.proxy_mounts.is_set:
|
|
117
117
|
raise ValueError("'proxy' and 'proxy_mounts' are mutually exclusive")
|
|
118
118
|
return self
|
|
119
119
|
|
infrahub_sdk/ctl/branch.py
CHANGED
|
@@ -5,9 +5,10 @@ from rich.console import Console
|
|
|
5
5
|
from rich.table import Table
|
|
6
6
|
|
|
7
7
|
from ..async_typer import AsyncTyper
|
|
8
|
-
from ..
|
|
9
|
-
from
|
|
8
|
+
from ..utils import calculate_time_diff
|
|
9
|
+
from .client import initialize_client
|
|
10
10
|
from .parameters import CONFIG_PARAM
|
|
11
|
+
from .utils import catch_exception
|
|
11
12
|
|
|
12
13
|
app = AsyncTyper()
|
|
13
14
|
console = Console()
|
infrahub_sdk/ctl/check.py
CHANGED
|
@@ -5,7 +5,7 @@ import sys
|
|
|
5
5
|
from asyncio import run as aiorun
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import TYPE_CHECKING
|
|
8
|
+
from typing import TYPE_CHECKING, Optional
|
|
9
9
|
|
|
10
10
|
import typer
|
|
11
11
|
from rich.console import Console
|
|
@@ -50,8 +50,8 @@ def run(
|
|
|
50
50
|
format_json: bool,
|
|
51
51
|
list_available: bool,
|
|
52
52
|
variables: dict[str, str],
|
|
53
|
-
name: str
|
|
54
|
-
branch: str
|
|
53
|
+
name: Optional[str] = None,
|
|
54
|
+
branch: Optional[str] = None,
|
|
55
55
|
) -> None:
|
|
56
56
|
"""Locate and execute all checks under the defined path."""
|
|
57
57
|
|
|
@@ -121,7 +121,7 @@ async def run_check(
|
|
|
121
121
|
except QueryNotFoundError as exc:
|
|
122
122
|
log.warning(f"{module_name}::{check}: unable to find query ({exc!s})")
|
|
123
123
|
passed = False
|
|
124
|
-
except Exception as exc:
|
|
124
|
+
except Exception as exc:
|
|
125
125
|
log.warning(f"{module_name}::{check}: An error occurred during execution ({exc})")
|
|
126
126
|
passed = False
|
|
127
127
|
|
infrahub_sdk/ctl/cli_commands.py
CHANGED
|
@@ -7,7 +7,7 @@ import logging
|
|
|
7
7
|
import platform
|
|
8
8
|
import sys
|
|
9
9
|
from pathlib import Path
|
|
10
|
-
from typing import TYPE_CHECKING, Any, Callable
|
|
10
|
+
from typing import TYPE_CHECKING, Any, Callable, Optional
|
|
11
11
|
|
|
12
12
|
import jinja2
|
|
13
13
|
import typer
|
|
@@ -74,13 +74,13 @@ console = Console()
|
|
|
74
74
|
@catch_exception(console=console)
|
|
75
75
|
def check(
|
|
76
76
|
check_name: str = typer.Argument(default="", help="Name of the Python check"),
|
|
77
|
-
branch: str
|
|
77
|
+
branch: Optional[str] = None,
|
|
78
78
|
path: str = typer.Option(".", help="Root directory"),
|
|
79
79
|
debug: bool = False,
|
|
80
80
|
format_json: bool = False,
|
|
81
81
|
_: str = CONFIG_PARAM,
|
|
82
82
|
list_available: bool = typer.Option(False, "--list", help="Show available Python checks"),
|
|
83
|
-
variables: list[str]
|
|
83
|
+
variables: Optional[list[str]] = typer.Argument(
|
|
84
84
|
None, help="Variables to pass along with the query. Format key=value key=value."
|
|
85
85
|
),
|
|
86
86
|
) -> None:
|
|
@@ -102,12 +102,12 @@ def check(
|
|
|
102
102
|
@catch_exception(console=console)
|
|
103
103
|
async def generator(
|
|
104
104
|
generator_name: str = typer.Argument(default="", help="Name of the Generator"),
|
|
105
|
-
branch: str
|
|
105
|
+
branch: Optional[str] = None,
|
|
106
106
|
path: str = typer.Option(".", help="Root directory"),
|
|
107
107
|
debug: bool = False,
|
|
108
108
|
_: str = CONFIG_PARAM,
|
|
109
109
|
list_available: bool = typer.Option(False, "--list", help="Show available Generators"),
|
|
110
|
-
variables: list[str]
|
|
110
|
+
variables: Optional[list[str]] = typer.Argument(
|
|
111
111
|
None, help="Variables to pass along with the query. Format key=value key=value."
|
|
112
112
|
),
|
|
113
113
|
) -> None:
|
|
@@ -129,14 +129,14 @@ async def run(
|
|
|
129
129
|
method: str = "run",
|
|
130
130
|
debug: bool = False,
|
|
131
131
|
_: str = CONFIG_PARAM,
|
|
132
|
-
branch: str = typer.Option(
|
|
133
|
-
concurrent: int
|
|
132
|
+
branch: str = typer.Option(None, help="Branch on which to run the script."),
|
|
133
|
+
concurrent: Optional[int] = typer.Option(
|
|
134
134
|
None,
|
|
135
135
|
help="Maximum number of requests to execute at the same time.",
|
|
136
136
|
envvar="INFRAHUB_MAX_CONCURRENT_EXECUTION",
|
|
137
137
|
),
|
|
138
138
|
timeout: int = typer.Option(60, help="Timeout in sec", envvar="INFRAHUB_TIMEOUT"),
|
|
139
|
-
variables: list[str]
|
|
139
|
+
variables: Optional[list[str]] = typer.Argument(
|
|
140
140
|
None, help="Variables to pass along with the query. Format key=value key=value."
|
|
141
141
|
),
|
|
142
142
|
) -> None:
|
|
@@ -259,7 +259,7 @@ def _run_transform(
|
|
|
259
259
|
@catch_exception(console=console)
|
|
260
260
|
def render(
|
|
261
261
|
transform_name: str = typer.Argument(default="", help="Name of the Python transformation", show_default=False),
|
|
262
|
-
variables: list[str]
|
|
262
|
+
variables: Optional[list[str]] = typer.Argument(
|
|
263
263
|
None, help="Variables to pass along with the query. Format key=value key=value."
|
|
264
264
|
),
|
|
265
265
|
branch: str = typer.Option(None, help="Branch on which to render the transform."),
|
|
@@ -309,7 +309,7 @@ def render(
|
|
|
309
309
|
@catch_exception(console=console)
|
|
310
310
|
def transform(
|
|
311
311
|
transform_name: str = typer.Argument(default="", help="Name of the Python transformation", show_default=False),
|
|
312
|
-
variables: list[str]
|
|
312
|
+
variables: Optional[list[str]] = typer.Argument(
|
|
313
313
|
None, help="Variables to pass along with the query. Format key=value key=value."
|
|
314
314
|
),
|
|
315
315
|
branch: str = typer.Option(None, help="Branch on which to run the transformation"),
|
|
@@ -352,7 +352,11 @@ def transform(
|
|
|
352
352
|
# Run Transform
|
|
353
353
|
result = asyncio.run(transform.run(data=data))
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
if isinstance(result, str):
|
|
356
|
+
json_string = result
|
|
357
|
+
else:
|
|
358
|
+
json_string = ujson.dumps(result, indent=2, sort_keys=True)
|
|
359
|
+
|
|
356
360
|
if out:
|
|
357
361
|
write_to_file(Path(out), json_string)
|
|
358
362
|
else:
|
|
@@ -383,6 +387,7 @@ def protocols(
|
|
|
383
387
|
|
|
384
388
|
else:
|
|
385
389
|
client = initialize_client_sync()
|
|
390
|
+
branch = branch or client.default_branch
|
|
386
391
|
schema.update(client.schema.fetch(branch=branch))
|
|
387
392
|
|
|
388
393
|
code_generator = CodeGenerator(schema=schema)
|
infrahub_sdk/ctl/exceptions.py
CHANGED
|
@@ -6,9 +6,3 @@ class QueryNotFoundError(Error):
|
|
|
6
6
|
def __init__(self, name: str, message: str = ""):
|
|
7
7
|
self.message = message or f"The requested query '{name}' was not found."
|
|
8
8
|
super().__init__(self.message)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class FileNotValidError(Error):
|
|
12
|
-
def __init__(self, name: str, message: str = ""):
|
|
13
|
-
self.message = message or f"Cannot parse '{name}' content."
|
|
14
|
-
super().__init__(self.message)
|
infrahub_sdk/ctl/exporter.py
CHANGED
|
@@ -22,7 +22,7 @@ def dump(
|
|
|
22
22
|
directory: Path = typer.Option(directory_name_with_timestamp, help="Directory path to store export"),
|
|
23
23
|
quiet: bool = typer.Option(False, help="No console output"),
|
|
24
24
|
_: str = CONFIG_PARAM,
|
|
25
|
-
branch: str = typer.Option(
|
|
25
|
+
branch: str = typer.Option(None, help="Branch from which to export"),
|
|
26
26
|
concurrent: int = typer.Option(
|
|
27
27
|
4,
|
|
28
28
|
help="Maximum number of requests to execute at the same time.",
|
infrahub_sdk/ctl/generator.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING, Optional
|
|
5
5
|
|
|
6
6
|
import typer
|
|
7
7
|
from rich.console import Console
|
|
@@ -9,7 +9,7 @@ from rich.console import Console
|
|
|
9
9
|
from ..ctl import config
|
|
10
10
|
from ..ctl.client import initialize_client
|
|
11
11
|
from ..ctl.repository import get_repository_config
|
|
12
|
-
from ..ctl.utils import execute_graphql_query, parse_cli_vars
|
|
12
|
+
from ..ctl.utils import execute_graphql_query, init_logging, parse_cli_vars
|
|
13
13
|
from ..exceptions import ModuleImportError
|
|
14
14
|
from ..node import InfrahubNode
|
|
15
15
|
|
|
@@ -20,11 +20,12 @@ if TYPE_CHECKING:
|
|
|
20
20
|
async def run(
|
|
21
21
|
generator_name: str,
|
|
22
22
|
path: str, # noqa: ARG001
|
|
23
|
-
debug: bool,
|
|
23
|
+
debug: bool,
|
|
24
24
|
list_available: bool,
|
|
25
25
|
branch: str | None = None,
|
|
26
|
-
variables: list[str]
|
|
26
|
+
variables: Optional[list[str]] = None,
|
|
27
27
|
) -> None:
|
|
28
|
+
init_logging(debug=debug)
|
|
28
29
|
repository_config = get_repository_config(Path(config.INFRAHUB_REPO_CONFIG_FILE))
|
|
29
30
|
|
|
30
31
|
if list_available or not generator_name:
|
|
@@ -34,7 +35,6 @@ async def run(
|
|
|
34
35
|
generator_config = repository_config.get_generator_definition(name=generator_name)
|
|
35
36
|
|
|
36
37
|
console = Console()
|
|
37
|
-
|
|
38
38
|
relative_path = str(generator_config.file_path.parent) if generator_config.file_path.parent != Path() else None
|
|
39
39
|
|
|
40
40
|
try:
|
infrahub_sdk/ctl/importer.py
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from asyncio import run as aiorun
|
|
4
4
|
from pathlib import Path
|
|
5
|
+
from typing import Optional
|
|
5
6
|
|
|
6
7
|
import typer
|
|
7
8
|
from rich.console import Console
|
|
@@ -25,8 +26,8 @@ def load(
|
|
|
25
26
|
),
|
|
26
27
|
quiet: bool = typer.Option(False, help="No console output"),
|
|
27
28
|
_: str = CONFIG_PARAM,
|
|
28
|
-
branch: str = typer.Option(
|
|
29
|
-
concurrent: int
|
|
29
|
+
branch: str = typer.Option(None, help="Branch from which to export"),
|
|
30
|
+
concurrent: Optional[int] = typer.Option(
|
|
30
31
|
None,
|
|
31
32
|
help="Maximum number of requests to execute at the same time.",
|
|
32
33
|
envvar="INFRAHUB_MAX_CONCURRENT_EXECUTION",
|
infrahub_sdk/ctl/menu.py
CHANGED
|
@@ -27,7 +27,7 @@ def callback() -> None:
|
|
|
27
27
|
async def load(
|
|
28
28
|
menus: list[Path],
|
|
29
29
|
debug: bool = False,
|
|
30
|
-
branch: str = typer.Option(
|
|
30
|
+
branch: str = typer.Option(None, help="Branch on which to load the menu."),
|
|
31
31
|
_: str = CONFIG_PARAM,
|
|
32
32
|
) -> None:
|
|
33
33
|
"""Load one or multiple menu files into Infrahub."""
|
infrahub_sdk/ctl/object.py
CHANGED
|
@@ -27,7 +27,7 @@ def callback() -> None:
|
|
|
27
27
|
async def load(
|
|
28
28
|
paths: list[Path],
|
|
29
29
|
debug: bool = False,
|
|
30
|
-
branch: str = typer.Option(
|
|
30
|
+
branch: str = typer.Option(None, help="Branch on which to load the objects."),
|
|
31
31
|
_: str = CONFIG_PARAM,
|
|
32
32
|
) -> None:
|
|
33
33
|
"""Load one or multiple objects files into Infrahub."""
|