diff options
author | Luke Kanies <luke@madstop.com> | 2009-08-23 12:10:35 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-08-24 11:34:38 +1000 |
commit | c0da3bfebb40198703d7d99f2809b315682e28fc (patch) | |
tree | b58b7ebf1cddc3516049d7b178b010cc2025acac /lib | |
parent | ff39bc707e7f37ddeb28203a9e1bfaddcb9dc641 (diff) | |
download | puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.tar.gz puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.tar.xz puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.zip |
Fixing #2558 - propagating recent fileserving changes
I'd made changes to the internals of the fileserving
system to fix #2544 (mostly switched from passing
the node around and then calculating the environment to just
passing the environment around), but those changes weren't consistent
throughout the fileserving code.
In the process of making them consistent, I realized that the
plain file server actually needs the node name rather than
the environment, so I switched to passing the request around,
because it has both pieces of information.
Also added further integration tests which will hopefully keep
this from cropping up again.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/file_serving/configuration.rb | 6 | ||||
-rw-r--r-- | lib/puppet/file_serving/mount/file.rb | 10 | ||||
-rw-r--r-- | lib/puppet/file_serving/mount/modules.rb | 8 | ||||
-rw-r--r-- | lib/puppet/file_serving/mount/plugins.rb | 8 | ||||
-rw-r--r-- | lib/puppet/indirector/file_server.rb | 4 |
5 files changed, 18 insertions, 18 deletions
diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index 3140455c7..a247f53dd 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -32,7 +32,7 @@ class Puppet::FileServing::Configuration # Find the right mount. Does some shenanigans to support old-style module # mounts. - def find_mount(mount_name, node) + def find_mount(mount_name, environment) # Reparse the configuration if necessary. readconfig @@ -40,7 +40,7 @@ class Puppet::FileServing::Configuration return mount end - if mounts["modules"].environment(node).module(mount_name) + if environment.module(mount_name) Puppet::Util::Warnings.warnonce "DEPRECATION NOTICE: Found module '%s' without using the 'modules' mount; please prefix path with 'modules/'" % mount_name return mounts["modules"] end @@ -72,7 +72,7 @@ class Puppet::FileServing::Configuration raise(ArgumentError, "Cannot find file: Invalid path '%s'" % mount_name) unless mount_name =~ %r{^[-\w]+$} - return nil unless mount = find_mount(mount_name, request.node) + return nil unless mount = find_mount(mount_name, request.environment) if mount.name == "modules" and mount_name != "modules" # yay backward-compatibility path = "%s/%s" % [mount_name, path] diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 9053ee18c..bf7ddda45 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -15,7 +15,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount end end - def complete_path(relative_path, node = nil) + def complete_path(relative_path, node) full_path = path(node) raise ArgumentError.new("Mounts without paths are not usable") unless full_path @@ -31,8 +31,8 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount end # Return an instance of the appropriate class. - def find(short_file, options = {}) - complete_path(short_file, options[:node]) + def find(short_file, request) + complete_path(short_file, request.node) end # Return the path as appropriate, expanding as necessary. @@ -63,8 +63,8 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount @path = path end - def search(path, options = {}) - return nil unless path = complete_path(path, options[:node]) + def search(path, request) + return nil unless path = complete_path(path, request.node) return [path] end diff --git a/lib/puppet/file_serving/mount/modules.rb b/lib/puppet/file_serving/mount/modules.rb index bf0bad02b..a7b6d9eee 100644 --- a/lib/puppet/file_serving/mount/modules.rb +++ b/lib/puppet/file_serving/mount/modules.rb @@ -4,16 +4,16 @@ require 'puppet/file_serving/mount' # modules for files. Yay. class Puppet::FileServing::Mount::Modules < Puppet::FileServing::Mount # Return an instance of the appropriate class. - def find(path, options = {}) + def find(path, request) module_name, relative_path = path.split("/", 2) - return nil unless mod = environment(options[:node]).module(module_name) + return nil unless mod = request.environment.module(module_name) mod.file(relative_path) end - def search(path, options = {}) + def search(path, request) module_name, relative_path = path.split("/", 2) - return nil unless mod = environment(options[:node]).module(module_name) + return nil unless mod = request.environment.module(module_name) return nil unless path = mod.file(relative_path) return [path] diff --git a/lib/puppet/file_serving/mount/plugins.rb b/lib/puppet/file_serving/mount/plugins.rb index 02b838c84..c860e52a7 100644 --- a/lib/puppet/file_serving/mount/plugins.rb +++ b/lib/puppet/file_serving/mount/plugins.rb @@ -5,18 +5,18 @@ require 'puppet/file_serving/mount' # many directories into one. class Puppet::FileServing::Mount::Plugins < Puppet::FileServing::Mount # Return an instance of the appropriate class. - def find(relative_path, environment) - return nil unless mod = environment.modules.find { |mod| mod.plugin(relative_path) } + def find(relative_path, request) + return nil unless mod = request.environment.modules.find { |mod| mod.plugin(relative_path) } path = mod.plugin(relative_path) return path end - def search(relative_path, environment) + def search(relative_path, request) # We currently only support one kind of search on plugins - return # them all. - paths = environment.modules.find_all { |mod| mod.plugins? }.collect { |mod| mod.plugin_directory } + paths = request.environment.modules.find_all { |mod| mod.plugins? }.collect { |mod| mod.plugin_directory } return nil if paths.empty? return paths end diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index fe4d4aa1c..18ac20824 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -30,7 +30,7 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus # The mount checks to see if the file exists, and returns nil # if not. - return nil unless path = mount.find(relative_path, request.environment) + return nil unless path = mount.find(relative_path, request) result = model.new(path) result.links = request.options[:links] if request.options[:links] result.collect @@ -42,7 +42,7 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus def search(request) mount, relative_path = configuration.split_path(request) - unless mount and paths = mount.search(relative_path, request.environment) + unless mount and paths = mount.search(relative_path, request) Puppet.info "Could not find filesystem info for file '%s' in environment %s" % [request.key, request.environment] return nil end |