Sha256: 258a52e8ccb3d38482a648d0b30f9b3fd42725f1d85fb0f57884322ee12a336e

Contents?: true

Size: 750 Bytes

Versions: 12

Compression:

Stored size: 750 Bytes

Contents

# Loads a binary file from a module or file system and returns its contents as a Binary.
# (Documented in 3.x stub)
#
# @since 4.8.0
#
Puppet::Functions.create_function(:binary_file, Puppet::Functions::InternalFunction) do
  dispatch :binary_file do
    scope_param
    param 'String', :path
  end

  def binary_file(scope, unresolved_path)
    path = nil
    found = Puppet::Parser::Files.find_file(unresolved_path, scope.compiler.environment)
    if found && Puppet::FileSystem.exist?(found)
      path = found
    end

    if path
      Puppet::Pops::Types::PBinaryType::Binary.from_binary_string(Puppet::FileSystem.binread(path))
    else
      raise Puppet::ParseError, "binary_file(): The given file '#{path}' does not exist"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
puppet-4.8.2 lib/puppet/functions/binary_file.rb
puppet-4.8.2-x86-mingw32 lib/puppet/functions/binary_file.rb
puppet-4.8.2-x64-mingw32 lib/puppet/functions/binary_file.rb
puppet-4.8.2-universal-darwin lib/puppet/functions/binary_file.rb
puppet-4.8.1 lib/puppet/functions/binary_file.rb
puppet-4.8.1-x86-mingw32 lib/puppet/functions/binary_file.rb
puppet-4.8.1-x64-mingw32 lib/puppet/functions/binary_file.rb
puppet-4.8.1-universal-darwin lib/puppet/functions/binary_file.rb
puppet-4.8.0 lib/puppet/functions/binary_file.rb
puppet-4.8.0-x86-mingw32 lib/puppet/functions/binary_file.rb
puppet-4.8.0-x64-mingw32 lib/puppet/functions/binary_file.rb
puppet-4.8.0-universal-darwin lib/puppet/functions/binary_file.rb