Sha256: ae6f2dc42f6143eaeadb7e19322f9d3c170b89c6d44031f6a765ffbfef47b9d4

Contents?: true

Size: 579 Bytes

Versions: 43

Compression:

Stored size: 579 Bytes

Contents

# frozen_string_literal: true

# Write a string to a file.
Puppet::Functions.create_function(:'file::write') do
  # @param filename Absolute path.
  # @param content File content to write.
  # @example Write a file to disk
  #   file::write('C:/Users/me/report', $apply_result.first.report)
  dispatch :write do
    required_param 'String', :filename
    required_param 'String', :content
    return_type 'Undef'
  end

  def write(filename, content)
    Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name)
    File.write(filename, content)
    nil
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
bolt-1.24.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-1.23.0 bolt-modules/file/lib/puppet/functions/file/write.rb
bolt-1.22.0 bolt-modules/file/lib/puppet/functions/file/write.rb