Module: ContainerConfig::Provider

Defined in:
lib/container_config/provider.rb,
lib/container_config/provider/env.rb,
lib/container_config/provider/base.rb,
lib/container_config/provider/default.rb,
lib/container_config/provider/secret_volume.rb,
lib/container_config/provider/rails_credential.rb

Overview

Contains classes and methods for config value providers

Defined Under Namespace

Classes: Base, Default, Env, RailsCredential, SecretVolume

Class Method Summary collapse

Class Method Details

.default_providersArray<ContainerConfig::Provider::Base>

Array of default providers

Returns:



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/container_config/provider.rb', line 43

def self.default_providers
  defaults = [
    ContainerConfig::Provider::Env.new,
    ContainerConfig::Provider::SecretVolume.new
  ]

  defaults |= rails_providers if ContainerConfig.rails_app?
  defaults << ContainerConfig::Provider::Default.new

  defaults
end

.load_value(key, *dig_keys, **options) ⇒ Object

Loads a value from the config value providers

Parameters:

  • key (String)

    Configuration key to load

  • dig_keys (Array)

    Variable keys to use to load from providers that accept a dig structure defaults to the lowercase key split by underscores “MY_PASSWORD” => [“my”, “password”]

  • options (Hash)

    Options Hash

Options Hash (**options):

  • :default (String)

    default value if the configuration setting cannot be found

  • :secret_mount_directory (String)

    directory where secret files are mounted

  • :type (Symbol)

    type to use such as :boolean, :integer, :string, :symbol, :ssl_verify_mode, :ssl_certificate, or :ssl_key

Returns:

  • (Object)

    configuration setting value



28
29
30
31
32
33
34
35
36
# File 'lib/container_config/provider.rb', line 28

def self.load_value(key, *dig_keys, **options)
  value = nil
  ContainerConfig.providers.each do |p|
    value = p.load(key, *dig_keys, **options)
    break unless value.nil?
  end

  value
end

.rails_providersArray<ContainerConfig::Provider::Base>

Array of Rails providers These are only included in the default providers when this gem is included as part of a rails application

Returns:



62
63
64
# File 'lib/container_config/provider.rb', line 62

def self.rails_providers
  [ContainerConfig::Provider::RailsCredential.new]
end