Class: R10K::Deployment Private

Inherits:
Object
  • Object
show all
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

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.



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

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.



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.

Deprecated.

Generate a deployment object based on a config

Parameters:

  • path (String)

    The path to the deployment config

Returns:



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

#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:



60
61
62
63
# File 'lib/r10k/deployment.rb', line 60

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



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

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:



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

#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:



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