foreman_ansible_director 0.6.0 → 0.7.0

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 (253) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_ansible_director/api/v2/ansible_content_controller.rb +9 -12
  3. data/app/controllers/foreman_ansible_director/api/v2/ansible_director_api_controller.rb +60 -3
  4. data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_bindings_controller.rb +347 -0
  5. data/app/controllers/foreman_ansible_director/api/v2/ansible_variables_controller.rb +204 -31
  6. data/app/controllers/foreman_ansible_director/api/v2/assignments_controller.rb +60 -4
  7. data/app/controllers/foreman_ansible_director/api/v2/execution_environments_controller.rb +8 -0
  8. data/app/controllers/foreman_ansible_director/api/v2/lifecycle_environment_paths_controller.rb +17 -1
  9. data/app/controllers/foreman_ansible_director/api/v2/status_controller.rb +5 -3
  10. data/app/controllers/foreman_ansible_director/concerns/filtered_auto_complete_search.rb +34 -0
  11. data/app/controllers/foreman_ansible_director/concerns/foreman/controller/host_extensions.rb +34 -0
  12. data/app/controllers/foreman_ansible_director/concerns/foreman/controller/hostgroup_extensions.rb +34 -0
  13. data/app/lib/foreman_ansible_director/abstract/content_resolution_node.rb +4 -0
  14. data/app/lib/foreman_ansible_director/abstract/variables/value_query.rb +13 -0
  15. data/app/lib/foreman_ansible_director/abstract/variables/value_transformer.rb +13 -0
  16. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/extract_variables.rb +55 -19
  17. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import.rb +16 -2
  18. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/import_collection.rb +2 -1
  19. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/rescue.rb +4 -8
  20. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/update_collection.rb +4 -1
  21. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/import_collection.rb +2 -1
  22. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/rescue.rb +4 -8
  23. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/dynamic/index_git_collection.rb +5 -4
  24. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_git_collection.rb +5 -4
  25. data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_static.rb +10 -8
  26. data/app/lib/foreman_ansible_director/actions/proxy/build_execution_environment.rb +12 -3
  27. data/app/lib/foreman_ansible_director/actions/remote_execution/Provider/ansible_navigator_provider.rb +23 -7
  28. data/app/lib/foreman_ansible_director/actions/remote_execution/Provider/ansible_script_provider.rb +23 -11
  29. data/app/lib/foreman_ansible_director/actions/rescue/ansible_content_unit/common/cleanup_check.rb +2 -1
  30. data/app/lib/foreman_ansible_director/ansible_variable_value/query/local.rb +17 -0
  31. data/app/lib/foreman_ansible_director/ansible_variable_value/transformer/static.rb +16 -0
  32. data/app/lib/foreman_ansible_director/ansible_variable_value/value_resolution.rb +26 -0
  33. data/app/lib/foreman_ansible_director/generators/variable_generator.rb +40 -22
  34. data/app/lib/foreman_ansible_director/issues/base_issue.rb +0 -7
  35. data/app/lib/foreman_ansible_director/issues/critical_error_exception.rb +8 -0
  36. data/app/lib/foreman_ansible_director/issues/errors/base_error.rb +13 -1
  37. data/app/lib/foreman_ansible_director/issues/errors/internal_error.rb +36 -0
  38. data/app/lib/foreman_ansible_director/issues/errors/invalid_yaml_error.rb +33 -0
  39. data/app/lib/foreman_ansible_director/issues/errors/no_proxy_for_build.rb +27 -0
  40. data/app/lib/foreman_ansible_director/issues/errors/parameter_missing_error.rb +30 -0
  41. data/app/lib/foreman_ansible_director/issues/errors/record_not_found.rb +29 -0
  42. data/app/lib/foreman_ansible_director/issues/errors/staging_product_missing.rb +31 -0
  43. data/app/lib/foreman_ansible_director/issues/warnings/base_warning.rb +9 -1
  44. data/app/lib/foreman_ansible_director/issues/warnings/invalid_collection_role_reference.rb +37 -0
  45. data/app/lib/foreman_ansible_director/issues/warnings/invalid_collection_role_variable_ref.rb +42 -0
  46. data/app/lib/foreman_ansible_director/issues/warnings/invalid_role_reference.rb +34 -0
  47. data/app/lib/foreman_ansible_director/issues/warnings/invalid_role_variable_ref.rb +40 -0
  48. data/app/lib/foreman_ansible_director/issues/warnings/no_resolution_candidate_for_variable_binding.rb +28 -0
  49. data/app/lib/foreman_ansible_director/parsers/proxy/dynflow/task_status_parser.rb +3 -5
  50. data/app/models/foreman_ansible_director/ansible_collection.rb +0 -4
  51. data/app/models/foreman_ansible_director/ansible_collection_role.rb +8 -0
  52. data/app/models/foreman_ansible_director/ansible_director_model.rb +6 -0
  53. data/app/models/foreman_ansible_director/ansible_role.rb +0 -3
  54. data/app/models/foreman_ansible_director/ansible_variable.rb +36 -19
  55. data/app/models/foreman_ansible_director/ansible_variable_binding.rb +47 -0
  56. data/app/models/foreman_ansible_director/concerns/ansible_execution_extensions.rb +57 -0
  57. data/app/models/foreman_ansible_director/concerns/content_consumer.rb +2 -0
  58. data/app/models/foreman_ansible_director/concerns/host_extensions.rb +4 -0
  59. data/app/models/foreman_ansible_director/concerns/hostgroup_extensions.rb +5 -1
  60. data/app/models/foreman_ansible_director/concerns/organization_extensions.rb +4 -0
  61. data/app/models/foreman_ansible_director/content_unit.rb +3 -0
  62. data/app/models/foreman_ansible_director/content_unit_version.rb +6 -0
  63. data/app/models/foreman_ansible_director/execution_environment.rb +41 -9
  64. data/app/models/foreman_ansible_director/lifecycle_environment.rb +40 -0
  65. data/app/models/foreman_ansible_director/lifecycle_environment_path.rb +17 -0
  66. data/app/overrides/hosts_ansible_content_tab.rb +15 -0
  67. data/app/services/foreman_ansible_director/ansible_director_build_proxy_selector.rb +16 -0
  68. data/app/services/foreman_ansible_director/ansible_director_run_proxy_selector.rb +12 -0
  69. data/app/services/foreman_ansible_director/assignment_service.rb +41 -24
  70. data/app/services/foreman_ansible_director/concerns/organization_creator_extensions.rb +24 -0
  71. data/app/services/foreman_ansible_director/execution_environment_service.rb +46 -1
  72. data/app/services/foreman_ansible_director/proxy/base_client.rb +2 -2
  73. data/app/services/foreman_ansible_director/proxy/dynflow/single_batch_action.rb +2 -2
  74. data/app/services/foreman_ansible_director/proxy/dynflow/task_status.rb +2 -2
  75. data/app/services/foreman_ansible_director/request_ctx/request_context.rb +15 -18
  76. data/app/services/foreman_ansible_director/variable_binding_service.rb +53 -0
  77. data/app/services/foreman_ansible_director/variable_service.rb +241 -95
  78. data/app/views/foreman_ansible_director/api/v2/ansible_content/version_detail.json.rabl +3 -16
  79. data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/create.json.rabl +3 -0
  80. data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/destroy.json.rabl +3 -0
  81. data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/index_for_variable.json.rabl +9 -0
  82. data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/show.json.rabl +7 -0
  83. data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/update_full.json.rabl +3 -0
  84. data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/update_partial.json.rabl +3 -0
  85. data/app/views/foreman_ansible_director/api/v2/ansible_variables/index_acr.json.rabl +9 -0
  86. data/app/views/foreman_ansible_director/api/v2/ansible_variables/resolve_single.json.rabl +34 -0
  87. data/app/views/foreman_ansible_director/api/v2/ansible_variables/show.json.rabl +3 -18
  88. data/app/views/foreman_ansible_director/api/v2/ansible_variables/update_full.json.rabl +7 -0
  89. data/app/views/foreman_ansible_director/api/v2/ansible_variables/update_partial.json.rabl +7 -0
  90. data/app/views/foreman_ansible_director/api/v2/ansible_variables/variables_for_target.json.rabl +58 -0
  91. data/app/views/foreman_ansible_director/api/v2/assignments/assignments.json.rabl +8 -0
  92. data/app/views/foreman_ansible_director/api/v2/assignments/preresolve.json.rabl +70 -0
  93. data/app/views/foreman_ansible_director/api/v2/common/response.json.rabl +1 -1
  94. data/app/views/foreman_ansible_director/api/v2/execution_environments/create.json.rabl +3 -0
  95. data/app/views/foreman_ansible_director/api/v2/execution_environments/destroy.json.rabl +3 -0
  96. data/app/views/foreman_ansible_director/api/v2/execution_environments/update.json.rabl +3 -0
  97. data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/create.json.rabl +3 -0
  98. data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/destroy.json.rabl +3 -0
  99. data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/promote.json.rabl +3 -0
  100. data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/show.json.rabl +7 -0
  101. data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/update.json.rabl +3 -0
  102. data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/create.json.rabl +3 -0
  103. data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/destroy.json.rabl +3 -0
  104. data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/show.json.rabl +3 -35
  105. data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/update.json.rabl +3 -0
  106. data/app/views/foreman_ansible_director/overrides/_hostgroups_main_fields.erb +2 -0
  107. data/app/views/foreman_ansible_director/overrides/_hostgroups_tab_content.erb +1 -0
  108. data/app/views/foreman_ansible_director/overrides/_hosts_main_fields.erb +34 -0
  109. data/app/views/foreman_ansible_director/overrides/_hosts_tab_content.erb +12 -0
  110. data/app/views/foreman_ansible_director/overrides/_hosts_tab_title.erb +3 -0
  111. data/config/routes.rb +28 -16
  112. data/db/migrate/20260630000001_scope_execution_environment_names_to_organization.rb +14 -0
  113. data/db/migrate/20260630000002_scope_content_unit_identity_to_organization.rb +14 -0
  114. data/db/migrate/20260727000001_ad_variable_redesign.rb +51 -0
  115. data/db/seeds.d/100-provision_after_build_params.rb +10 -0
  116. data/lib/foreman_ansible_director/constants.rb +5 -1
  117. data/lib/foreman_ansible_director/engine.rb +8 -1
  118. data/lib/foreman_ansible_director/register.rb +51 -22
  119. data/lib/foreman_ansible_director/remote_execution.rb +7 -0
  120. data/lib/tasks/create_staging_products.rake +34 -0
  121. data/package.json +18 -15
  122. data/test/controllers/api/v2/ansible_content_controller_test.rb +142 -0
  123. data/test/controllers/api/v2/execution_environments_controller_test.rb +146 -0
  124. data/test/controllers/api/v2/lifecycle_environment_paths_controller_test.rb +126 -0
  125. data/test/factories/ansible_variable_bindings_factory.rb +51 -0
  126. data/test/factories/ansible_variables_factory.rb +32 -5
  127. data/test/factories/extensions.rb +13 -0
  128. data/test/foreman_ansible_director_test_helper.rb +6 -0
  129. data/test/generators/unit/variable_generator_test.rb +248 -74
  130. data/test/models/unit/ansible_variable_binding_test.rb +250 -0
  131. data/test/models/unit/ansible_variable_test.rb +160 -17
  132. data/test/models/unit/content_unit_test.rb +74 -0
  133. data/test/models/unit/execution_environment_test.rb +90 -3
  134. data/test/services/unit/assignment_service_test.rb +14 -22
  135. data/test/services/unit/execution_environment_service_test.rb +44 -0
  136. data/test/services/unit/variable_service_test.rb +474 -337
  137. data/webpack/components/ansible_content/AnsibleContentPageWrapper.tsx +6 -3
  138. data/webpack/components/ansible_content/components/AnsibleContentTable.tsx +23 -34
  139. data/webpack/components/ansible_content/components/AnsibleContentTableSecondaryRow.tsx +17 -27
  140. data/webpack/components/ansible_content/components/AnsibleContentTableWrapper.tsx +14 -13
  141. data/webpack/components/ansible_content/components/AnsibleContentWizard/AnsibleContentWizard.tsx +2 -2
  142. data/webpack/components/ansible_content/components/AnsibleContentWizard/components/ProviderSelectionStep.tsx +6 -2
  143. data/webpack/components/ansible_content/components/AnsibleContentWizard/components/ReviewStep.tsx +2 -2
  144. data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GalaxyContentUnitInput.tsx +6 -5
  145. data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GitContentUnitInput.tsx +10 -12
  146. data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/components/GitRefInput.tsx +2 -5
  147. data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/components/VersionInput.tsx +2 -5
  148. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/{MatcherSelector.tsx → TargetNodeSelector.tsx} +50 -44
  149. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/ValueAdapters/ArrayAdapter.tsx +209 -0
  150. data/webpack/components/ansible_content/components/Variables/CollectionOverviewWrapper.tsx +49 -0
  151. data/webpack/components/ansible_content/components/Variables/CollectionRoleOverview.tsx +140 -0
  152. data/webpack/components/ansible_content/components/Variables/ManagementDrawer.tsx +89 -0
  153. data/webpack/components/ansible_content/components/Variables/VariableList.tsx +166 -0
  154. data/webpack/components/ansible_content/components/Variables/VariableListWrapper.tsx +59 -0
  155. data/webpack/components/ansible_content/components/Variables/components/DrawerBindingContent.tsx +170 -0
  156. data/webpack/components/ansible_content/components/Variables/components/DrawerBindingContentWrapper.tsx +62 -0
  157. data/webpack/components/ansible_content/components/Variables/components/DrawerVariableContent.tsx +134 -0
  158. data/webpack/components/ansible_content/components/Variables/components/components/BindingCreateContent.tsx +174 -0
  159. data/webpack/components/ansible_content/components/Variables/components/components/BindingDetailsContent.tsx +95 -0
  160. data/webpack/components/ansible_content/components/Variables/components/components/BindingIndexContent.tsx +181 -0
  161. data/webpack/components/ansible_environments/AnsibleEnvironmentsPageWrapper.tsx +6 -3
  162. data/webpack/components/ansible_environments/components/AnsibleLcePathIndexWrapper.tsx +19 -19
  163. data/webpack/components/ansible_environments/components/components/AnsibleExecutionEnvSelectionModal.tsx +4 -3
  164. data/webpack/components/ansible_environments/components/components/AnsibleExecutionEnvSelectionModalWrapper.tsx +1 -1
  165. data/webpack/components/ansible_environments/components/components/AnsibleLceComponent.tsx +1 -1
  166. data/webpack/components/ansible_environments/components/components/AnsibleLceComponentWrapper.tsx +3 -2
  167. data/webpack/components/ansible_environments/components/components/AnsibleLcePathComponent.tsx +35 -121
  168. data/webpack/components/ansible_environments/components/components/AnsibleLibraryOverview.tsx +4 -5
  169. data/webpack/components/ansible_execution_environments/AnsibleExecutionEnvPageWrapper.tsx +6 -3
  170. data/webpack/components/ansible_execution_environments/components/ContentUnitModal.tsx +4 -4
  171. data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardHeaderActions.tsx +15 -13
  172. data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardWrapper.tsx +22 -86
  173. data/webpack/components/ansible_execution_environments/components/ExecutionEnvCreateCard.tsx +69 -67
  174. data/webpack/components/ansible_execution_environments/components/ExecutionEnvGridWrapper.tsx +16 -39
  175. data/webpack/components/ansible_execution_environments/components/components/components/ContentUnitSelector.tsx +1 -2
  176. data/webpack/components/common/Alerts/AlertContext.tsx +174 -0
  177. data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignment.tsx +183 -185
  178. data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentMain.tsx +15 -57
  179. data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentWrapper.tsx +59 -63
  180. data/webpack/components/common/AnsibleContentAssignment/AssignmentContext.tsx +289 -0
  181. data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelector.tsx +21 -29
  182. data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelectorWrapper.tsx +14 -65
  183. data/webpack/components/common/AnsibleContentAssignment/components/ContentAssignmentTable.tsx +32 -32
  184. data/webpack/components/common/AnsibleContentAssignment/components/Variables/VariableContext.tsx +169 -0
  185. data/webpack/components/common/AnsibleContentAssignment/components/Variables/VariableTableWrapper.tsx +41 -0
  186. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/BindingDetailModal.tsx +515 -0
  187. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/BindingDetailModalWrapper.tsx +97 -0
  188. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/InlineValueRenderer.tsx +68 -0
  189. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/ValuePresenter.tsx +202 -0
  190. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariableAssignmentTableToolbar.tsx +34 -0
  191. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesAssignmentTable.tsx +112 -0
  192. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesTable.tsx +173 -0
  193. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesTableToolbar.tsx +34 -0
  194. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/CrossNodeDisabledAlert.tsx +46 -0
  195. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/DetailsCard.tsx +168 -0
  196. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/ValueCard.tsx +143 -0
  197. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/ValueCardWrapper.tsx +77 -0
  198. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlErrorState.tsx +40 -0
  199. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlParsedTypeMismatchErrorState.tsx +35 -0
  200. data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlParserErrorState.tsx +38 -0
  201. data/webpack/components/common/AnsibleContentAssignment/components/Variables/utils.ts +70 -0
  202. data/webpack/components/common/AnsibleContentAssignment/helpers.ts +12 -10
  203. data/webpack/components/common/Page.tsx +0 -2
  204. data/webpack/components/common/YamlEditor.tsx +30 -20
  205. data/webpack/components/extensions/components/InheritComponent.tsx +0 -1
  206. data/webpack/components/extensions/host_details/HostDetailsLceCard/HostDetailsLceCard.tsx +8 -10
  207. data/webpack/components/extensions/host_details/HostDetailsTab/HostDetailsTab.tsx +10 -7
  208. data/webpack/helpers/adContext.ts +2 -0
  209. data/webpack/helpers/components/ConfirmationModal.tsx +5 -2
  210. data/webpack/helpers/constants.ts +0 -20
  211. data/webpack/helpers/hooks/useFetch.ts +104 -0
  212. data/webpack/helpers/hooks/useLegacySelectValue.tsx +67 -0
  213. data/webpack/helpers/toasts/crudToasts.tsx +75 -0
  214. data/webpack/helpers/toasts/promoteToasts.tsx +53 -0
  215. data/webpack/helpers/toasts/useToasts.tsx +142 -0
  216. data/webpack/resources/backendClient.ts +150 -0
  217. data/webpack/resources/clients/AnsibleVariable.ts +78 -0
  218. data/webpack/resources/clients/AnsibleVariableBinding.ts +104 -0
  219. data/webpack/resources/clients/ExecutionEnvironment.ts +77 -0
  220. data/webpack/resources/clients/LifecycleEnvironmentPath.ts +114 -0
  221. data/webpack/resources/types.ts +13 -0
  222. data/webpack/resources/utils.ts +12 -0
  223. data/webpack/types/AnsibleContentAssignmentTypes.d.ts +9 -19
  224. data/webpack/types/AnsibleContentTypes.d.ts +7 -5
  225. data/webpack/types/AnsibleEnvironmentsTypes.d.ts +0 -4
  226. data/webpack/types/AnsibleExecutionEnvTypes.d.ts +1 -10
  227. data/webpack/types/AnsibleVariableTypes.d.ts +64 -37
  228. data/webpack/types/DynamicAssignmentTypes.d.ts +22 -0
  229. data/webpack/types/common.d.ts +1 -1
  230. data/webpack/types/foremanReact/Root/Context/ForemanContext.d.ts +2 -5
  231. data/webpack/types/foremanReact/common/hooks/API/APIHooks.d.ts +0 -2
  232. data/webpack/types/foremanReact/components/Pagination/index.d.ts +0 -1
  233. data/webpack/types/foremanReact/components/ToastsList/slice.d.ts +3 -1
  234. data/webpack/types/issues/errors.d.ts +4 -3
  235. data/webpack/types/issues/types.ts +5 -0
  236. data/webpack/types/issues/warnings.d.ts +4 -2
  237. metadata +125 -90
  238. data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_overrides_controller.rb +0 -203
  239. data/app/models/foreman_ansible_director/concerns/lookup_keys_extensions.rb +0 -13
  240. data/app/overrides/create_host_ansible_tab.rb +0 -15
  241. data/app/services/foreman_ansible_director/ansible_director_proxy_selector.rb +0 -20
  242. data/app/views/foreman_ansible_director/api/v2/ansible_variable_overrides/index_for_target.json.rabl +0 -35
  243. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesOverview.tsx +0 -103
  244. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesSelector.tsx +0 -319
  245. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideCard.tsx +0 -144
  246. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideManagementModal.tsx +0 -328
  247. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverridesTabContent.tsx +0 -313
  248. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalContent.tsx +0 -392
  249. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalWrapper.tsx +0 -81
  250. data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/tabConstants.ts +0 -2
  251. data/webpack/components/common/AnsibleContentAssignment/components/Variables/MergedOverrideCard.tsx +0 -310
  252. data/webpack/components/common/AnsibleContentAssignment/components/Variables/OverrideGrid.tsx +0 -80
  253. data/webpack/components/common/AnsibleContentAssignment/components/Variables/OverrideGridWrapper.tsx +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bfa5c13b50ecdad46dceeb00e2691c16c586e8060094b5fe21eb1b19ae0eb60
