Sha256: 3927d8a922ab15d054b76333504a1114f13703f0a3dbd67a54df73502314c5ff

Contents?: true

Size: 932 Bytes

Versions: 39

Compression:

Stored size: 932 Bytes

Contents

# frozen_string_literal: true

# Check if a local file is readable using Puppet's
# `Puppet::Parser::Files.find_file()` function. This will only check files on the
# machine you run Bolt on.
Puppet::Functions.create_function(:'file::readable', Puppet::Functions::InternalFunction) do
  # @param filename Absolute path or Puppet file path.
  # @return Whether the file is readable.
  # @example Check a file on disk
  #   file::readable('/tmp/i_dumped_this_here')
  # @example check a file from the modulepath
  #   file::readable('example/VERSION')
  dispatch :readable do
    scope_param
    required_param 'String', :filename
    return_type 'Boolean'
  end

  def readable(scope, filename)
    # Send Analytics Report
    Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name)

    found = Puppet::Parser::Files.find_file(filename, scope.compiler.environment)
    found ? File.readable?(found) : false
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
bolt-2.33.1 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.32.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.31.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.30.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.29.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.28.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.27.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.26.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.25.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.24.1 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.24.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.23.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.22.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.21.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.20.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.19.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.18.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.17.0 bolt-modules/file/lib/puppet/functions/file/readable.rb
bolt-2.16.0 bolt-modules/file/lib/puppet/functions/file/readable.rb