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.
- checksums.yaml +4 -4
- data/app/controllers/foreman_ansible_director/api/v2/ansible_content_controller.rb +9 -12
- data/app/controllers/foreman_ansible_director/api/v2/ansible_director_api_controller.rb +60 -3
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_bindings_controller.rb +347 -0
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variables_controller.rb +204 -31
- data/app/controllers/foreman_ansible_director/api/v2/assignments_controller.rb +60 -4
- data/app/controllers/foreman_ansible_director/api/v2/execution_environments_controller.rb +8 -0
- data/app/controllers/foreman_ansible_director/api/v2/lifecycle_environment_paths_controller.rb +17 -1
- data/app/controllers/foreman_ansible_director/api/v2/status_controller.rb +5 -3
- data/app/controllers/foreman_ansible_director/concerns/filtered_auto_complete_search.rb +34 -0
- data/app/controllers/foreman_ansible_director/concerns/foreman/controller/host_extensions.rb +34 -0
- data/app/controllers/foreman_ansible_director/concerns/foreman/controller/hostgroup_extensions.rb +34 -0
- data/app/lib/foreman_ansible_director/abstract/content_resolution_node.rb +4 -0
- data/app/lib/foreman_ansible_director/abstract/variables/value_query.rb +13 -0
- data/app/lib/foreman_ansible_director/abstract/variables/value_transformer.rb +13 -0
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/extract_variables.rb +55 -19
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import.rb +16 -2
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/import_collection.rb +2 -1
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/rescue.rb +4 -8
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/galaxy/update_collection.rb +4 -1
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/import_collection.rb +2 -1
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/import_providers/git/rescue.rb +4 -8
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/dynamic/index_git_collection.rb +5 -4
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_git_collection.rb +5 -4
- data/app/lib/foreman_ansible_director/actions/ansible_content_unit/index/index_static.rb +10 -8
- data/app/lib/foreman_ansible_director/actions/proxy/build_execution_environment.rb +12 -3
- data/app/lib/foreman_ansible_director/actions/remote_execution/Provider/ansible_navigator_provider.rb +23 -7
- data/app/lib/foreman_ansible_director/actions/remote_execution/Provider/ansible_script_provider.rb +23 -11
- data/app/lib/foreman_ansible_director/actions/rescue/ansible_content_unit/common/cleanup_check.rb +2 -1
- data/app/lib/foreman_ansible_director/ansible_variable_value/query/local.rb +17 -0
- data/app/lib/foreman_ansible_director/ansible_variable_value/transformer/static.rb +16 -0
- data/app/lib/foreman_ansible_director/ansible_variable_value/value_resolution.rb +26 -0
- data/app/lib/foreman_ansible_director/generators/variable_generator.rb +40 -22
- data/app/lib/foreman_ansible_director/issues/base_issue.rb +0 -7
- data/app/lib/foreman_ansible_director/issues/critical_error_exception.rb +8 -0
- data/app/lib/foreman_ansible_director/issues/errors/base_error.rb +13 -1
- data/app/lib/foreman_ansible_director/issues/errors/internal_error.rb +36 -0
- data/app/lib/foreman_ansible_director/issues/errors/invalid_yaml_error.rb +33 -0
- data/app/lib/foreman_ansible_director/issues/errors/no_proxy_for_build.rb +27 -0
- data/app/lib/foreman_ansible_director/issues/errors/parameter_missing_error.rb +30 -0
- data/app/lib/foreman_ansible_director/issues/errors/record_not_found.rb +29 -0
- data/app/lib/foreman_ansible_director/issues/errors/staging_product_missing.rb +31 -0
- data/app/lib/foreman_ansible_director/issues/warnings/base_warning.rb +9 -1
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_collection_role_reference.rb +37 -0
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_collection_role_variable_ref.rb +42 -0
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_role_reference.rb +34 -0
- data/app/lib/foreman_ansible_director/issues/warnings/invalid_role_variable_ref.rb +40 -0
- data/app/lib/foreman_ansible_director/issues/warnings/no_resolution_candidate_for_variable_binding.rb +28 -0
- data/app/lib/foreman_ansible_director/parsers/proxy/dynflow/task_status_parser.rb +3 -5
- data/app/models/foreman_ansible_director/ansible_collection.rb +0 -4
- data/app/models/foreman_ansible_director/ansible_collection_role.rb +8 -0
- data/app/models/foreman_ansible_director/ansible_director_model.rb +6 -0
- data/app/models/foreman_ansible_director/ansible_role.rb +0 -3
- data/app/models/foreman_ansible_director/ansible_variable.rb +36 -19
- data/app/models/foreman_ansible_director/ansible_variable_binding.rb +47 -0
- data/app/models/foreman_ansible_director/concerns/ansible_execution_extensions.rb +57 -0
- data/app/models/foreman_ansible_director/concerns/content_consumer.rb +2 -0
- data/app/models/foreman_ansible_director/concerns/host_extensions.rb +4 -0
- data/app/models/foreman_ansible_director/concerns/hostgroup_extensions.rb +5 -1
- data/app/models/foreman_ansible_director/concerns/organization_extensions.rb +4 -0
- data/app/models/foreman_ansible_director/content_unit.rb +3 -0
- data/app/models/foreman_ansible_director/content_unit_version.rb +6 -0
- data/app/models/foreman_ansible_director/execution_environment.rb +41 -9
- data/app/models/foreman_ansible_director/lifecycle_environment.rb +40 -0
- data/app/models/foreman_ansible_director/lifecycle_environment_path.rb +17 -0
- data/app/overrides/hosts_ansible_content_tab.rb +15 -0
- data/app/services/foreman_ansible_director/ansible_director_build_proxy_selector.rb +16 -0
- data/app/services/foreman_ansible_director/ansible_director_run_proxy_selector.rb +12 -0
- data/app/services/foreman_ansible_director/assignment_service.rb +41 -24
- data/app/services/foreman_ansible_director/concerns/organization_creator_extensions.rb +24 -0
- data/app/services/foreman_ansible_director/execution_environment_service.rb +46 -1
- data/app/services/foreman_ansible_director/proxy/base_client.rb +2 -2
- data/app/services/foreman_ansible_director/proxy/dynflow/single_batch_action.rb +2 -2
- data/app/services/foreman_ansible_director/proxy/dynflow/task_status.rb +2 -2
- data/app/services/foreman_ansible_director/request_ctx/request_context.rb +15 -18
- data/app/services/foreman_ansible_director/variable_binding_service.rb +53 -0
- data/app/services/foreman_ansible_director/variable_service.rb +241 -95
- data/app/views/foreman_ansible_director/api/v2/ansible_content/version_detail.json.rabl +3 -16
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/index_for_variable.json.rabl +9 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/show.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/update_full.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_bindings/update_partial.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/index_acr.json.rabl +9 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/resolve_single.json.rabl +34 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/show.json.rabl +3 -18
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/update_full.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/update_partial.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/ansible_variables/variables_for_target.json.rabl +58 -0
- data/app/views/foreman_ansible_director/api/v2/assignments/assignments.json.rabl +8 -0
- data/app/views/foreman_ansible_director/api/v2/assignments/preresolve.json.rabl +70 -0
- data/app/views/foreman_ansible_director/api/v2/common/response.json.rabl +1 -1
- data/app/views/foreman_ansible_director/api/v2/execution_environments/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/execution_environments/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/execution_environments/update.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/promote.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/show.json.rabl +7 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environment_paths/update.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/create.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/destroy.json.rabl +3 -0
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/show.json.rabl +3 -35
- data/app/views/foreman_ansible_director/api/v2/lifecycle_environments/update.json.rabl +3 -0
- data/app/views/foreman_ansible_director/overrides/_hostgroups_main_fields.erb +2 -0
- data/app/views/foreman_ansible_director/overrides/_hostgroups_tab_content.erb +1 -0
- data/app/views/foreman_ansible_director/overrides/_hosts_main_fields.erb +34 -0
- data/app/views/foreman_ansible_director/overrides/_hosts_tab_content.erb +12 -0
- data/app/views/foreman_ansible_director/overrides/_hosts_tab_title.erb +3 -0
- data/config/routes.rb +28 -16
- data/db/migrate/20260630000001_scope_execution_environment_names_to_organization.rb +14 -0
- data/db/migrate/20260630000002_scope_content_unit_identity_to_organization.rb +14 -0
- data/db/migrate/20260727000001_ad_variable_redesign.rb +51 -0
- data/db/seeds.d/100-provision_after_build_params.rb +10 -0
- data/lib/foreman_ansible_director/constants.rb +5 -1
- data/lib/foreman_ansible_director/engine.rb +8 -1
- data/lib/foreman_ansible_director/register.rb +51 -22
- data/lib/foreman_ansible_director/remote_execution.rb +7 -0
- data/lib/tasks/create_staging_products.rake +34 -0
- data/package.json +18 -15
- data/test/controllers/api/v2/ansible_content_controller_test.rb +142 -0
- data/test/controllers/api/v2/execution_environments_controller_test.rb +146 -0
- data/test/controllers/api/v2/lifecycle_environment_paths_controller_test.rb +126 -0
- data/test/factories/ansible_variable_bindings_factory.rb +51 -0
- data/test/factories/ansible_variables_factory.rb +32 -5
- data/test/factories/extensions.rb +13 -0
- data/test/foreman_ansible_director_test_helper.rb +6 -0
- data/test/generators/unit/variable_generator_test.rb +248 -74
- data/test/models/unit/ansible_variable_binding_test.rb +250 -0
- data/test/models/unit/ansible_variable_test.rb +160 -17
- data/test/models/unit/content_unit_test.rb +74 -0
- data/test/models/unit/execution_environment_test.rb +90 -3
- data/test/services/unit/assignment_service_test.rb +14 -22
- data/test/services/unit/execution_environment_service_test.rb +44 -0
- data/test/services/unit/variable_service_test.rb +474 -337
- data/webpack/components/ansible_content/AnsibleContentPageWrapper.tsx +6 -3
- data/webpack/components/ansible_content/components/AnsibleContentTable.tsx +23 -34
- data/webpack/components/ansible_content/components/AnsibleContentTableSecondaryRow.tsx +17 -27
- data/webpack/components/ansible_content/components/AnsibleContentTableWrapper.tsx +14 -13
- data/webpack/components/ansible_content/components/AnsibleContentWizard/AnsibleContentWizard.tsx +2 -2
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/ProviderSelectionStep.tsx +6 -2
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/ReviewStep.tsx +2 -2
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GalaxyContentUnitInput.tsx +6 -5
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/GitContentUnitInput.tsx +10 -12
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/components/GitRefInput.tsx +2 -5
- data/webpack/components/ansible_content/components/AnsibleContentWizard/components/components/components/VersionInput.tsx +2 -5
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/{MatcherSelector.tsx → TargetNodeSelector.tsx} +50 -44
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/ValueAdapters/ArrayAdapter.tsx +209 -0
- data/webpack/components/ansible_content/components/Variables/CollectionOverviewWrapper.tsx +49 -0
- data/webpack/components/ansible_content/components/Variables/CollectionRoleOverview.tsx +140 -0
- data/webpack/components/ansible_content/components/Variables/ManagementDrawer.tsx +89 -0
- data/webpack/components/ansible_content/components/Variables/VariableList.tsx +166 -0
- data/webpack/components/ansible_content/components/Variables/VariableListWrapper.tsx +59 -0
- data/webpack/components/ansible_content/components/Variables/components/DrawerBindingContent.tsx +170 -0
- data/webpack/components/ansible_content/components/Variables/components/DrawerBindingContentWrapper.tsx +62 -0
- data/webpack/components/ansible_content/components/Variables/components/DrawerVariableContent.tsx +134 -0
- data/webpack/components/ansible_content/components/Variables/components/components/BindingCreateContent.tsx +174 -0
- data/webpack/components/ansible_content/components/Variables/components/components/BindingDetailsContent.tsx +95 -0
- data/webpack/components/ansible_content/components/Variables/components/components/BindingIndexContent.tsx +181 -0
- data/webpack/components/ansible_environments/AnsibleEnvironmentsPageWrapper.tsx +6 -3
- data/webpack/components/ansible_environments/components/AnsibleLcePathIndexWrapper.tsx +19 -19
- data/webpack/components/ansible_environments/components/components/AnsibleExecutionEnvSelectionModal.tsx +4 -3
- data/webpack/components/ansible_environments/components/components/AnsibleExecutionEnvSelectionModalWrapper.tsx +1 -1
- data/webpack/components/ansible_environments/components/components/AnsibleLceComponent.tsx +1 -1
- data/webpack/components/ansible_environments/components/components/AnsibleLceComponentWrapper.tsx +3 -2
- data/webpack/components/ansible_environments/components/components/AnsibleLcePathComponent.tsx +35 -121
- data/webpack/components/ansible_environments/components/components/AnsibleLibraryOverview.tsx +4 -5
- data/webpack/components/ansible_execution_environments/AnsibleExecutionEnvPageWrapper.tsx +6 -3
- data/webpack/components/ansible_execution_environments/components/ContentUnitModal.tsx +4 -4
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardHeaderActions.tsx +15 -13
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCardWrapper.tsx +22 -86
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvCreateCard.tsx +69 -67
- data/webpack/components/ansible_execution_environments/components/ExecutionEnvGridWrapper.tsx +16 -39
- data/webpack/components/ansible_execution_environments/components/components/components/ContentUnitSelector.tsx +1 -2
- data/webpack/components/common/Alerts/AlertContext.tsx +174 -0
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignment.tsx +183 -185
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentMain.tsx +15 -57
- data/webpack/components/common/AnsibleContentAssignment/AnsibleContentAssignmentWrapper.tsx +59 -63
- data/webpack/components/common/AnsibleContentAssignment/AssignmentContext.tsx +289 -0
- data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelector.tsx +21 -29
- data/webpack/components/common/AnsibleContentAssignment/components/AssignmentSelectorWrapper.tsx +14 -65
- data/webpack/components/common/AnsibleContentAssignment/components/ContentAssignmentTable.tsx +32 -32
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/VariableContext.tsx +169 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/VariableTableWrapper.tsx +41 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/BindingDetailModal.tsx +515 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/BindingDetailModalWrapper.tsx +97 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/InlineValueRenderer.tsx +68 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/ValuePresenter.tsx +202 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariableAssignmentTableToolbar.tsx +34 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesAssignmentTable.tsx +112 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesTable.tsx +173 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/VariablesTableToolbar.tsx +34 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/CrossNodeDisabledAlert.tsx +46 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/DetailsCard.tsx +168 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/ValueCard.tsx +143 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/ValueCardWrapper.tsx +77 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlErrorState.tsx +40 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlParsedTypeMismatchErrorState.tsx +35 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/components/components/YamlParserErrorState.tsx +38 -0
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/utils.ts +70 -0
- data/webpack/components/common/AnsibleContentAssignment/helpers.ts +12 -10
- data/webpack/components/common/Page.tsx +0 -2
- data/webpack/components/common/YamlEditor.tsx +30 -20
- data/webpack/components/extensions/components/InheritComponent.tsx +0 -1
- data/webpack/components/extensions/host_details/HostDetailsLceCard/HostDetailsLceCard.tsx +8 -10
- data/webpack/components/extensions/host_details/HostDetailsTab/HostDetailsTab.tsx +10 -7
- data/webpack/helpers/adContext.ts +2 -0
- data/webpack/helpers/components/ConfirmationModal.tsx +5 -2
- data/webpack/helpers/constants.ts +0 -20
- data/webpack/helpers/hooks/useFetch.ts +104 -0
- data/webpack/helpers/hooks/useLegacySelectValue.tsx +67 -0
- data/webpack/helpers/toasts/crudToasts.tsx +75 -0
- data/webpack/helpers/toasts/promoteToasts.tsx +53 -0
- data/webpack/helpers/toasts/useToasts.tsx +142 -0
- data/webpack/resources/backendClient.ts +150 -0
- data/webpack/resources/clients/AnsibleVariable.ts +78 -0
- data/webpack/resources/clients/AnsibleVariableBinding.ts +104 -0
- data/webpack/resources/clients/ExecutionEnvironment.ts +77 -0
- data/webpack/resources/clients/LifecycleEnvironmentPath.ts +114 -0
- data/webpack/resources/types.ts +13 -0
- data/webpack/resources/utils.ts +12 -0
- data/webpack/types/AnsibleContentAssignmentTypes.d.ts +9 -19
- data/webpack/types/AnsibleContentTypes.d.ts +7 -5
- data/webpack/types/AnsibleEnvironmentsTypes.d.ts +0 -4
- data/webpack/types/AnsibleExecutionEnvTypes.d.ts +1 -10
- data/webpack/types/AnsibleVariableTypes.d.ts +64 -37
- data/webpack/types/DynamicAssignmentTypes.d.ts +22 -0
- data/webpack/types/common.d.ts +1 -1
- data/webpack/types/foremanReact/Root/Context/ForemanContext.d.ts +2 -5
- data/webpack/types/foremanReact/common/hooks/API/APIHooks.d.ts +0 -2
- data/webpack/types/foremanReact/components/Pagination/index.d.ts +0 -1
- data/webpack/types/foremanReact/components/ToastsList/slice.d.ts +3 -1
- data/webpack/types/issues/errors.d.ts +4 -3
- data/webpack/types/issues/types.ts +5 -0
- data/webpack/types/issues/warnings.d.ts +4 -2
- metadata +125 -90
- data/app/controllers/foreman_ansible_director/api/v2/ansible_variable_overrides_controller.rb +0 -203
- data/app/models/foreman_ansible_director/concerns/lookup_keys_extensions.rb +0 -13
- data/app/overrides/create_host_ansible_tab.rb +0 -15
- data/app/services/foreman_ansible_director/ansible_director_proxy_selector.rb +0 -20
- data/app/views/foreman_ansible_director/api/v2/ansible_variable_overrides/index_for_target.json.rabl +0 -35
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesOverview.tsx +0 -103
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/AnsibleVariablesSelector.tsx +0 -319
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideCard.tsx +0 -144
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverrideManagementModal.tsx +0 -328
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/OverridesTabContent.tsx +0 -313
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalContent.tsx +0 -392
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/VariableManagementModalWrapper.tsx +0 -81
- data/webpack/components/ansible_content/components/AnsibleVariablesOverview/VariableManagementModal/tabConstants.ts +0 -2
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/MergedOverrideCard.tsx +0 -310
- data/webpack/components/common/AnsibleContentAssignment/components/Variables/OverrideGrid.tsx +0 -80
- 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20d1091937c1d76ecd26e040e861d757cc36110d28a60e74630b3cfb168db165
|
|
4
|
+
data.tar.gz: f1da955ee815b2f80233760544a9732daa44ca6713996b048f2f8b20d374b745
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
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 ::
|
|
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
|
|
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: :
|
|
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
|