4
- data.tar.gz: 12749d98c77fe7008baf803bdfcc627b428f82f1192da8f904602611dbbac9f6
3
+ metadata.gz: 20d1091937c1d76ecd26e040e861d757cc36110d28a60e74630b3cfb168db165
4
+ data.tar.gz: f1da955ee815b2f80233760544a9732daa44ca6713996b048f2f8b20d374b745
5
5
  SHA512:
6
- metadata.gz: 8650021501539c07fc71f21cacaea22dae5abe0066b209354b9ae68b8bc2d802c7ea5440c55df65b3d53f5b218b67bcbdb7d88c9699cd6c2219bd46749c69e17
7
- data.tar.gz: 5537935a1c0f62ca5a3465b7fc998bb713e8dd22a2fdfa193b5db14a6e1176367112268124f2bb879d139bd8740706e44d620347c60e40e251c6386975130efb
6
+ metadata.gz: b0a246ed2de42e751eac1f80e11b1fc10350a68b83babfcfceeed2df2a72cb76455f8d3094e18cafea12d973ba76d974586a561151fae60378bc9005e8d0b942
7
+ data.tar.gz: c13404a68266d31c7535b2658a10f8a67ee3a047cb1a817d1d475df981f2ac2461e48b9a2703b9f605a8ad9a3805c2ab80ff4a102ed420d30f505c45fb33aa51
@@ -5,7 +5,9 @@ module ForemanAnsibleDirector
5
5
  module V2
