Class: Hiera::Backend::Eyaml::Encryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/hiera/backend/eyaml/encryptor.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 9

def options
  @options
end

.tagObject

Returns the value of attribute tag.



9
10
11
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 9

def tag
  @tag
end

Class Method Details

.debug(msg) ⇒ Object



65
66
67
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 65

def self.debug(msg)
  LoggingHelper.debug from: plugin_classname, msg: msg
end

.decode(string) ⇒ Object



29
30
31
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 29

def self.decode(string)
  Base64.decode64(string)
end

.decrypt(*_args) ⇒ Object

Raises:

  • (StandardError)


37
38
39
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 37

def self.decrypt *_args
  raise StandardError, "decrypt() not defined for decryptor plugin: #{self}"
end

.encode(binary_string) ⇒ Object



25
26
27
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 25

def self.encode(binary_string)
  Base64.strict_encode64(binary_string)
end

.encrypt(*_args) ⇒ Object

Raises:

  • (StandardError)


33
34
35
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 33

def self.encrypt *_args
  raise StandardError, "encrypt() not defined for encryptor plugin: #{self}"
end

.find(encryption_scheme = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 12

def self.find(encryption_scheme = nil)
  encryption_scheme = Eyaml.default_encryption_scheme if encryption_scheme.nil?
  require "hiera/backend/eyaml/encryptors/#{File.basename encryption_scheme.downcase}"
  encryptor_module = Module.const_get(:Hiera).const_get(:Backend).const_get(:Eyaml).const_get(:Encryptors)
  encryptor_class = Utils.find_closest_class parent_class: encryptor_module, class_name: encryption_scheme
  if encryptor_class.nil?
    raise StandardError,
          "Could not find hiera-eyaml encryptor: #{encryption_scheme}. Try gem install hiera-eyaml-#{encryption_scheme.downcase} ?"
  end

  encryptor_class
end

.format_message(msg) ⇒ Object



57
58
59
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 57

def self.format_message(msg)
  "[eyaml_#{plugin_classname}]:  #{msg}"
end

.hiera?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 53

def self.hiera?
  Utils.hiera?
end

.info(msg) ⇒ Object



69
70
71
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 69

def self.info(msg)
  LoggingHelper.info from: plugin_classname, msg: msg
end

.option(name) ⇒ Object



49
50
51
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 49

def self.option(name)
  Eyaml::Options["#{plugin_classname}_#{name}"] || options["#{plugin_classname}_#{name}"]
end

.plugin_classnameObject



41
42
43
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 41

def self.plugin_classname
  to_s.split('::').last.downcase
end

.registerObject



45
46
47
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 45

def self.register
  Hiera::Backend::Eyaml::Plugins.register_options options: options, plugin: plugin_classname
end

.trace(msg) ⇒ Object



61
62
63
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 61

def self.trace(msg)
  LoggingHelper.trace from: plugin_classname, msg: msg
end

.warn(msg) ⇒ Object



73
74
75
# File 'lib/hiera/backend/eyaml/encryptor.rb', line 73

def self.warn(msg)
  LoggingHelper.warn from: plugin_classname, msg: msg
end