1
require 'puppet/indirector'
2
require 'puppet/file_serving'
3
require 'puppet/file_serving/base'
4
require 'puppet/file_serving/indirection_hooks'
6
# A class that handles retrieving file contents.
7
# It only reads the file when its content is specifically
9
class Puppet::FileServing::Content < Puppet::FileServing::Base
10
extend Puppet::Indirector
11
indirects :file_content, :extend => Puppet::FileServing::IndirectionHooks
15
def self.supported_formats
19
def self.from_raw(content)
20
instance = new("/this/is/a/fake/path")
21
instance.content = content
25
# BF: we used to fetch the file content here, but this is counter-productive
26
# for puppetmaster streaming of file content. So collect just returns itself
28
return if stat.ftype == "directory"
32
# Read the content of our file in.
35
# This stat can raise an exception, too.
36
raise(ArgumentError, "Cannot read the contents of links unless following links") if stat.ftype == "symlink"
38
@content = Puppet::Util.binread(full_path)
44
File.new(full_path, "rb")