From 44410525722d4de0ed416f42c7d094d42f6602a6 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Thu, 8 Nov 2007 21:02:56 +0100 Subject: fix #891: create a plugins mount which collects all modules' plugins/ subdirs This is Matthew Palmer's work, from his debian package at http://theshed.hezmatt.org/mattshacks/puppet/_patches/load_plugins_from_modules/20070831054902-6856b-0fd1481621def5d0c4d1ae48fb2f1dc357767c1e.patch I just wriggled a few hunks so they apply. --- lib/puppet/module.rb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/puppet/module.rb') diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 45860c74d..3ff4fa470 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -4,7 +4,7 @@ class Puppet::Module TEMPLATES = "templates" FILES = "files" MANIFESTS = "manifests" - + # Return an array of paths by splitting the +modulepath+ config # parameter. Only consider paths that are absolute and existing # directories @@ -27,14 +27,27 @@ class Puppet::Module return nil end - modpath = modulepath(environment).collect { |path| - File::join(path, modname) - }.find { |f| File::directory?(f) } + modpath = all(environment).find { |f| File::directory?(f) } return nil unless modpath return self.new(modname, modpath) end + # Return an array of the full path of every subdirectory in each + # directory in the modulepath. + def self.all(environment = nil) + modulepath(environment).map do |mp| + Dir.new(mp).map do |modfile| + modpath = File.join(mp, modfile) + unless modfile == '.' or modfile == '..' or !File.directory?(modpath) + modpath + else + nil + end + end + end.flatten.compact + end + # Instance methods # Find the concrete file denoted by +file+. If +file+ is absolute, -- cgit From b575d1585322709604f558742dfd6f5ce412b342 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Sat, 24 Nov 2007 23:16:47 -0600 Subject: Integrating Matt Palmer's patch to provide a 'plugins' mount, fixing #891. The patch was ported to the current code by David Schmitt, I applied the rest of Matt's patches, and I then fixed all of the code so that the tests passed. The primary change I had to make to the patch was reenabling host expansion in paths -- his patch had disabled it. --- lib/puppet/module.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/puppet/module.rb') diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 3ff4fa470..54212710d 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -27,7 +27,9 @@ class Puppet::Module return nil end - modpath = all(environment).find { |f| File::directory?(f) } + modpath = modulepath(environment).collect { |path| + File::join(path, modname) + }.find { |f| File::directory?(f) } return nil unless modpath return self.new(modname, modpath) -- cgit