class Puppet::FileBucketFile::File

Public Class Methods

new() click to toggle source
# File lib/puppet/indirector/file_bucket_file/file.rb, line 12
def initialize
  Puppet.settings.use(:filebucket)
end

Public Instance Methods

find( request ) click to toggle source
# File lib/puppet/indirector/file_bucket_file/file.rb, line 16
def find( request )
  checksum, files_original_path = request_to_checksum_and_path( request )
  dir_path = path_for(request.options[:bucket_path], checksum)
  file_path = ::File.join(dir_path, 'contents')

  return nil unless ::File.exists?(file_path)
  return nil unless path_match(dir_path, files_original_path)

  if request.options[:diff_with]
    hash_protocol = sumtype(checksum)
    file2_path = path_for(request.options[:bucket_path], request.options[:diff_with], 'contents')
    raise "could not find diff_with #{request.options[:diff_with]}" unless ::File.exists?(file2_path)
    return %xdiff #{file_path.inspect} #{file2_path.inspect}`
  else
    contents = IO.binread(file_path)
    Puppet.info "FileBucket read #{checksum}"
    model.new(contents)
  end
end
head(request) click to toggle source
# File lib/puppet/indirector/file_bucket_file/file.rb, line 36
def head(request)
  checksum, files_original_path = request_to_checksum_and_path(request)
  dir_path = path_for(request.options[:bucket_path], checksum)

  ::File.exists?(::File.join(dir_path, 'contents')) and path_match(dir_path, files_original_path)
end
save( request ) click to toggle source
# File lib/puppet/indirector/file_bucket_file/file.rb, line 43
def save( request )
  instance = request.instance
  checksum, files_original_path = request_to_checksum_and_path(request)

  save_to_disk(instance, files_original_path)
  instance.to_s
end
validate_key(request) click to toggle source
# File lib/puppet/indirector/file_bucket_file/file.rb, line 51
def validate_key(request)
  # There are no ACLs on filebucket files so validating key is not important
end