Class: Puppet::Environments::Directories Private

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EnvironmentLoader

#get!

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.



199
200
201
202
# File 'lib/puppet/environments.rb', line 199

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 (String)

    path to environment directories

  • global_module_path (Array<String>)

    the global modulepath setting

Returns:



209
210
211
212
213
214
# File 'lib/puppet/environments.rb', line 209

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:

Returns:



230
231
232
233
234
# File 'lib/puppet/environments.rb', line 230

def get(name)
  if valid_directory?(File.join(@environment_dir, name.to_s))
    create_environment(name)
  end
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:

  • name (String, Symbol)

    The name of the environment whose configuration we are looking up

Returns:

  • (Puppet::Setting::EnvironmentConf, nil)

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



237
238
239
240
241
242
243
# File 'lib/puppet/environments.rb', line 237

def get_conf(name)
  envdir = File.join(@environment_dir, name.to_s)
  if valid_directory?(envdir)
    return Puppet::Settings::EnvironmentConf.load_from(envdir, @global_module_path)
  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:



222
223
224
225
226
227
# File 'lib/puppet/environments.rb', line 222

def list
  valid_directories.collect do |envdir|
    name = Puppet::FileSystem.basename_string(envdir).intern
    create_environment(name)
  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:



217
218
219
# File 'lib/puppet/environments.rb', line 217

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