infrahub-server 1.1.6__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.
Files changed (407) hide show
  1. infrahub/api/artifact.py +16 -4
  2. infrahub/api/dependencies.py +8 -0
  3. infrahub/api/oauth2.py +0 -1
  4. infrahub/api/oidc.py +0 -1
  5. infrahub/api/query.py +18 -7
  6. infrahub/api/schema.py +32 -6
  7. infrahub/api/transformation.py +12 -5
  8. infrahub/{message_bus/messages/check_artifact_create.py → artifacts/models.py} +5 -3
  9. infrahub/{message_bus/operations/check/artifact.py → artifacts/tasks.py} +26 -25
  10. infrahub/cli/__init__.py +0 -2
  11. infrahub/cli/db.py +6 -7
  12. infrahub/cli/events.py +8 -3
  13. infrahub/cli/git_agent.py +9 -7
  14. infrahub/cli/tasks.py +4 -6
  15. infrahub/computed_attribute/models.py +1 -1
  16. infrahub/computed_attribute/tasks.py +64 -17
  17. infrahub/computed_attribute/triggers.py +90 -0
  18. infrahub/config.py +1 -1
  19. infrahub/context.py +39 -0
  20. infrahub/core/account.py +5 -8
  21. infrahub/core/attribute.py +54 -22
  22. infrahub/core/branch/models.py +4 -4
  23. infrahub/core/branch/tasks.py +137 -129
  24. infrahub/core/changelog/__init__.py +0 -0
  25. infrahub/core/changelog/diff.py +283 -0
  26. infrahub/core/changelog/models.py +499 -0
  27. infrahub/core/constants/__init__.py +43 -2
  28. infrahub/core/constants/infrahubkind.py +1 -0
  29. infrahub/core/constants/schema.py +2 -0
  30. infrahub/core/diff/combiner.py +12 -8
  31. infrahub/core/diff/coordinator.py +49 -70
  32. infrahub/core/diff/data_check_synchronizer.py +86 -7
  33. infrahub/core/diff/enricher/aggregated.py +3 -3
  34. infrahub/core/diff/enricher/cardinality_one.py +7 -7
  35. infrahub/core/diff/enricher/hierarchy.py +22 -7
  36. infrahub/core/diff/enricher/labels.py +19 -4
  37. infrahub/core/diff/enricher/path_identifier.py +7 -9
  38. infrahub/core/diff/enricher/summary_counts.py +3 -1
  39. infrahub/core/diff/merger/merger.py +8 -4
  40. infrahub/core/diff/model/path.py +76 -35
  41. infrahub/core/diff/parent_node_adder.py +78 -0
  42. infrahub/core/diff/payload_builder.py +13 -2
  43. infrahub/core/diff/query/all_conflicts.py +6 -3
  44. infrahub/core/diff/query/artifact.py +1 -1
  45. infrahub/core/diff/query/delete_query.py +1 -1
  46. infrahub/core/diff/query/diff_get.py +3 -2
  47. infrahub/core/diff/query/diff_summary.py +1 -1
  48. infrahub/core/diff/query/field_specifiers.py +3 -1
  49. infrahub/core/diff/query/field_summary.py +3 -2
  50. infrahub/core/diff/query/filters.py +14 -3
  51. infrahub/core/diff/query/get_conflict_query.py +1 -1
  52. infrahub/core/diff/query/has_conflicts_query.py +6 -3
  53. infrahub/core/diff/query/merge.py +3 -3
  54. infrahub/core/diff/query/{drop_tracking_id.py → merge_tracking_id.py} +4 -4
  55. infrahub/core/diff/query/roots_metadata.py +9 -2
  56. infrahub/core/diff/query/save.py +233 -142
  57. infrahub/core/diff/query/summary_counts_enricher.py +267 -0
  58. infrahub/core/diff/query/time_range_query.py +3 -2
  59. infrahub/core/diff/query/update_conflict_query.py +1 -1
  60. infrahub/core/diff/query_parser.py +49 -24
  61. infrahub/core/diff/repository/deserializer.py +32 -28
  62. infrahub/core/diff/repository/repository.py +215 -41
  63. infrahub/core/diff/tasks.py +13 -12
  64. infrahub/core/enums.py +1 -1
  65. infrahub/core/graph/__init__.py +1 -1
  66. infrahub/core/graph/index.py +3 -0
  67. infrahub/core/integrity/object_conflict/conflict_recorder.py +1 -1
  68. infrahub/core/ipam/reconciler.py +1 -1
  69. infrahub/core/ipam/tasks.py +2 -3
  70. infrahub/core/manager.py +20 -15
  71. infrahub/core/merge.py +5 -2
  72. infrahub/core/migrations/graph/__init__.py +4 -0
  73. infrahub/core/migrations/graph/m001_add_version_to_graph.py +1 -1
  74. infrahub/core/migrations/graph/m002_attribute_is_default.py +2 -2
  75. infrahub/core/migrations/graph/m003_relationship_parent_optional.py +2 -2
  76. infrahub/core/migrations/graph/m004_add_attr_documentation.py +1 -1
  77. infrahub/core/migrations/graph/m005_add_rel_read_only.py +1 -1
  78. infrahub/core/migrations/graph/m006_add_rel_on_delete.py +1 -1
  79. infrahub/core/migrations/graph/m007_add_rel_allow_override.py +1 -1
  80. infrahub/core/migrations/graph/m008_add_human_friendly_id.py +1 -1
  81. infrahub/core/migrations/graph/m009_add_generate_profile_attr.py +1 -1
  82. infrahub/core/migrations/graph/m010_add_generate_profile_attr_generic.py +1 -1
  83. infrahub/core/migrations/graph/m011_remove_profile_relationship_schema.py +2 -2
  84. infrahub/core/migrations/graph/m012_convert_account_generic.py +12 -23
  85. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +7 -11
  86. infrahub/core/migrations/graph/m014_remove_index_attr_value.py +2 -2
  87. infrahub/core/migrations/graph/m015_diff_format_update.py +1 -1
  88. infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -1
  89. infrahub/core/migrations/graph/m017_add_core_profile.py +1 -1
  90. infrahub/core/migrations/graph/m018_uniqueness_nulls.py +2 -2
  91. infrahub/core/migrations/graph/m019_restore_rels_to_time.py +256 -0
  92. infrahub/core/migrations/graph/m020_add_generate_template_attr.py +48 -0
  93. infrahub/core/migrations/query/attribute_add.py +1 -1
  94. infrahub/core/migrations/query/attribute_rename.py +1 -1
  95. infrahub/core/migrations/query/delete_element_in_schema.py +1 -1
  96. infrahub/core/migrations/query/node_duplicate.py +39 -19
  97. infrahub/core/migrations/query/relationship_duplicate.py +1 -1
  98. infrahub/core/migrations/query/schema_attribute_update.py +1 -1
  99. infrahub/core/migrations/schema/node_attribute_remove.py +1 -1
  100. infrahub/core/migrations/schema/node_remove.py +27 -13
  101. infrahub/core/migrations/schema/tasks.py +5 -5
  102. infrahub/core/migrations/shared.py +4 -4
  103. infrahub/core/models.py +7 -8
  104. infrahub/core/node/__init__.py +170 -46
  105. infrahub/core/node/base.py +1 -1
  106. infrahub/core/node/constraints/grouped_uniqueness.py +9 -2
  107. infrahub/core/node/delete_validator.py +4 -4
  108. infrahub/core/node/ipam.py +13 -8
  109. infrahub/core/node/permissions.py +4 -0
  110. infrahub/core/node/resource_manager/ip_prefix_pool.py +8 -5
  111. infrahub/core/node/standard.py +3 -5
  112. infrahub/core/property.py +1 -1
  113. infrahub/core/protocols.py +6 -0
  114. infrahub/core/protocols_base.py +4 -2
  115. infrahub/core/query/__init__.py +2 -5
  116. infrahub/core/query/attribute.py +9 -9
  117. infrahub/core/query/branch.py +5 -5
  118. infrahub/core/query/delete.py +1 -1
  119. infrahub/core/query/diff.py +45 -7
  120. infrahub/core/query/ipam.py +4 -4
  121. infrahub/core/query/node.py +19 -14
  122. infrahub/core/query/relationship.py +213 -26
  123. infrahub/core/query/resource_manager.py +13 -11
  124. infrahub/core/query/standard_node.py +6 -6
  125. infrahub/core/query/task.py +3 -3
  126. infrahub/core/query/task_log.py +1 -1
  127. infrahub/core/query/utils.py +5 -5
  128. infrahub/core/registry.py +0 -2
  129. infrahub/core/relationship/constraints/count.py +1 -1
  130. infrahub/core/relationship/constraints/peer_kind.py +1 -1
  131. infrahub/core/relationship/model.py +76 -38
  132. infrahub/core/schema/__init__.py +6 -4
  133. infrahub/core/schema/attribute_schema.py +8 -0
  134. infrahub/core/schema/basenode_schema.py +13 -3
  135. infrahub/core/schema/definitions/core/__init__.py +153 -0
  136. infrahub/core/schema/definitions/core/account.py +168 -0
  137. infrahub/core/schema/definitions/core/artifact.py +127 -0
  138. infrahub/core/schema/definitions/core/builtin.py +21 -0
  139. infrahub/core/schema/definitions/core/check.py +60 -0
  140. infrahub/core/schema/definitions/core/generator.py +96 -0
  141. infrahub/core/schema/definitions/core/graphql_query.py +77 -0
  142. infrahub/core/schema/definitions/core/group.py +105 -0
  143. infrahub/core/schema/definitions/core/ipam.py +252 -0
  144. infrahub/core/schema/definitions/core/lineage.py +17 -0
  145. infrahub/core/schema/definitions/core/menu.py +46 -0
  146. infrahub/core/schema/definitions/core/permission.py +161 -0
  147. infrahub/core/schema/definitions/core/profile.py +29 -0
  148. infrahub/core/schema/definitions/core/propose_change.py +88 -0
  149. infrahub/core/schema/definitions/core/propose_change_comment.py +188 -0
  150. infrahub/core/schema/definitions/core/propose_change_validator.py +326 -0
  151. infrahub/core/schema/definitions/core/repository.py +280 -0
  152. infrahub/core/schema/definitions/core/resource_pool.py +180 -0
  153. infrahub/core/schema/definitions/core/template.py +12 -0
  154. infrahub/core/schema/definitions/core/transform.py +87 -0
  155. infrahub/core/schema/definitions/core/webhook.py +108 -0
  156. infrahub/core/schema/definitions/internal.py +16 -0
  157. infrahub/core/schema/generated/genericnode_schema.py +5 -0
  158. infrahub/core/schema/generated/node_schema.py +5 -0
  159. infrahub/core/schema/generic_schema.py +5 -1
  160. infrahub/core/schema/manager.py +45 -42
  161. infrahub/core/schema/node_schema.py +4 -0
  162. infrahub/core/schema/profile_schema.py +4 -0
  163. infrahub/core/schema/relationship_schema.py +10 -2
  164. infrahub/core/schema/schema_branch.py +260 -16
  165. infrahub/core/schema/template_schema.py +36 -0
  166. infrahub/core/task/user_task.py +7 -5
  167. infrahub/core/timestamp.py +3 -3
  168. infrahub/core/utils.py +3 -2
  169. infrahub/core/validators/attribute/choices.py +1 -1
  170. infrahub/core/validators/attribute/enum.py +1 -1
  171. infrahub/core/validators/attribute/kind.py +1 -1
  172. infrahub/core/validators/attribute/length.py +1 -1
  173. infrahub/core/validators/attribute/optional.py +1 -1
  174. infrahub/core/validators/attribute/regex.py +1 -1
  175. infrahub/core/validators/attribute/unique.py +1 -1
  176. infrahub/core/validators/checks_runner.py +37 -0
  177. infrahub/core/validators/node/generate_profile.py +1 -1
  178. infrahub/core/validators/node/hierarchy.py +1 -1
  179. infrahub/core/validators/query.py +1 -1
  180. infrahub/core/validators/relationship/count.py +1 -1
  181. infrahub/core/validators/relationship/optional.py +1 -1
  182. infrahub/core/validators/relationship/peer.py +1 -1
  183. infrahub/core/validators/tasks.py +8 -6
  184. infrahub/core/validators/uniqueness/query.py +20 -17
  185. infrahub/database/__init__.py +16 -2
  186. infrahub/database/memgraph.py +1 -1
  187. infrahub/dependencies/builder/constraint/grouped/node_runner.py +0 -2
  188. infrahub/dependencies/builder/diff/combiner.py +1 -1
  189. infrahub/dependencies/builder/diff/conflicts_enricher.py +1 -1
  190. infrahub/dependencies/builder/diff/coordinator.py +0 -2
  191. infrahub/dependencies/builder/diff/deserializer.py +4 -2
  192. infrahub/dependencies/builder/diff/enricher/hierarchy.py +3 -1
  193. infrahub/dependencies/builder/diff/enricher/summary_counts.py +1 -1
  194. infrahub/dependencies/builder/diff/parent_node_adder.py +8 -0
  195. infrahub/events/artifact_action.py +76 -0
  196. infrahub/events/branch_action.py +50 -21
  197. infrahub/events/group_action.py +117 -0
  198. infrahub/events/models.py +164 -51
  199. infrahub/events/node_action.py +70 -8
  200. infrahub/events/repository_action.py +8 -8
  201. infrahub/events/schema_action.py +21 -8
  202. infrahub/exceptions.py +9 -0
  203. infrahub/generators/models.py +1 -0
  204. infrahub/generators/tasks.py +34 -15
  205. infrahub/git/base.py +3 -5
  206. infrahub/git/constants.py +0 -1
  207. infrahub/git/integrator.py +60 -36
  208. infrahub/git/models.py +80 -1
  209. infrahub/git/repository.py +7 -8
  210. infrahub/git/tasks.py +432 -112
  211. infrahub/git_credential/helper.py +2 -3
  212. infrahub/graphql/analyzer.py +572 -11
  213. infrahub/graphql/app.py +34 -26
  214. infrahub/graphql/auth/query_permission_checker/anonymous_checker.py +5 -5
  215. infrahub/graphql/auth/query_permission_checker/default_branch_checker.py +4 -4
  216. infrahub/graphql/auth/query_permission_checker/merge_operation_checker.py +4 -4
  217. infrahub/graphql/auth/query_permission_checker/object_permission_checker.py +28 -35
  218. infrahub/graphql/auth/query_permission_checker/super_admin_checker.py +5 -5
  219. infrahub/graphql/context.py +33 -0
  220. infrahub/graphql/enums.py +1 -1
  221. infrahub/graphql/initialization.py +5 -1
  222. infrahub/graphql/loaders/node.py +2 -2
  223. infrahub/graphql/manager.py +63 -63
  224. infrahub/graphql/mutations/account.py +20 -13
  225. infrahub/graphql/mutations/artifact_definition.py +16 -12
  226. infrahub/graphql/mutations/branch.py +86 -40
  227. infrahub/graphql/mutations/computed_attribute.py +24 -13
  228. infrahub/graphql/mutations/diff.py +54 -14
  229. infrahub/graphql/mutations/diff_conflict.py +14 -8
  230. infrahub/graphql/mutations/generator.py +83 -0
  231. infrahub/graphql/mutations/graphql_query.py +19 -11
  232. infrahub/graphql/mutations/ipam.py +25 -23
  233. infrahub/graphql/mutations/main.py +243 -50
  234. infrahub/graphql/mutations/menu.py +10 -10
  235. infrahub/graphql/mutations/proposed_change.py +36 -28
  236. infrahub/graphql/mutations/relationship.py +343 -104
  237. infrahub/graphql/mutations/repository.py +41 -35
  238. infrahub/graphql/mutations/resource_manager.py +26 -26
  239. infrahub/graphql/mutations/schema.py +66 -33
  240. infrahub/graphql/mutations/tasks.py +16 -10
  241. infrahub/graphql/parser.py +1 -1
  242. infrahub/graphql/permissions.py +3 -10
  243. infrahub/graphql/queries/account.py +22 -18
  244. infrahub/graphql/queries/branch.py +6 -4
  245. infrahub/graphql/queries/diff/tree.py +63 -52
  246. infrahub/graphql/queries/event.py +115 -0
  247. infrahub/graphql/queries/internal.py +3 -3
  248. infrahub/graphql/queries/ipam.py +23 -18
  249. infrahub/graphql/queries/relationship.py +11 -10
  250. infrahub/graphql/queries/resource_manager.py +43 -27
  251. infrahub/graphql/queries/search.py +9 -8
  252. infrahub/graphql/queries/status.py +12 -9
  253. infrahub/graphql/queries/task.py +11 -9
  254. infrahub/graphql/resolvers/resolver.py +69 -43
  255. infrahub/graphql/resolvers/single_relationship.py +16 -10
  256. infrahub/graphql/schema.py +4 -0
  257. infrahub/graphql/subscription/__init__.py +1 -1
  258. infrahub/graphql/subscription/events.py +1 -1
  259. infrahub/graphql/subscription/graphql_query.py +8 -8
  260. infrahub/graphql/types/branch.py +2 -2
  261. infrahub/graphql/types/common.py +6 -1
  262. infrahub/graphql/types/context.py +12 -0
  263. infrahub/graphql/types/enums.py +2 -0
  264. infrahub/graphql/types/event.py +158 -0
  265. infrahub/graphql/types/interface.py +2 -2
  266. infrahub/graphql/types/node.py +3 -3
  267. infrahub/graphql/types/permission.py +2 -2
  268. infrahub/graphql/types/relationship.py +3 -3
  269. infrahub/graphql/types/standard_node.py +9 -11
  270. infrahub/graphql/utils.py +28 -182
  271. infrahub/groups/tasks.py +2 -3
  272. infrahub/lock.py +21 -21
  273. infrahub/menu/generator.py +0 -1
  274. infrahub/menu/menu.py +116 -138
  275. infrahub/menu/models.py +4 -4
  276. infrahub/message_bus/__init__.py +11 -13
  277. infrahub/message_bus/messages/__init__.py +0 -14
  278. infrahub/message_bus/messages/check_generator_run.py +1 -3
  279. infrahub/message_bus/messages/event_branch_merge.py +3 -0
  280. infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +6 -0
  281. infrahub/message_bus/messages/request_proposedchange_pipeline.py +2 -0
  282. infrahub/message_bus/messages/send_echo_request.py +1 -1
  283. infrahub/message_bus/operations/__init__.py +4 -13
  284. infrahub/message_bus/operations/check/__init__.py +2 -2
  285. infrahub/message_bus/operations/check/generator.py +1 -3
  286. infrahub/message_bus/operations/event/branch.py +7 -3
  287. infrahub/message_bus/operations/event/schema.py +1 -1
  288. infrahub/message_bus/operations/event/worker.py +0 -3
  289. infrahub/message_bus/operations/finalize/validator.py +1 -1
  290. infrahub/message_bus/operations/git/file.py +2 -2
  291. infrahub/message_bus/operations/git/repository.py +1 -1
  292. infrahub/message_bus/operations/requests/__init__.py +0 -4
  293. infrahub/message_bus/operations/requests/generator_definition.py +2 -4
  294. infrahub/message_bus/operations/requests/proposed_change.py +37 -20
  295. infrahub/message_bus/operations/send/echo.py +1 -1
  296. infrahub/message_bus/types.py +1 -1
  297. infrahub/permissions/__init__.py +2 -1
  298. infrahub/permissions/globals.py +15 -0
  299. infrahub/permissions/types.py +26 -0
  300. infrahub/pools/prefix.py +29 -165
  301. infrahub/prefect_server/__init__.py +0 -0
  302. infrahub/prefect_server/app.py +18 -0
  303. infrahub/prefect_server/database.py +20 -0
  304. infrahub/prefect_server/events.py +28 -0
  305. infrahub/prefect_server/models.py +46 -0
  306. infrahub/proposed_change/models.py +18 -1
  307. infrahub/proposed_change/tasks.py +195 -53
  308. infrahub/pytest_plugin.py +4 -4
  309. infrahub/server.py +13 -12
  310. infrahub/services/__init__.py +148 -63
  311. infrahub/services/adapters/cache/__init__.py +11 -11
  312. infrahub/services/adapters/cache/nats.py +42 -25
  313. infrahub/services/adapters/cache/redis.py +3 -11
  314. infrahub/services/adapters/event/__init__.py +10 -18
  315. infrahub/services/adapters/http/__init__.py +0 -5
  316. infrahub/services/adapters/http/httpx.py +22 -15
  317. infrahub/services/adapters/message_bus/__init__.py +25 -8
  318. infrahub/services/adapters/message_bus/local.py +9 -7
  319. infrahub/services/adapters/message_bus/nats.py +14 -8
  320. infrahub/services/adapters/message_bus/rabbitmq.py +23 -10
  321. infrahub/services/adapters/workflow/__init__.py +11 -8
  322. infrahub/services/adapters/workflow/local.py +27 -6
  323. infrahub/services/adapters/workflow/worker.py +23 -7
  324. infrahub/services/component.py +43 -40
  325. infrahub/services/protocols.py +7 -7
  326. infrahub/services/scheduler.py +30 -29
  327. infrahub/storage.py +2 -4
  328. infrahub/task_manager/constants.py +1 -1
  329. infrahub/task_manager/event.py +261 -0
  330. infrahub/task_manager/models.py +147 -3
  331. infrahub/task_manager/task.py +1 -1
  332. infrahub/tasks/artifact.py +19 -18
  333. infrahub/tasks/registry.py +1 -1
  334. infrahub/tasks/telemetry.py +13 -14
  335. infrahub/transformations/tasks.py +3 -5
  336. infrahub/trigger/__init__.py +0 -0
  337. infrahub/trigger/catalogue.py +16 -0
  338. infrahub/trigger/constants.py +9 -0
  339. infrahub/trigger/models.py +105 -0
  340. infrahub/trigger/tasks.py +91 -0
  341. infrahub/types.py +1 -1
  342. infrahub/utils.py +1 -1
  343. infrahub/webhook/constants.py +0 -2
  344. infrahub/webhook/models.py +161 -40
  345. infrahub/webhook/tasks.py +123 -202
  346. infrahub/webhook/triggers.py +27 -0
  347. infrahub/workers/infrahub_async.py +36 -25
  348. infrahub/workers/utils.py +63 -0
  349. infrahub/workflows/catalogue.py +71 -52
  350. infrahub/workflows/initialization.py +14 -8
  351. infrahub/workflows/models.py +28 -4
  352. infrahub/workflows/utils.py +1 -1
  353. infrahub_sdk/client.py +8 -0
  354. infrahub_sdk/ctl/branch.py +3 -2
  355. infrahub_sdk/ctl/check.py +3 -3
  356. infrahub_sdk/ctl/cli_commands.py +16 -11
  357. infrahub_sdk/ctl/exceptions.py +0 -6
  358. infrahub_sdk/ctl/exporter.py +1 -1
  359. infrahub_sdk/ctl/generator.py +5 -5
  360. infrahub_sdk/ctl/importer.py +3 -2
  361. infrahub_sdk/ctl/menu.py +1 -1
  362. infrahub_sdk/ctl/object.py +1 -1
  363. infrahub_sdk/ctl/repository.py +23 -15
  364. infrahub_sdk/ctl/schema.py +2 -2
  365. infrahub_sdk/ctl/utils.py +4 -19
  366. infrahub_sdk/ctl/validate.py +2 -1
  367. infrahub_sdk/exceptions.py +12 -0
  368. infrahub_sdk/generator.py +3 -0
  369. infrahub_sdk/node.py +4 -4
  370. infrahub_sdk/protocols.py +21 -8
  371. infrahub_sdk/schema/__init__.py +14 -2
  372. infrahub_sdk/schema/main.py +7 -0
  373. infrahub_sdk/task/__init__.py +1 -0
  374. infrahub_sdk/task/constants.py +3 -0
  375. infrahub_sdk/task/exceptions.py +25 -0
  376. infrahub_sdk/task/manager.py +545 -0
  377. infrahub_sdk/task/models.py +74 -0
  378. infrahub_sdk/timestamp.py +134 -33
  379. infrahub_sdk/utils.py +39 -1
  380. infrahub_sdk/yaml.py +2 -3
  381. {infrahub_server-1.1.6.dist-info → infrahub_server-1.2.0b1.dist-info}/METADATA +47 -12
  382. infrahub_server-1.2.0b1.dist-info/RECORD +725 -0
  383. infrahub_testcontainers/container.py +14 -6
  384. infrahub_testcontainers/docker-compose.test.yml +24 -5
  385. infrahub_testcontainers/haproxy.cfg +43 -0
  386. infrahub_testcontainers/helpers.py +85 -1
  387. infrahub/core/branch/constants.py +0 -2
  388. infrahub/core/schema/definitions/core.py +0 -2274
  389. infrahub/graphql/query.py +0 -52
  390. infrahub/message_bus/messages/check_repository_checkdefinition.py +0 -20
  391. infrahub/message_bus/messages/check_repository_mergeconflicts.py +0 -16
  392. infrahub/message_bus/messages/check_repository_usercheck.py +0 -26
  393. infrahub/message_bus/messages/request_artifactdefinition_check.py +0 -17
  394. infrahub/message_bus/messages/request_repository_checks.py +0 -12
  395. infrahub/message_bus/messages/request_repository_userchecks.py +0 -18
  396. infrahub/message_bus/operations/check/repository.py +0 -293
  397. infrahub/message_bus/operations/requests/artifact_definition.py +0 -148
  398. infrahub/message_bus/operations/requests/repository.py +0 -133
  399. infrahub/schema/constants.py +0 -1
  400. infrahub/schema/tasks.py +0 -76
  401. infrahub/services/adapters/database/__init__.py +0 -9
  402. infrahub_sdk/ctl/_file.py +0 -13
  403. infrahub_server-1.1.6.dist-info/RECORD +0 -681
  404. /infrahub/{schema → artifacts}/__init__.py +0 -0
  405. {infrahub_server-1.1.6.dist-info → infrahub_server-1.2.0b1.dist-info}/LICENSE.txt +0 -0
  406. {infrahub_server-1.1.6.dist-info → infrahub_server-1.2.0b1.dist-info}/WHEEL +0 -0
  407. {infrahub_server-1.1.6.dist-info → infrahub_server-1.2.0b1.dist-info}/entry_points.txt +0 -0
