Sha256: 0692e8566f22d06aed0cf1610accb6058ca730833890d34f820974688e7bd6db

Contents?: true

Size: 1.19 KB

Versions: 68

Compression:

Stored size: 1.19 KB

Contents

require 'r10k/deployment'
require 'r10k/settings/loader'
require 'r10k/util/symbolize_keys'
require 'r10k/errors'
require 'r10k/initializers'
require 'yaml'

module R10K
class Deployment
class Config

  include R10K::Logging

  attr_accessor :configfile

  def initialize(configfile, overrides={})
    @configfile = configfile
    @overrides = overrides

    load_config
  end

  # Perform a scan for key and check for both string and symbol keys
  def setting(key)
    @config[key]
  end

  alias [] setting

  def settings
    @config
  end

  # Load and store a config file, and set relevant options
  #
  # @param [String] configfile The path to the YAML config file
  def load_config
    loader = R10K::Settings::Loader.new
    hash = loader.read(@configfile)

    with_overrides = hash.merge(@overrides) do |key, oldval, newval|
      logger.debug2 _("Overriding config file setting '%{key}': '%{old_val}' -> '%{new_val}'") % {key: key, old_val: oldval, new_val: newval}
      newval
    end

    @config = R10K::Settings.global_settings.evaluate(with_overrides)

    initializer = R10K::Initializers::GlobalInitializer.new(@config)
    initializer.call
  end

  class ConfigError < R10K::Error
  end
end
end
end

Version data entries

68 entries across 68 versions & 2 rubygems

Version Path
r10k-5.0.0 lib/r10k/deployment/config.rb
r10k-4.1.0 lib/r10k/deployment/config.rb
r10k-4.0.2 lib/r10k/deployment/config.rb
r10k-4.0.1 lib/r10k/deployment/config.rb
r10k-4.0.0 lib/r10k/deployment/config.rb
r10k-4.0.0.pre lib/r10k/deployment/config.rb
r10k-3.16.0 lib/r10k/deployment/config.rb
r10k-3.15.4 lib/r10k/deployment/config.rb
r10k-3.15.3 lib/r10k/deployment/config.rb
r10k-3.15.2 lib/r10k/deployment/config.rb
r10k-3.15.1 lib/r10k/deployment/config.rb
r10k-3.15.0 lib/r10k/deployment/config.rb
akerl-r10k-3.14.2.1 lib/r10k/deployment/config.rb
r10k-3.14.2 lib/r10k/deployment/config.rb
r10k-3.14.1 lib/r10k/deployment/config.rb
r10k-3.14.0 lib/r10k/deployment/config.rb
r10k-3.13.0 lib/r10k/deployment/config.rb
r10k-3.12.1 lib/r10k/deployment/config.rb
r10k-3.12.0 lib/r10k/deployment/config.rb
r10k-3.11.0 lib/r10k/deployment/config.rb