Class: SecretsManager::Config

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

Defined Under Namespace

Classes: SecretConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path, environment) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
# File 'lib/secrets_manager/config.rb', line 7

def initialize(config_path, environment)
  @config_path = config_path
  @environment = environment
  @secrets = []
end

Instance Attribute Details

#secretsObject (readonly)

Returns the value of attribute secrets.



5
6
7
# File 'lib/secrets_manager/config.rb', line 5

def secrets
  @secrets
end

Instance Method Details

#config_stringObject



24
25
26
# File 'lib/secrets_manager/config.rb', line 24

def config_string
  File.read(@config_path).gsub('$environment', @environment)
end

#initObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/secrets_manager/config.rb', line 13

def init
  return unless File.file?(@config_path)

  configuration = JSON.parse(config_string, symbolize_names: true)
  configuration.each do |k, v|
    @secrets << SecretConfig.new(k, v[:id], v[:input], v[:type], v[:path])
  end

  self
end