From 70630b903b747db0148cd972b64e5162b8f459cc Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Mon, 18 Oct 2010 15:24:37 -0700 Subject: 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. --- lib/puppet/indirector/resource/ral.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/puppet/indirector') diff --git a/lib/puppet/indirector/resource/ral.rb b/lib/puppet/indirector/resource/ral.rb index 1c2ab14ae..bc41d14ae 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 ) -- cgit