diff --git a/manifests/init.pp b/manifests/init.pp index f9afb534..85b854f0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -388,6 +388,17 @@ # (optional) Enable the password field while launching a Heat stack. # Defaults to true # +# [*customization_module*] +# (optional) Horizon has a global override mechanism available to perform +# customizations. This adds a key - customization_module - to HORIZON_CONFIG +# dictionary in local_settings.py. The value should be a string with the +# path to your module containing modifications in dotted python path +# notation. +# Defaults to undef +# +# Example: +# customization_module => "my_project.overrides" +# # === DEPRECATED group/name # # [*fqdn*] @@ -498,6 +509,7 @@ class horizon( $password_validator = undef, $password_validator_help = undef, $enable_user_pass = true, + $customization_module = undef, # DEPRECATED PARAMETERS $custom_theme_path = undef, $fqdn = undef, diff --git a/releasenotes/notes/add-customization-module-config-option-798d0bb4e00737c3.yaml b/releasenotes/notes/add-customization-module-config-option-798d0bb4e00737c3.yaml new file mode 100644 index 00000000..7494ad66 --- /dev/null +++ b/releasenotes/notes/add-customization-module-config-option-798d0bb4e00737c3.yaml @@ -0,0 +1,8 @@ +--- +features: + - Horizon has a global override mechanism available to perform + customizations. This change adds customization_module key + to HORIZON_CONFIG dictionary in local_settings.py. The + value of the parameter should be a string with the path + to the module containing modifications in dotted python + path notation. diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index e5d117b2..c01f661b 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -537,6 +537,69 @@ describe 'horizon' do ]) end end + + context 'with customization_module provided' do + before do + params.merge!({ + :help_url => 'https://docs.openstack.org', + :customization_module => 'my_project.overrides', + :local_settings_template => fixtures_path + '/override_local_settings.py.erb' + }) + end + + it 'uses the custom local_settings.py template' do + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ + '# Custom local_settings.py', + "HORIZON_CONFIG = {", + " 'dashboards': ('project', 'admin', 'settings',),", + " 'default_dashboard': 'project',", + " 'user_home': 'openstack_dashboard.views.get_user_home',", + " 'ajax_queue_limit': 10,", + " 'auto_fade_alerts': {", + " 'delay': 3000,", + " 'fade_duration': 1500,", + " 'types': ['alert-success', 'alert-info']", + " },", + " 'help_url': \"https://docs.openstack.org\",", + " 'exceptions': {'recoverable': exceptions.RECOVERABLE,", + " 'not_found': exceptions.NOT_FOUND,", + " 'unauthorized': exceptions.UNAUTHORIZED},", + " 'customization_module': 'my_project.overrides',", + "}", + ]) + end + end + + context 'with customization_module empty' do + before do + params.merge!({ + :help_url => 'https://docs.openstack.org', + :customization_module => '', + :local_settings_template => fixtures_path + '/override_local_settings.py.erb' + }) + end + + it 'uses the custom local_settings.py template' do + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ + '# Custom local_settings.py', + "HORIZON_CONFIG = {", + " 'dashboards': ('project', 'admin', 'settings',),", + " 'default_dashboard': 'project',", + " 'user_home': 'openstack_dashboard.views.get_user_home',", + " 'ajax_queue_limit': 10,", + " 'auto_fade_alerts': {", + " 'delay': 3000,", + " 'fade_duration': 1500,", + " 'types': ['alert-success', 'alert-info']", + " },", + " 'help_url': \"https://docs.openstack.org\",", + " 'exceptions': {'recoverable': exceptions.RECOVERABLE,", + " 'not_found': exceptions.NOT_FOUND,", + " 'unauthorized': exceptions.UNAUTHORIZED},", + "}", + ]) + end + end end shared_examples_for 'horizon on RedHat' do diff --git a/spec/fixtures/override_local_settings.py.erb b/spec/fixtures/override_local_settings.py.erb index 42639652..1fb85c53 100644 --- a/spec/fixtures/override_local_settings.py.erb +++ b/spec/fixtures/override_local_settings.py.erb @@ -15,4 +15,7 @@ HORIZON_CONFIG = { 'exceptions': {'recoverable': exceptions.RECOVERABLE, 'not_found': exceptions.NOT_FOUND, 'unauthorized': exceptions.UNAUTHORIZED}, +<% if @customization_module and ! (@customization_module.empty?) -%> + 'customization_module': '<%= @customization_module -%>', +<% end -%> } diff --git a/templates/local_settings.py.erb b/templates/local_settings.py.erb index c025c16f..5f30a1bb 100644 --- a/templates/local_settings.py.erb +++ b/templates/local_settings.py.erb @@ -111,6 +111,9 @@ HORIZON_CONFIG = { 'exceptions': {'recoverable': exceptions.RECOVERABLE, 'not_found': exceptions.NOT_FOUND, 'unauthorized': exceptions.UNAUTHORIZED}, +<% if @customization_module and ! (@customization_module.empty?) -%> + 'customization_module': '<%= @customization_module -%>', +<% end -%> } # If provided, a "Report Bug" link will be displayed in the site header