Class: Conjur::Config
- Inherits:
-
Object
- Object
- Conjur::Config
- Defined in:
- lib/conjur/config.rb
Constant Summary collapse
- @@attributes =
{}
Class Method Summary collapse
- .[](key) ⇒ Object
- .apply ⇒ Object
- .clear ⇒ Object
- .default_config_files ⇒ Object
- .inspect ⇒ Object
- .keys ⇒ Object
- .load(config_files = default_config_files) ⇒ Object
- .merge(a) ⇒ Object
- .plugins ⇒ Object
Class Method Details
.[](key) ⇒ Object
106 107 108 |
# File 'lib/conjur/config.rb', line 106 def [](key) @@attributes[key.to_s] end |
.apply ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/conjur/config.rb', line 58 def apply require 'conjur/configuration' keys = Config.keys.dup keys.delete(:plugins) cfg = Conjur.configuration keys.each do |k| if Conjur.configuration.respond_to?("#{k}_env_var") && (env_var = Conjur.configuration.send("#{k}_env_var")) && (v = ENV[env_var]) if Conjur.log Conjur.log << "Not overriding environment setting #{k}=#{v}\n" end next end value = Config[k] cfg.set k, value if value end if Conjur.log require 'conjur/api' Conjur.log << "Using authn host #{Conjur::Authn::API.host}\n" end if Config[:cert_file] OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_file Config[:cert_file] end end |
.clear ⇒ Object
29 30 31 |
# File 'lib/conjur/config.rb', line 29 def clear @@attributes = {} end |
.default_config_files ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/conjur/config.rb', line 33 def default_config_files [ File.join("/etc", "conjur.conf"), ( ENV['CONJURRC'] || [ File.("~/.conjurrc"), '.conjurrc'] ) ].flatten.tap do |f| if f.include?'.conjurrc' and File.file?('.conjurrc') and not ENV['CONJURRC']=='.conjurrc' $stderr.puts "WARNING: .conjurrc file from current directory is used. This behaviour is deprecated. Use ENV['CONJURRC'] to explicitly define custom configuration file if needed" end end end |
.inspect ⇒ Object
84 85 86 |
# File 'lib/conjur/config.rb', line 84 def inspect @@attributes.inspect end |
.keys ⇒ Object
102 103 104 |
# File 'lib/conjur/config.rb', line 102 def keys @@attributes.keys.map(&:to_sym) end |
.load(config_files = default_config_files) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/conjur/config.rb', line 41 def load(config_files = default_config_files) require 'yaml' require 'conjur/log' config_files.each do |f| if File.file?(f) if Conjur.log Conjur.log << "Loading #{f}\n" end config = YAML.load(IO.read(f)).stringify_keys rescue {} if config['cert_file'] config['cert_file'] = File.(config['cert_file'], File.dirname(f)) end Conjur::Config.merge config end end end |
.merge(a) ⇒ Object
97 98 99 100 |
# File 'lib/conjur/config.rb', line 97 def merge(a) a = {} unless a @@attributes.deep_merge!(a.stringify_keys) end |
.plugins ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/conjur/config.rb', line 88 def plugins plugins = @@attributes['plugins'] if plugins plugins.is_a?(Array) ? plugins : plugins.split(',') else [] end end |