Class: R10K::Deployment Private

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/deployment.rb,
lib/r10k/deployment/config.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

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.



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

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.



27
28
29
# File 'lib/r10k/deployment.rb', line 27

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



20
21
22
23
# File 'lib/r10k/deployment.rb', line 20

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.



99
100
101
102
103
104
105
# File 'lib/r10k/deployment.rb', line 99

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.



58
59
60
61
# File 'lib/r10k/deployment.rb', line 58

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.



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

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>].



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

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

#preload!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.



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

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



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

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.



45
46
47
48
# File 'lib/r10k/deployment.rb', line 45

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.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/r10k/deployment.rb', line 82

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::Error, msg
      else
        hash[environment.path] = [source, environment]
      end
    end
  end
end