Class: SmartProxyDynflowCore::Settings
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- SmartProxyDynflowCore::Settings
- Defined in:
- lib/smart_proxy_dynflow_core/settings.rb
Constant Summary collapse
- DEFAULT_SETTINGS =
{ :database => '/var/lib/foreman-proxy/dynflow/dynflow.sqlite', :foreman_url => 'https://127.0.0.1:3000', :console_auth => true, :listen => '127.0.0.1', :port => '8008', :use_https => false, :ssl_ca_file => nil, :ssl_private_key => nil, :ssl_certificate => nil, :ssl_disabled_ciphers => [], :tls_disabled_versions => [], :foreman_ssl_ca => nil, :foreman_ssl_key => nil, :foreman_ssl_cert => nil, :standalone => false, :log_file => '/var/log/foreman-proxy/smart_proxy_dynflow_core.log', :log_level => :ERROR, :plugins => {}, :pid_file => '/var/run/foreman-proxy/smart_proxy_dynflow_core.pid', :daemonize => false, :execution_plan_cleaner_age => 60 * 60 * 24, :loaded => false }
- PROXY_SETTINGS =
[:ssl_ca_file, :ssl_certificate, :ssl_private_key, :foreman_url, :foreman_ssl_ca, :foreman_ssl_cert, :foreman_ssl_key, :log_file, :log_level, :ssl_disabled_ciphers]
- PLUGIN_SETTINGS =
[:database, :core_url, :console_auth, :execution_plan_cleaner_age]
Class Method Summary collapse
- .instance ⇒ Object
- .load_from_proxy(plugin) ⇒ Object
- .load_global_settings(path) ⇒ Object
- .load_plugin_settings(path) ⇒ Object
- .loaded! ⇒ Object
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ Settings
constructor
A new instance of Settings.
Methods inherited from OpenStruct
Constructor Details
#initialize(settings = {}) ⇒ Settings
Returns a new instance of Settings.
54 55 56 |
# File 'lib/smart_proxy_dynflow_core/settings.rb', line 54 def initialize(settings = {}) super(DEFAULT_SETTINGS.merge(settings)) end |
Class Method Details
.instance ⇒ Object
58 59 60 |
# File 'lib/smart_proxy_dynflow_core/settings.rb', line 58 def self.instance SmartProxyDynflowCore::SETTINGS end |
.load_from_proxy(plugin) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/smart_proxy_dynflow_core/settings.rb', line 76 def self.load_from_proxy(plugin) plugin_class = if Proxy::VERSION >= '1.16.0' plugin else # DEPRECATION: Remove this branch when dropping support for smart-proxy < 1.16 plugin[:class] end settings = plugin_class.settings.to_h PROXY_SETTINGS.each do |key| SETTINGS[key] = Proxy::SETTINGS[key] end PLUGIN_SETTINGS.each do |key| SETTINGS[key] = settings[key] if settings.key?(key) end SETTINGS.plugins.values.each { |plugin| plugin.load_settings_from_proxy } Settings.loaded! end |
.load_global_settings(path) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/smart_proxy_dynflow_core/settings.rb', line 62 def self.load_global_settings(path) if File.exists? File.join(path) YAML.load_file(path).each do |key, value| SETTINGS[key] = value end end end |
.load_plugin_settings(path) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/smart_proxy_dynflow_core/settings.rb', line 94 def self.load_plugin_settings(path) settings = YAML.load_file(path) name = File.basename(path).gsub(/\.yml$/, '') if SETTINGS.plugins.key? name settings = SETTINGS.plugins[name].to_h.merge(settings) end SETTINGS.plugins[name] = OpenStruct.new settings end |