Class: Puppet::Environments::Directories Private
- 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 ‘[server]` section for the server) prepended with the `modules` directory of the environment directory.
Class Method Summary collapse
-
.from_path(path, global_module_path) ⇒ Array<Puppet::Environments::Directories>
private
Generate an array of directory loaders from a path string.
- .real_path(dir) ⇒ Object private
Instance Method Summary collapse
-
#get(name) ⇒ Puppet::Node::Environment?
private
Find a named environment.
-
#get_conf(name) ⇒ Puppet::Setting::EnvironmentConf?
private
Attempt to obtain the initial configuration for the environment.
-
#initialize(environment_dir, global_module_path) ⇒ Directories
constructor
private
A new instance of Directories.
-
#list ⇒ Array<Puppet::Node::Environment>
private
All of the environments known to the loader.
-
#search_paths ⇒ Array<String>
private
A list of indicators of where the loader is getting its environments from.
Methods included from EnvironmentLoader
#clear_all, #get!, #guard, #unguard
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.
178 179 180 181 182 183 |
# File 'lib/puppet/environments.rb', line 178 def initialize(environment_dir, global_module_path) @environment_dir = Puppet::FileSystem.(environment_dir) @global_module_path = global_module_path ? global_module_path.map { |p| Puppet::FileSystem.(p) } : nil 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.
190 191 192 193 194 195 |
# File 'lib/puppet/environments.rb', line 190 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 |
.real_path(dir) ⇒ 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.
197 198 199 200 201 202 |
# File 'lib/puppet/environments.rb', line 197 def self.real_path(dir) if Puppet::FileSystem.symlink?(dir) && Puppet[:versioned_environment_dirs] dir = Pathname.new Puppet::FileSystem.(Puppet::FileSystem.readlink(dir)) end return dir 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
217 218 219 220 221 |
# File 'lib/puppet/environments.rb', line 217 def get(name) if validated_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.
224 225 226 227 228 229 230 231 |
# File 'lib/puppet/environments.rb', line 224 def get_conf(name) envdir = validated_directory(File.join(@environment_dir, name.to_s)) if envdir Puppet::Settings::EnvironmentConf.load_from(envdir, @global_module_path) else nil end end |
#list ⇒ Array<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.
210 211 212 213 214 |
# File 'lib/puppet/environments.rb', line 210 def list valid_environment_names.collect do |name| create_environment(name) end end |
#search_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.
A list of indicators of where the loader is getting its environments from.
205 206 207 |
# File 'lib/puppet/environments.rb', line 205 def search_paths ["file://#{@environment_dir}"] end |