Sha256: 3ef5bc750e8bae1c9b7c6204dd1415501b8332b30f330853b80e74a1830db811

Contents?: true

Size: 946 Bytes

Versions: 10

Compression:

Stored size: 946 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 'Any', :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

10 entries across 10 versions & 1 rubygems

Version Path
bolt-2.31.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.30.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.29.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.28.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.27.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.26.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.25.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.24.1 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.24.0 bolt-modules/out/lib/puppet/functions/out/message.rb
bolt-2.23.0 bolt-modules/out/lib/puppet/functions/out/message.rb