@@ -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
- WEBHOOK_CONFIGURE = WorkflowDefinition(
374
- name="webhook-setup-automations",
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="configure_webhooks",
357
+ function="webhook_process",
378
358
  )
379
359
 
380
- WEBHOOK_TRIGGER = WorkflowDefinition(
381
- name="webhook-trigger-actions",
382
- type=WorkflowType.USER,
360
+ WEBHOOK_CONFIGURE_ONE = WorkflowDefinition(
361
+ name="webhook-setup-automation-one",
362
+ type=WorkflowType.CORE,
383
363
  module="infrahub.webhook.tasks",
384
- function="trigger_webhooks",
364
+ function="configure_webhook_one",
385
365
  )
386
366
 
387
- AUTOMATION_SETUP_WEBHOOK_CONFIGURATION_TRIGGER = WorkflowDefinition(
388
- name="webhook-setup-configuration-trigger",
389
- type=WorkflowType.USER,
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="trigger_webhook_configuration",
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
- WEBHOOK_CONFIGURE,
448
- WEBHOOK_SEND,
449
- WEBHOOK_TRIGGER,
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 automation_setup_workflows, worker_pools, workflows
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
+ )
@@ -1,7 +1,9 @@
1
1
  import importlib
2
- from typing import Any, Awaitable, Callable, TypeVar
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 get_function(self) -> Callable[..., Awaitable[Any]]:
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 validate_workflow(self) -> None:
80
- self.get_function()
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
@@ -76,4 +76,4 @@ async def wait_for_schema_to_converge(
76
76
 
77
77
  iteration += 1
78
78
 
79
- log.info(f"Schema converged after {delay * iteration} seconds")
79
+ log.info(f"Schema converged after {delay * iteration:.2f} seconds")
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
 
@@ -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 ..ctl.client import initialize_client
9
- from ..ctl.utils import calculate_time_diff, catch_exception
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 | None = None,
54
- branch: str | None = None,
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
 
@@ -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 | None = None,
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] | None = typer.Argument(
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 | None = None,
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] | None = typer.Argument(
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("main", help="Branch on which to run the script."),
133
- concurrent: int | None = typer.Option(
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] | None = typer.Argument(
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] | None = typer.Argument(
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] | None = typer.Argument(
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
- json_string = ujson.dumps(result, indent=2, sort_keys=True)
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)
@@ -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)
@@ -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("main", help="Branch from which to export"),
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.",
@@ -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, # noqa: ARG001
23
+ debug: bool,
24
24
  list_available: bool,
25
25
  branch: str | None = None,
26
- variables: list[str] | None = None,
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:
@@ -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("main", help="Branch from which to export"),
29
- concurrent: int | None = typer.Option(
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("main", help="Branch on which to load the menu."),
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."""
@@ -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("main", help="Branch on which to load the objects."),
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."""
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from pathlib import Path
4
+ from typing import Optional
4
5
 
5
6
  import typer
6
7
  import yaml
@@ -8,15 +9,14 @@ from pydantic import ValidationError
8
9
  from rich.console import Console
9
10
  from rich.table import Table
10
11
 
11
- from infrahub_sdk.ctl.client import initialize_client
12
-
13
12
  from ..async_typer import AsyncTyper
14
- from ..ctl.exceptions import FileNotValidError
15
- from ..ctl.utils import init_logging
13
+ from ..exceptions import FileNotValidError
16
14
  from ..graphql import Mutation, Query
17
15
  from ..schema.repository import InfrahubRepositoryConfig
18
- from ._file import read_file
16
+ from ..utils import read_file
17
+ from .client import initialize_client
19
18
  from .parameters import CONFIG_PARAM
19
+ from .utils import init_logging
20
20
 
21
21
  app = AsyncTyper()
22
22
  console = Console()
@@ -69,12 +69,11 @@ async def add(
69
69
  name: str,
70
70
  location: str,
71
71
  description: str = "",
72
- username: str | None = None,
72
+ username: Optional[str] = None,
73
73
  password: str = "",
74
- commit: str = "",
74
+ ref: str = "",
75
75
  read_only: bool = False,
76
76
  debug: bool = False,
77
- branch: str = typer.Option("main", help="Branch on which to add the repository."),
78
77
  _: str = CONFIG_PARAM,
79
78
  ) -> None:
80
79
  """Add a new repository."""
@@ -86,15 +85,24 @@ async def add(
86
85
  "name": {"value": name},
87
86
  "location": {"value": location},
88
87
  "description": {"value": description},
89
- "commit": {"value": commit},
90
88
  },
91
89
  }
90
+ if read_only:
91
+ input_data["data"]["ref"] = {"value": ref}
92
+ else:
93
+ input_data["data"]["default_branch"] = {"value": ref}
92
94
 
93
95
  client = initialize_client()
94
96
 
95
- credential = await client.create(kind="CorePasswordCredential", name=name, username=username, password=password)
96
- await credential.save(allow_upsert=True)
97
- input_data["data"]["credential"] = {"id": credential.id}
97
+ if username or password:
98
+ credential = await client.create(
99
+ kind="CorePasswordCredential",
100
+ name=name,
101
+ username=username,
102
+ password=password,
103
+ )
104
+ await credential.save(allow_upsert=True)
105
+ input_data["data"]["credential"] = {"id": credential.id}
98
106
 
99
107
  query = Mutation(
100
108
  mutation="CoreReadOnlyRepositoryCreate" if read_only else "CoreRepositoryCreate",
@@ -102,18 +110,18 @@ async def add(
102
110
  query={"ok": None},
103
111
  )
104
112
 
105
- await client.execute_graphql(query=query.render(), branch_name=branch, tracker="mutation-repository-create")
113
+ await client.execute_graphql(query=query.render(), tracker="mutation-repository-create")
106
114
 
107
115
 
108
116
  @app.command()
109
117
  async def list(
110
- branch: str | None = None,
118
+ branch: Optional[str] = typer.Option(None, help="Branch on which to list repositories."),
111
119
  debug: bool = False,
112
120
  _: str = CONFIG_PARAM,
113
121
  ) -> None:
114
122
  init_logging(debug=debug)
115
123
 
116
- client = initialize_client(branch=branch)
124
+ client = initialize_client()
117
125
 
118
126
  repo_status_query = {
119
127
  "CoreGenericRepository": {
@@ -108,7 +108,7 @@ def get_node(schemas_data: list[dict], schema_index: int, node_index: int) -> di
108
108
  async def load(
109
109
  schemas: list[Path],
110
110
  debug: bool = False,
111
- branch: str = typer.Option("main", help="Branch on which to load the schema."),
111
+ branch: str = typer.Option(None, help="Branch on which to load the schema."),
112
112
  wait: int = typer.Option(0, help="Time in seconds to wait until the schema has converged across all workers"),
113
113
  _: str = CONFIG_PARAM,
114
114
  ) -> None:
@@ -159,7 +159,7 @@ async def load(
159
159
  async def check(
160
160
  schemas: list[Path],
161
161
  debug: bool = False,
162
- branch: str = typer.Option("main", help="Branch on which to check the schema."),
162
+ branch: str = typer.Option(None, help="Branch on which to check the schema."),
163
163
  _: str = CONFIG_PARAM,
164
164
  ) -> None:
165
165
  """Check if schema files are valid and what would be the impact of loading them with Infrahub."""