I've clearly forgotten how this aspect of ralsh works.  How does an instances 
method that returns [] fix anything?  Does this just make the file management 
work but not file querying?  E.g., what does 'puppet resource file' do here?  
It would normally list all instances, but that's obviously not going to happen.

Thanks.

On Oct 18, 2010, at 3:30 PM, Jesse Wolfe wrote:

> 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 adds one line to Owen's version, as our unit tests caught an
> unexpected ruby quirk:
> "text/".split("/")
> and
> "text/".split("/", 2)
> do not return the same values.
> 
> Signed-off-by: Jesse Wolfe <[email protected]>
> ---
> lib/puppet/indirector/resource/ral.rb |    9 +++++++--
> lib/puppet/type/file.rb               |   21 ++-------------------
> 2 files changed, 9 insertions(+), 21 deletions(-)
> 
> 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 f35a264..8ed9a1d 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
> +    return []
>   end
> 
>   @depthfirst = false
> -- 
> 1.7.0.4
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.
> 


-- 
A censor is a man who knows more than he thinks you ought to.
        -- Granville Hicks
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199




-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to