Sha256: 38df55a11d606ed4ff2eb8689370401a40e26dc294bfba3eb1291c09e2abdf35

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

require 'r10k'
require 'r10k/deployment/source'
require 'r10k/deployment/config'

require 'yaml'

module R10K
class Deployment
  # Model a full installation of module directories and modules.

  # Generate a deployment object based on a config
  #
  # @param path [String] The path to the deployment config
  # @return [R10K::Deployment] The deployment loaded with the given config
  def self.load_config(path)
    config = R10K::Deployment::Config.new(path)
    new(config)
  end

  def initialize(config)
    @config = config

    load_environments
  end

  def fetch_sources
    sources.each do |source|
      source.fetch_remote
    end
    load_environments
  end

  # Lazily load all sources
  #
  # This instantiates the @_sources instance variable, but should not be
  # used directly as it could be legitimately unset if we're doing lazy
  # loading.
  #
  # @return [Array<R10K::Deployment::Source>] All repository sources
  #   specified in the config
  def sources
    load_sources if @_sources.nil?
    @_sources
  end

  # Lazily load all environments
  #
  # This instantiates the @_environments instance variable, but should not be
  # used directly as it could be legitimately unset if we're doing lazy
  # loading.
  #
  # @return [Array<R10K::Deployment::Environment>] All enviroments across
  #   all sources
  def environments
    load_environments if @_environments.nil?
    @_environments
  end

  private

  def load_sources
    @_sources = @config.setting(:sources).map do |(name, hash)|
      R10K::Deployment::Source.vivify(name, hash)
    end
  end

  def load_environments
    @_environments = []
    sources.each do |source|
      @_environments += source.environments
    end
  end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
r10k-1.0.0 lib/r10k/deployment.rb
r10k-1.0.0rc4 lib/r10k/deployment.rb
r10k-1.0.0rc3 lib/r10k/deployment.rb
r10k-1.0.0rc2 lib/r10k/deployment.rb
r10k-1.0.0rc1 lib/r10k/deployment.rb