Sha256: bee3dc68bc241561763a99361101bbbb9d71381153843707a084123032f49ab1

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

require 'bolt/util/format'

# Output a message for the user when running in verbose mode.
#
# 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::verbose') do
  # @param message The message to output.
  # @example Print a message
  #   out::verbose('Something went wrong')
  dispatch :output_verbose do
    param 'Any', :message
    return_type 'Undef'
  end

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

    Puppet.lookup(:bolt_executor).tap do |executor|
      executor.report_function_call(self.class.name)
      executor.publish_event(type: :verbose, message: Bolt::Util::Format.stringify(message))
    end

    nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bolt-3.13.0 bolt-modules/out/lib/puppet/functions/out/verbose.rb