Sha256: aae78f258d47028e92d8c6f04990ecd7ad28586b94d0f09a2c8cf8bcfec465fe
Contents?: true
Size: 908 Bytes
Versions: 6
Compression:
Stored size: 908 Bytes
Contents
# frozen_string_literal: true # Check if a local file exists using Puppet's # `Puppet::Parser::Files.find_file()` function. This will only check files that # are on the machine Bolt is run on. Puppet::Functions.create_function(:'file::exists', Puppet::Functions::InternalFunction) do # @param filename Absolute path or Puppet file path. # @return Whether the file exists. # @example Check a file on disk # file::exists('/tmp/i_dumped_this_here') # @example check a file from the modulepath # file::exists('example/files/VERSION') dispatch :exists do scope_param required_param 'String', :filename return_type 'Boolean' end def exists(scope, filename) Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name) found = Puppet::Parser::Files.find_file(filename, scope.compiler.environment) found ? Puppet::FileSystem.exist?(found) : false end end
Version data entries
6 entries across 6 versions & 1 rubygems