Sha256: 25dcacc4d26f48eb4997caf9e98e8fb6f94c548398461a99d4af6d1d456ed097

Contents?: true

Size: 949 Bytes

Versions: 7

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

# Output a message for the user.
#
# This will print a message to stdout when using the human output format,
# and print to stderr when using the json output format
#
# > **Note:** Not available in apply block
Puppet::Functions.create_function(:'out::message') do
  # Output a message.
  # @param message The message to output.
  # @example Print a message
  #   out::message('Something went wrong')
  dispatch :output_message do
    param 'String', :message
    return_type 'Undef'
  end

  def output_message(message)
    unless Puppet[:tasks]
      raise Puppet::ParseErrorWithIssue
        .from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'out::message')
    end

    executor = Puppet.lookup(:bolt_executor)
    # Send Analytics Report
    executor.report_function_call(self.class.name)

    executor.publish_event(type: :message, message: message)

    nil
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bolt-2.22.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.21.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.20.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.19.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.18.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.17.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.16.0 bolt-modules/out/lib/puppet/functions/out/message.rb