Class: R10K::Deployment Private
- Inherits:
-
Object
- Object
- R10K::Deployment
- 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
- #config ⇒ Object readonly private
Class Method Summary collapse
-
.load_config(path) ⇒ R10K::Deployment
private
Generate a deployment object based on a config.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object private
-
#environments ⇒ Array<R10K::Environment::Base>
private
Lazily load all environments.
-
#initialize(config) ⇒ Deployment
constructor
private
A new instance of Deployment.
-
#paths ⇒ Array<String>
private
The paths used by all contained sources.
-
#paths_and_sources ⇒ Hash<String, Array<R10K::Source::Base>]
private
Hash<String, Array<R10K::Source::Base>].
- #preload! ⇒ Object (also: #fetch_sources) private
-
#purge! ⇒ Object
private
Remove unmanaged content from all source paths.
-
#sources ⇒ Array<R10K::Source::Base>
private
Lazily load all sources.
- #validate! ⇒ Object private
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
#config ⇒ Object (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
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 |
#environments ⇒ Array<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.
64 65 66 67 |
# File 'lib/r10k/deployment.rb', line 64 def environments load_environments if @_environments.nil? @_environments end |
#paths ⇒ Array<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.
70 71 72 |
# File 'lib/r10k/deployment.rb', line 70 def paths paths_and_sources.keys end |
#paths_and_sources ⇒ Hash<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>].
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 |
#sources ⇒ 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.
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.
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 |