[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5rc1-120-g2247c80
James Turnbull
james at lovedthanlost.net
Mon Feb 7 06:41:01 UTC 2011
The following commit has been merged in the upstream branch:
commit 70630b903b747db0148cd972b64e5162b8f459cc
Author: Jesse Wolfe <jes5199 at gmail.com>
Date: Mon Oct 18 15:24:37 2010 -0700
Fix #3165 Ralsh (bin/puppet resource) can't manage files
This is based on the patch submitted by Owen Smith.
File management was being blocked by two problems: an obsolete, broken
`instances` method for the file type,
and a bug in the way resource/ral handled slashes in resource names.
This patch makes two changes to Owen's version:
1) our unit tests caught an
unexpected ruby quirk:
"text/".split("/")
and
"text/".split("/", 2)
do not return the same values.
2) File.instances now reproduces the old behavior of listing files in
the root directory. This is now implemented in terms of the existing
file recursion feature.
diff --git a/lib/puppet/indirector/resource/ral.rb b/lib/puppet/indirector/resource/ral.rb
index 1c2ab14..bc41d14 100644
--- a/lib/puppet/indirector/resource/ral.rb
+++ b/lib/puppet/indirector/resource/ral.rb
@@ -34,12 +34,17 @@ class Puppet::Resource::Ral < Puppet::Indirector::Code
private
+ # {type,resource}_name: the resource name may contain slashes:
+ # File["/etc/hosts"]. To handle, assume the type name does
+ # _not_ have any slashes in it, and split only on the first.
+
def type_name( request )
- request.key.split('/')[0]
+ request.key.split('/', 2)[0]
end
def resource_name( request )
- request.key.split('/')[1]
+ name = request.key.split('/', 2)[1]
+ name unless name == ""
end
def type( request )
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index eee948c..dc0fe7b 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -290,25 +290,8 @@ Puppet::Type.newtype(:file) do
super(path.gsub(/\/+/, '/').sub(/\/$/, ''))
end
- # List files, but only one level deep.
- def self.instances(base = "/")
- return [] unless FileTest.directory?(base)
-
- files = []
- Dir.entries(base).reject { |e|
- e == "." or e == ".."
- }.each do |name|
- path = File.join(base, name)
- if obj = self[path]
- obj[:audit] = :all
- files << obj
- else
- files << self.new(
- :name => path, :audit => :all
- )
- end
- end
- files
+ def self.instances(base = '/')
+ return self.new(:name => base, :recurse => true, :recurselimit => 1, :audit => :all).recurse_local.values
end
@depthfirst = false
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list