Class: Puppet::Environments::Directories Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/environments.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.

Reads environments from a directory on disk. Each environment is represented as a sub-directory. The environment’s manifest setting is the manifest directory of the environment directory. The environment’s modulepath setting is the global modulepath (from the [master] section for the master) prepended with the modules directory of the environment directory.

API:

  • private

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment_dir, global_module_path) ⇒ Directories

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

API:

  • private



157
158
159
160
# File 'lib/puppet/environments.rb', line 157

def initialize(environment_dir, global_module_path)
  @environment_dir = environment_dir
  @global_module_path = global_module_path
end

Class Method Details

.from_path(path, global_module_path) ⇒ Array<Puppet::Environments::Directories>

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 an array of directory loaders from a path string.

Parameters:

  • path to environment directories

  • the global modulepath setting

Returns:

  • An array of configured directory loaders.

API:

  • private



167
168
169
170
171
172
# File 'lib/puppet/environments.rb', line 167

def self.from_path(path, global_module_path)
  environments = path.split(File::PATH_SEPARATOR)
  environments.map do |dir|
    Puppet::Environments::Directories.new(dir, global_module_path)
  end
end

Instance Method Details

#get(name) ⇒ Puppet::Node::Environment?

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.

Find a named environment

Parameters:

  • The name of environment to find

Returns:

  • the requested environment or nil if it wasn’t found

API:

  • private



197
198
199
# File 'lib/puppet/environments.rb', line 197

def get(name)
  list.find { |env| env.name == name.intern }
end

#get_conf(name) ⇒ Puppet::Setting::EnvironmentConf?

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.

Attempt to obtain the initial configuration for the environment. Not all loaders can provide this.

Parameters:

  • The name of the environment whose configuration we are looking up

Returns:

  • the configuration for the requested environment, or nil if not found or no configuration is available

API:

  • private



202
203
204
205
206
207
208
209
210
# File 'lib/puppet/environments.rb', line 202

def get_conf(name)
  valid_directories.each do |envdir|
    envname = Puppet::FileSystem.basename_string(envdir)
    if envname == name.to_s
      return Puppet::Settings::EnvironmentConf.load_from(envdir, @global_module_path)
    end
  end
  nil
end

#listArray<Puppet::Node::Environment>

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 All of the environments known to the loader.

Returns:

  • All of the environments known to the loader

API:

  • private



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/puppet/environments.rb', line 180

def list
  valid_directories.collect do |envdir|
    name = Puppet::FileSystem.basename_string(envdir)

    setting_values = Puppet.settings.values(name, Puppet.settings.preferred_run_mode)
    env = Puppet::Node::Environment.create(
      name.intern,
      Puppet::Node::Environment.split_path(setting_values.interpolate(:modulepath)),
      setting_values.interpolate(:manifest),
      setting_values.interpolate(:config_version)
    )
    env.watching = false
    env
  end
end

#search_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.

A list of indicators of where the loader is getting its environments from.

Returns:

  • The URIs of the load locations

API:

  • private



175
176
177
# File 'lib/puppet/environments.rb', line 175

def search_paths
  ["file://#{@environment_dir}"]
end