6
6
  class AnsibleContentController < AnsibleDirectorApiController
7
7
  before_action :find_organization, only: %i[create_units]
8
- before_action :find_optional_organization, only: %i[index]
8
+ # rubocop:disable Rails/LexicallyScopedActionFilter
9
+ before_action :find_optional_organization, only: %i[index auto_complete_search]
10
+ # rubocop:enable Rails/LexicallyScopedActionFilter
9
11
 
10
12
  resource_description { resource_id 'AD Ansible Content' }
11
13
 
@@ -72,14 +74,10 @@ module ForemanAnsibleDirector
72
74
  api :GET, '/v2/ansible_director/ansible_content', N_('List Ansible content units')
73
75
  param :organization_id, :number, desc: N_('Organization identifier'), required: false
74
76
  param_group :search_and_pagination, ::Api::V2::BaseController
77
+ add_scoped_search_description_for(::ForemanAnsibleDirector::ContentUnit)
75
78
  # endregion
76
79
  def index
77
- scope = resource_scope_for_index
78
- @ansible_content_units = if @organization
79
- scope.where(organization_id: @organization.id)
80
- else
81
- scope
82
- end
80
+ @ansible_content_units = resource_scope_for_index
83
81
  end
84
82
 
85
83
  # region ApiDoc: GET /api/v2/ansible_director/ansible_content/:content_unit_id/versions/:content_unit_version_id
