Class: R10K::Deployment Private

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/deployment.rb,
lib/r10k/deployment/config.rb,
lib/r10k/deployment/source.rb,
lib/r10k/deployment/config/loader.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A deployment models the entire state of the configuration that a Puppet master can use. It contains a set of sources that can produce environments and manages the contents of directories where environments are deployed.

Defined Under Namespace

Classes: Config, Environment, Source

Constant Summary collapse

Basedir =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Deprecated.
R10K::Util::Basedir

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Deployment

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Deployment.



32
33
34
# File 'lib/r10k/deployment.rb', line 32

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'lib/r10k/deployment.rb', line 30

def config
  @config
end

Class Method Details

.load_config(path) ⇒ R10K::Deployment

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Generate a deployment object based on a config

Parameters:

  • path (String)

    The path to the deployment config

Returns:



23
24
25
26
# File 'lib/r10k/deployment.rb', line 23

def self.load_config(path)
  config = R10K::Deployment::Config.new(path)
  new(config)
end

Instance Method Details

#accept(visitor) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



105
106
107
108
109
110
111
# File 'lib/r10k/deployment.rb', line 105

def accept(visitor)
  visitor.visit(:deployment, self) do
    sources.each do |env|
      env.accept(visitor)
    end
  end
end

#environmentsArray<R10K::Environment::Base>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Returns:



64
65
66
67
# File 'lib/r10k/deployment.rb', line 64

def environments
  load_environments if @_environments.nil?
  @_environments
end

#pathsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The paths used by all contained sources.

Returns:

  • (Array<String>)

    The paths used by all contained sources



70
71
72
# File 'lib/r10k/deployment.rb', line 70

def paths
  paths_and_sources.keys
end

#paths_and_sourcesHash<String, Array<R10K::Source::Base>]

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Hash<String, Array<R10K::Source::Base>].

Returns:



75
76
77
78
79
# File 'lib/r10k/deployment.rb', line 75

def paths_and_sources
  pathmap = Hash.new { |h, k| h[k] = [] }
  sources.each { |source| pathmap[source.basedir] << source }
  pathmap
end

#preload!Object Also known as: fetch_sources

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/r10k/deployment.rb', line 36

def preload!
  sources.each(&:preload!)
end

#purge!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Remove unmanaged content from all source paths



82
83
84
85
86
# File 'lib/r10k/deployment.rb', line 82

def purge!
  paths_and_sources.each_pair do |path, sources_at_path|
    R10K::Util::Basedir.new(path, sources_at_path).purge!
  end
end

#sourcesArray<R10K::Source::Base>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Returns:



51
52
53
54
# File 'lib/r10k/deployment.rb', line 51

def sources
  load_sources if @_sources.nil?
  @_sources
end

#validate!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/r10k/deployment.rb', line 88

def validate!
  hash = {}
  sources.each do |source|
    source.environments.each do |environment|
      if hash.key?(environment.path)
        osource, oenvironment = hash[environment.path]
        msg = ""
        msg << "Environment collision at #{environment.path} between "
        msg << "#{source.name}:#{environment.name} and #{osource.name}:#{oenvironment.name}"
        raise R10K::R10KError, msg
      else
        hash[environment.path] = [source, environment]
      end
    end
  end
end