Class: R10K::Deployment Private
- Inherits:
-
Object
- Object
- R10K::Deployment
- Defined in:
- lib/r10k/deployment.rb,
lib/r10k/deployment/config.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
- #config ⇒ Object readonly private
Class Method Summary collapse
- .load_config(path, overrides = {}) ⇒ R10K::Deployment deprecated private Deprecated.
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 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.
31 32 33 |
# File 'lib/r10k/deployment.rb', line 31 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.
29 30 31 |
# File 'lib/r10k/deployment.rb', line 29 def config @config end |
Class Method Details
.load_config(path, overrides = {}) ⇒ 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
22 23 24 25 |
# File 'lib/r10k/deployment.rb', line 22 def self.load_config(path, overrides={}) config = R10K::Deployment::Config.new(path, overrides) 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 |source| source.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.
60 61 62 63 |
# File 'lib/r10k/deployment.rb', line 60 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.
66 67 68 |
# File 'lib/r10k/deployment.rb', line 66 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>].
71 72 73 74 75 |
# File 'lib/r10k/deployment.rb', line 71 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.
35 36 37 |
# File 'lib/r10k/deployment.rb', line 35 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
78 79 80 81 82 |
# File 'lib/r10k/deployment.rb', line 78 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.
47 48 49 50 |
# File 'lib/r10k/deployment.rb', line 47 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.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/r10k/deployment.rb', line 84 def validate! hash = {} sources.each do |source| source.environments.each do |environment| if hash.key?(environment.path) osource, oenvironment = hash[environment.path] msg = _("Environment collision at %{env_path} between %{source}:%{env_name} and %{osource}:%{oenv_name}") % {env_path: environment.path, source: source.name, env_name: environment.name, osource: osource.name, oenv_name: oenvironment.name} raise R10K::Error, msg else hash[environment.path] = [source, environment] end end end end |