Class: Jerakia

Inherits:
Object
  • Object
show all
Defined in:
lib/jerakia.rb,
lib/jerakia/cli.rb,
lib/jerakia/util.rb,
lib/jerakia/error.rb,
lib/jerakia/answer.rb,
lib/jerakia/policy.rb,
lib/jerakia/server.rb,
lib/jerakia/request.rb,
lib/jerakia/version.rb,
lib/jerakia/launcher.rb,
lib/jerakia/cli/token.rb,
lib/jerakia/util/http.rb,
lib/jerakia/cli/config.rb,
lib/jerakia/cli/lookup.rb,
lib/jerakia/cli/secret.rb,
lib/jerakia/cli/server.rb,
lib/jerakia/datasource.rb,
lib/jerakia/dsl/lookup.rb,
lib/jerakia/dsl/policy.rb,
lib/jerakia/encryption.rb,
lib/jerakia/server/auth.rb,
lib/jerakia/server/rest.rb,
lib/jerakia/encryption/vault.rb,
lib/jerakia/server/auth/token.rb,
lib/jerakia/lookup/plugin_config.rb

Overview

Jerakia::Lookup::PluginConfig

This class is a simple wrapper class to expose configuration options from the global configuration file to lookup plugins. It's exposed to the lookup as the config method. Eg: config

Direct Known Subclasses

Log, Response

Defined Under Namespace

Modules: Dsl, Util Classes: Answer, CLI, Cache, Config, Datasource, DatasourceArgumentError, Encryption, EncryptionError, Error, FileParseError, HTTPError, Launcher, Log, Lookup, Policy, PolicyError, Request, Response, Schema, SchemaError, Scope, Server

Constant Summary collapse

VERSION =

Public API to retrieve the latest released version of the code

This should be updated when a new gem is released and it is read from the gemspec file

'2.5.0'.freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Jerakia

Returns a new instance of Jerakia.


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jerakia.rb', line 28

def initialize(options = {})
  @options = options
  @policies = {}

  load_config
  load_log_handler

  if config[:plugindir]
    $LOAD_PATH << config[:plugindir] unless $LOAD_PATH.include?(config[:plugindir])
  end

  log.debug('Jerakia initialized')
  Jerakia.log.verbose("Jerakia started. Version #{Jerakia::VERSION}")
  @launcher = Jerakia::Launcher.new
end

Class Attribute Details

.configObject

Returns the value of attribute config


21
22
23
# File 'lib/jerakia.rb', line 21

def config
  @config
end

.logObject

Returns the value of attribute log


22
23
24
# File 'lib/jerakia.rb', line 22

def log
  @log
end

Instance Attribute Details

#launcherObject (readonly)

Returns the value of attribute launcher


18
19
20
# File 'lib/jerakia.rb', line 18

def launcher
  @launcher
end

#optionsObject (readonly)

Returns the value of attribute options


17
18
19
# File 'lib/jerakia.rb', line 17

def options
  @options
end

Class Method Details

.fatal(msg, e) ⇒ Object


49
50
51
52
53
54
# File 'lib/jerakia.rb', line 49

def self.fatal(msg, e)
  stacktrace = e.backtrace.join("\n")
  Jerakia.log.fatal msg
  Jerakia.log.fatal "Full stacktrace output:\n#{$!}\n\n#{stacktrace}"
  raise e
end

Instance Method Details

#configObject


57
58
59
# File 'lib/jerakia.rb', line 57

def config
  self.class.config
end

#logObject


61
62
63
# File 'lib/jerakia.rb', line 61

def log
  self.class.log
end

#lookup(request) ⇒ Object


44
45
46
47
# File 'lib/jerakia.rb', line 44

def lookup(request)
  raise Jerakia::PolicyError, "Policy '#{request.policy}' not defined" unless launcher.policy_exists?(request.policy)
  launcher.policies[request.policy.to_sym].run(request)
end