@@ -146,6 +144,10 @@ module ForemanAnsibleDirector
146
144
  resource_class
147
145
  end
148
146
 
147
+ def resource_scope
148
+ organization_scoped_resource_scope
149
+ end
150
+
149
151
  private
150
152
 
151
153
  def destroy_params
@@ -165,11 +167,6 @@ module ForemanAnsibleDirector
165
167
  def resource_class
166
168
  ::ForemanAnsibleDirector::ContentUnit
167
169
  end
168
-
169
- def index_relation
170
- units = AnsibleContentUnit
171
- units.where organization_id: (params[:organization_id] || @organization.id)
172
- end
173
170
  end
174
171
  end
175
172
  end
@@ -5,12 +5,41 @@ module ForemanAnsibleDirector
5
5
  module V2
6
6
  class AnsibleDirectorApiController < ::Api::V2::BaseController
7
7
  include ::Api::Version2
8
- include ::Foreman::Controller::AutoCompleteSearch
8
+ include ::ForemanAnsibleDirector::Concerns::FilteredAutoCompleteSearch
9
9
 
10
10
  include ::ForemanAnsibleDirector::RequestCtx::RequestContextHelper
11
11
 
12
12
  around_action :attach_request_ctx
13
13
 
14
+ rescue_from StandardError do |error|
15
+ @ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::InternalError.new(
16
+ exception: error,
17
+ coincidence_id: @ctx.coincidence_id
18
+ ))
19
+ render_default_response
20
+ # Re-raise the exception to get a traceback in the log
21
+ raise error
22
+ end
23
+
24
+ rescue_from ActiveRecord::RecordNotFound do |error|
25
+ @ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::RecordNotFound.new(exception: error))
26
+ render_default_response
27
+ end
28
+
29
+ rescue_from ActionController::ParameterMissing do |error|
30
+ @ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::ParameterMissingError.new(exception: error))
31
+ render_default_response
32
+ end
33
+
34
+ rescue_from Psych::SyntaxError do |error|
35
+ @ctx.add_error(::ForemanAnsibleDirector::Issues::Errors::InvalidYamlError.new(exception: error))
36
+ render_default_response
37
+ end
38
+
39
+ rescue_from ::ForemanAnsibleDirector::Issues::CriticalErrorException do |_|
40
+ render_default_response
41
+ end
42
+
14
43
  def attach_request_ctx
