Class: Conjur::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/conjur/config.rb

Constant Summary collapse

@@attributes =
{}

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



75
76
77
# File 'lib/conjur/config.rb', line 75

def [](key)
  @@attributes[key.to_s]
end

.applyObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/conjur/config.rb', line 40

def apply
  keys = Config.keys.dup
  keys.delete(:plugins)
  keys.each do |k|
    value = Config[k]
    Conjur.configuration.set k, value if value
  end
  
  if Conjur.log
    Conjur.log << "Using authn host #{Conjur::Authn::API.host}\n"
  end
end

.inspectObject



53
54
55
# File 'lib/conjur/config.rb', line 53

def inspect
  @@attributes.inspect
end

.keysObject



71
72
73
# File 'lib/conjur/config.rb', line 71

def keys
  @@attributes.keys.map(&:to_sym)
end

.loadObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/conjur/config.rb', line 28

def load
  require 'yaml'
  [ File.join("/etc", "conjur.conf"), ( ENV['CONJURRC'] || File.join(ENV['HOME'], ".conjurrc") ), '.conjurrc' ].each do |f|
    if File.exists?(f)
      if Conjur.log
        Conjur.log << "Loading #{f}\n"
      end
      Conjur::Config.merge YAML.load(IO.read(f))
    end
  end
end

.merge(a) ⇒ Object



66
67
68
69
# File 'lib/conjur/config.rb', line 66

def merge(a)
  a = {} unless a
  @@attributes.deep_merge!(a.stringify_keys)
end

.pluginsObject



57
58
59
60
61
62
63
64
# File 'lib/conjur/config.rb', line 57

def plugins
  plugins = @@attributes['plugins']
  if plugins
    plugins.is_a?(Array) ? plugins : plugins.split(',')
  else
    []
  end
end