Class: Runger::Loaders::EJSON

Inherits:
Base
  • Object
show all
Defined in:
lib/runger/loaders/ejson.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call, #initialize, #use_local?

Methods included from Tracing

capture, current_trace, current_trace_source, source_stack, trace!, trace_stack, with_trace_source

Constructor Details

This class inherits a constructor from Runger::Loaders::Base

Class Attribute Details

.bin_pathObject

Returns the value of attribute bin_path.



7
8
9
# File 'lib/runger/loaders/ejson.rb', line 7

def bin_path
  @bin_path
end

Instance Method Details

#call(name:, ejson_namespace: name, ejson_parser: Runger::EJSONParser.new(Runger::Loaders::EJSON.bin_path), **_options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/runger/loaders/ejson.rb', line 12

def call(
  name:,
  ejson_namespace: name,
  ejson_parser: Runger::EJSONParser.new(Runger::Loaders::EJSON.bin_path),
  **_options
)
  configs = []

  rel_config_paths.each do |rel_config_path|
    secrets_hash, rel_path =
      extract_hash_from_rel_config_path(
        ejson_parser:,
        rel_config_path:,
      )

    next unless secrets_hash

    config_hash =
      if ejson_namespace
        secrets_hash[ejson_namespace]
      else
        secrets_hash.except('_public_key')
      end

    next unless config_hash.is_a?(Hash)

    configs <<
      trace!(:ejson, path: rel_path) do
        config_hash
      end
  end

  return {} if configs.empty?

  configs.inject do |result_config, next_config|
    ::Runger::Utils.deep_merge!(result_config, next_config)
  end
end