15
44
  ::ForemanAnsibleDirector::RequestCtx::RequestContext.with_context(
16
45
  ::ForemanAnsibleDirector::RequestCtx::RequestContext.new(request.request_id)
@@ -20,8 +49,13 @@ module ForemanAnsibleDirector
20
49
  end
21
50
  end
22
51
 
52
+ def render_default_response
53
+ return if performed?
54
+ render template: 'foreman_ansible_director/api/v2/common/response', status: @ctx.response_status_code
55
+ end
56
+
23
57
  def find_organization
24
- @organization = Organization.current || find_optional_organization
58
+ @organization = find_optional_organization || Organization.current
25
59
  if @organization.nil?
26
60
  render_error(
27
61
  'custom_error',
@@ -34,6 +68,29 @@ module ForemanAnsibleDirector
34
68
  @organization
35
69
  end
36
70
 
71
+ def organization_scoped_resource_scope(scope = resource_class.all)
72
+ return scope.none if User.current.blank?
73
+ organization = @organization || Organization.current
74
+ if organization.nil?
75
+ if User.current.admin?
76
+ scope
77
+ else
78
+ scope.where(organization_id: User.current.my_organizations)
79
+ end
80
+ else
81
+ scope.where(organization_id: organization.id)
82
+ end
83
+ end
84
+
85
+ def action_permission
86
+ case params[:action]
87
+ when 'auto_complete_search'
88
+ :view
89
+ else
90
+ super
91
+ end
92
+ end
93
+
37
94
  private
38
95
 
39
96
  def organization_id_keys
@@ -50,7 +107,7 @@ module ForemanAnsibleDirector
50
107
 
51
108
  @organization = get_organization(org_id)
52
109
  if @organization.nil?
53
- render_error('custom_error', status: :unprocessable_entity,
110
+ render_error('custom_error', status: :not_found,
54
111
  locals: { message: "Couldn't find organization #{org_id}" })
55
112
  end
56
113
  @organization
@@ -0,0 +1,347 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAnsibleDirector
4
+ module Api
5
+ module V2
6
+ class AnsibleVariableBindingsController < AnsibleDirectorApiController
7
+ before_action :find_resource, only: %w[show destroy update_full update_partial]
8
+ before_action :find_variable, only: [:index_for_variable]
9
+
10
+ before_action :find_organization, only: %i[create]
11
+ # rubocop:disable Rails/LexicallyScopedActionFilter
12
+ before_action :find_optional_organization, only: %i[index_for_variable auto_complete_search]
13
+ # rubocop:enable Rails/LexicallyScopedActionFilter
14
+ resource_description { resource_id 'AD Ansible Variable Bindings' }
15
+
16
+ def index_for_variable
17
+ end
18
+
19
+ # region ApiDoc: GET /api/v2/ansible_director/ansible_variables/bindings/:id
20
+ api :GET, '/v2/ansible_director/ansible_variables/bindings/:id', N_('Show details of a variable binding')
21
+ param :id, :number, desc: N_('Variable binding identifier'), required: true
22
+ # endregion
23
+ def show
24
+ end
25
+
26
+ # region ApiDoc: POST /api/v2/ansible_director/ansible_variables/bindings
27
+ api :POST, '/api/v2/ansible_director/ansible_variables/bindings', N_('Create a variable binding')
28
+ param :organization_id, :number, desc: N_('Organization identifier'), required: true
29
+ param :ansible_variable_binding, Hash, desc: N_('Variable binding definition'), required: true do
30
+ param :variable_name,
31
+ String,
32
+ desc: N_('Name of the Ansible variable to bind.'),
33
+ example: 'ntp_server',
34
+ required: true
35
+ param :data_type,
36
+ %w[string integer boolean float array dictionary],
37
+ desc: N_('Data type of the variable.'),
38
+ example: 'string',
39
+ required: true
40
+ param :raw_value,
41
+ String,
42
+ desc: N_('Value of the variable (must be valid YAML for any type).'),
43
+ example: "---\ntime.example.com",
44
+ required: true
45
+ param :assignable_type,
46
+ %w[ForemanAnsibleDirector::AnsibleCollectionRole ForemanAnsibleDirector::AnsibleRole],
47
+ desc: N_('Type of the assignable ForemanAnsibleDirector::(AnsibleCollectionRole | AnsibleRole).'),
48
+ required: true
49
+ param :assignable_namespace,
50
+ String,
51
+ desc: N_('Namespace of the assignable.'),
52
+ example: 'my_namespace',
53
+ required: true
54
+ param :assignable_name,
55
+ String,
56
+ desc: N_('Name of the assignable.'),
57
+ example: 'my_collection',
58
+ required: true
59
+ param :assignable_role_name,
60
+ String,
61
+ desc: N_('Name of the role within the collection (required for AnsibleCollectionRole).'),
62
+ example: 'my_role',
63
+ required: false
64
+ param :target,
65
+ String,
66
+ desc: N_('Target type for the binding (host | hostgroup).'),
67
+ example: 'host',
68
+ required: true
69
+ param :target_id,
70
+ :number,
71
+ desc: N_('ID of the target entity.'),
72
+ example: 1,
73
+ required: true
74
+ end
75
+ # TRANSLATORS: ApiDoc, do not translate!
76
+ example <<~EXAMPLE
77
+ {
78
+ "organization_id": 1,
79
+ "ansible_variable_binding": {
80
+ "variable_name": "ntp_server",
81
+ "data_type": "string",
82
+ "raw_value": "---\\ntime.example.com",
83
+ "assignable_type": "ForemanAnsibleDirector::AnsibleCollectionRole",
84
+ "assignable_namespace": "my_namespace",
85
+ "assignable_name": "my_collection",
86
+ "assignable_role_name": "my_role",
87
+ "target": "host",
88
+ "target_id": 1
89
+ }
90
+ }
91
+ EXAMPLE
92
+ # endregion
93
+ def create
94
+ binding_params = variable_binding_create_params
95
+ validate_yaml! variable_binding_create_params[:raw_value]
96
+
97
+ target = ::ForemanAnsibleDirector::AssignmentService.find_target(
98
+ target_type: binding_params[:target],
99
+ target_id: binding_params[:target_id]
100
+ )
101
+
102
+ @created_binding = ::ForemanAnsibleDirector::VariableBindingService.create_variable_binding(
103
+ variable_name: binding_params[:variable_name],
104
+ data_type: binding_params[:data_type],
105
+ raw_value: binding_params[:raw_value],
106
+ target: target,
107
+ assignable_type: binding_params[:assignable_type],
108
+ assignable_namespace: binding_params[:assignable_namespace],
109
+ assignable_name: binding_params[:assignable_name],
110
+ assignable_role_name: binding_params[:assignable_role_name],
111
+ organization_id: @organization.id
112
+ )
113
+ end
114
+
115
+ # region ApiDoc: PUT /api/v2/ansible_director/ansible_variables/bindings/:id
116
+ api :PUT, '/v2/ansible_director/ansible_variables/bindings/:id', N_('Update a variable binding')
117
+ description <<~DESC
118
+ Replace an entire variable binding. All binding attributes have to be provided. To update only a subset of+
119
+ arguments, consider using PATCH.
120
+ DESC
121
+ param :ansible_variable_binding, Hash, desc: N_('Variable binding updates'), required: true do
122
+ param :variable_name,
123
+ String,
124
+ desc: N_('Name of the Ansible variable to bind.'),
125
+ example: 'ntp_server',
126
+ required: true
127
+ param :data_type,
128
+ %w[string integer boolean float array dictionary],
129
+ desc: N_('Data type of the variable.'),
130
+ example: 'string',
131
+ required: true
132
+ param :raw_value,
133
+ String,
134
+ desc: N_('Value of the variable (must be valid YAML for any type).'),
135
+ example: '---\\ntime.example.com',
136
+ required: true
137
+ param :assignable_type,
138
+ %w[ForemanAnsibleDirector::AnsibleCollectionRole ForemanAnsibleDirector::AnsibleRole],
139
+ desc: N_('Type of the assignable ForemanAnsibleDirector::(AnsibleCollectionRole | AnsibleRole).'),
140
+ required: true
141
+ param :assignable_namespace,
142
+ String,
143
+ desc: N_('Namespace of the assignable.'),
144
+ example: 'my_namespace',
145
+ required: true
146
+ param :assignable_name,
147
+ String,
148
+ desc: N_('Name of the assignable.'),
149
+ example: 'my_collection',
150
+ required: true
151
+ param :assignable_role_name,
152
+ String,
153
+ desc: N_('Name of the role within the collection (required for AnsibleCollectionRole).'),
154
+ example: 'my_role',
155
+ required: false
156
+ param :target,
157
+ String,
158
+ desc: N_('Target type for the binding (host | hostgroup).'),
159
+ example: 'host',
160
+ required: true
161
+ param :target_id,
162
+ :number,
163
+ desc: N_('ID of the target entity.'),
164
+ example: 1,
165
+ required: true
166
+ end
167
+ # TRANSLATORS: ApiDoc, do not translate!
168
+ example <<~EXAMPLE
169
+ {
170
+ "ansible_variable_binding": {
171
+ "data_type": "string",
172
+ "raw_value": "---\\ntime.example.com",
173
+ "variable_name": "ntp_server",
174
+ "assignable_type": "ForemanAnsibleDirector::AnsibleCollectionRole",
175
+ "assignable_namespace": "my_namespace",
176
+ "assignable_name": "my_collection",
177
+ "assignable_role_name": "my_role",
178
+ "target": "host",
179
+ "target_id": 1
180
+ }
181
+ }
182
+ EXAMPLE
183
+ # endregion
184
+ def update_full
185
+ variable_binding_params = variable_binding_full_params
186
+ validate_yaml! variable_binding_full_params[:raw_value]
187
+
188
+ ::ForemanAnsibleDirector::VariableBindingService.edit_variable_binding(
189
+ variable_binding: @ansible_variable_binding,
190
+ **variable_binding_params
191
+ )
192
+ end
193
+
194
+ # region ApiDoc: PATCH /api/v2/ansible_director/ansible_variables/bindings/:id
195
+ api :PATCH, '/api/v2/ansible_director/ansible_variables/bindings/:id', N_('Partially update a variable binding')
196
+ description <<~DESC
197
+ Partially update an Ansible variable binding. To update every binding attribute, consider using PUT, which
198
+ informs you of missing attributes.
199
+ DESC
200
+ param :ansible_variable_binding, Hash, desc: N_('Variable binding updates'), required: true do
201
+ param :variable_name,
202
+ String,
203
+ desc: N_('Name of the Ansible variable to bind.'),
204
+ example: 'ntp_server',
205
+ required: false
206
+ param :data_type,
207
+ %w[string integer boolean float array dictionary],
208
+ desc: N_('Data type of the variable.'),
209
+ required: false
210
+ param :raw_value,
211
+ String,
212
+ desc: N_('Value of the variable (must be valid YAML for any type).'),
213
+ example: "---\ntime.example.com",
214
+ required: false
215
+ param :assignable_type,
216
+ %w[ForemanAnsibleDirector::AnsibleCollectionRole ForemanAnsibleDirector::AnsibleRole],
217
+ desc: N_('Type of the assignable ForemanAnsibleDirector::(AnsibleCollectionRole | AnsibleRole).'),
218
+ example: 'ForemanAnsibleDirector::AnsibleCollectionRole',
219
+ required: false
220
+ param :assignable_namespace,
221
+ String,
222
+ desc: N_('Namespace of the assignable.'),
223
+ example: 'my_namespace',
224
+ required: false
225
+ param :assignable_name,
226
+ String,
227
+ desc: N_('Name of the assignable.'),
228
+ example: 'my_collection',
229
+ required: false
230
+ param :assignable_role_name,
231
+ String,
232
+ desc: N_('Name of the role within the collection (required for AnsibleCollectionRole).'),
233
+ example: 'my_role',
234
+ required: false
235
+ param :target,
236
+ String,
237
+ desc: N_('Target type for the binding (host | hostgroup).'),
238
+ example: 'host',
239
+ required: false
240
+ param :target_id,
241
+ :number,
242
+ desc: N_('ID of the target entity.'),
243
+ example: 1,
244
+ required: false
245
+ end
246
+ # TRANSLATORS: ApiDoc, do not translate!
247
+ example <<~EXAMPLE
248
+ {
249
+ "ansible_variable_binding": {
250
+ "raw_value": "---\\nnew-time.example.com"
251
+ }
252
+ }
253
+ EXAMPLE
254
+ # endregion
255
+ def update_partial
256
+ variable_binding_params = variable_binding_partial_params
257
+ validate_yaml! variable_binding_partial_params[:raw_value]
258
+
259
+ ::ForemanAnsibleDirector::VariableBindingService.edit_variable_binding(
260
+ variable_binding: @ansible_variable_binding,
261
+ **variable_binding_params
262
+ )
263
+ end
264
+
265
+ # region ApiDoc: DELETE /api/v2/ansible_director/ansible_variables/bindings/:id
266
+ api :DELETE, '/api/v2/ansible_director/ansible_variables/bindings/:id', N_('Delete a variable binding')
267
+ param :id, :number, desc: N_('Variable Binding identifier'), required: true
268
+ # endregion
269
+ def destroy
270
+ ::ForemanAnsibleDirector::VariableBindingService.destroy_variable_binding(@ansible_variable_binding)
271
+ end
272
+
273
+ def resource_class
274
+ ::ForemanAnsibleDirector::AnsibleVariableBinding
275
+ end
276
+
277
+ def resource_scope
278
+ organization_scoped_resource_scope
279
+ end
280
+
281
+ private
282
+
283
+ def find_variable
284
+ @ansible_variable = ::ForemanAnsibleDirector::AnsibleVariable.find_by!(id: params[:id])
285
+ end
286
+
287
+ def base_params
288
+ root_node = params.require(:ansible_variable_binding)
289
+ root_node.permit(
290
+ :data_type,
291
+ :raw_value,
292
+ :assignable_namespace,
293
+ :assignable_name,
294
+ :assignable_role_name,
295
+ :assignable_type,
296
+ :variable_name,
297
+ :target,
298
+ :target_id
299
+ )
300
+ end
301
+
302
+ def variable_binding_create_params
303
+ root_node = base_params
304
+ {
305
+ **variable_binding_full_params,
306
+ assignable_namespace: root_node.require(:assignable_namespace),
307
+ assignable_name: root_node.require(:assignable_name),
308
+ assignable_role_name: if params[:assignable_type] == 'ForemanAnsibleDirector::AnsibleCollectionRole'
309
+ root_node.require(:assignable_role_name)
310
+ else
311
+ root_node[:assignable_role_name]
312
+ end,
313
+ assignable_type: root_node.require(:assignable_type),
314
+ target: params[:target] || root_node.require(:target),
315
+ target_id: params[:target_id] || root_node.require(:target_id),
316
+ }
317
+ end
318
+
319
+ def variable_binding_full_params
320
+ root_node = base_params
321
+ {
322
+ data_type: root_node.require(:data_type),
323
+ raw_value: root_node.require(:raw_value),
324
+ variable_name: root_node.require(:variable_name),
325
+ }
326
+ end
327
+
328
+ def variable_binding_partial_params
329
+ root_node = base_params
330
+ {
331
+ data_type: root_node[:data_type],
332
+ raw_value: root_node[:raw_value],
333
+ variable_name: root_node[:variable_name],
334
+ }.compact
335
+ end
336
+
337
+ def validate_yaml!(string)
338
+ YAML.safe_load(string)
339
+ end
340
+
341
+ def controller_permission
342
+ 'ansible_director_variable_overrides'
343
+ end
344
+ end
345
+ end
346
+ end
347
+ end