bolt 3.12.0 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/bolt-modules/log/lib/puppet/functions/log/debug.rb +39 -0
- data/bolt-modules/log/lib/puppet/functions/log/error.rb +40 -0
- data/bolt-modules/log/lib/puppet/functions/log/fatal.rb +40 -0
- data/bolt-modules/log/lib/puppet/functions/log/info.rb +39 -0
- data/bolt-modules/log/lib/puppet/functions/log/trace.rb +39 -0
- data/bolt-modules/log/lib/puppet/functions/log/warn.rb +41 -0
- data/bolt-modules/out/lib/puppet/functions/out/message.rb +6 -48
- data/bolt-modules/out/lib/puppet/functions/out/verbose.rb +33 -0
- data/lib/bolt/bolt_option_parser.rb +1 -1
- data/lib/bolt/cli.rb +2 -2
- data/lib/bolt/config/options.rb +2 -2
- data/lib/bolt/outputter/human.rb +2 -0
- data/lib/bolt/outputter/json.rb +2 -0
- data/lib/bolt/outputter/logger.rb +6 -0
- data/lib/bolt/util/format.rb +68 -0
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/transport_app.rb +11 -0
- data/lib/bolt_spec/bolt_context.rb +9 -0
- data/lib/bolt_spec/plans.rb +1 -1
- data/lib/bolt_spec/plans/mock_executor.rb +15 -1
- data/lib/bolt_spec/plans/publish_stub.rb +4 -4
- data/resources/bolt_bash_completion.sh +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80a2245a2ac92c15284c4d6206f5480c6cf72033b32b773a98303b634f853e54
|
4
|
+
data.tar.gz: 4a6e868eba652ea23cb8530a135e3187fae81296d63df8bf9b54d5c2117df615
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7373197cc0401a971ff8e68ed70ef31f90d2087d09a5a0a5178124e40d2aae59546db768480fb5ea65f2b2993d60104abcf137df281863ddaf37c69d58365e5
|
7
|
+
data.tar.gz: 338c72c31cc379aaf45adae5a122a2a2e9fe6dede738aec4b46c21b5102d16a00ee5a494514dd80bc9f4fcd922ee08e62164e64d34987d40ad1d7383ff475363
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
5
|
+
# Log a debugging message.
|
6
|
+
#
|
7
|
+
# Messages logged at this level typically include detailed information about
|
8
|
+
# what a plan is doing. For example, you might log a message at the `debug`
|
9
|
+
# level that shows what value is returned from a function invocation.
|
10
|
+
#
|
11
|
+
# See [Logs](logs.md) for more information about Bolt's log levels.
|
12
|
+
#
|
13
|
+
# > **Note:** Not available in apply block
|
14
|
+
Puppet::Functions.create_function(:'log::debug') do
|
15
|
+
# Log a debugging message.
|
16
|
+
# @param message The message to log.
|
17
|
+
# @example Log a debugging message
|
18
|
+
# log::debug("Function frogsay returned: ${result}")
|
19
|
+
dispatch :log_debug do
|
20
|
+
param 'Any', :message
|
21
|
+
return_type 'Undef'
|
22
|
+
end
|
23
|
+
|
24
|
+
def log_debug(message)
|
25
|
+
unless Puppet[:tasks]
|
26
|
+
raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
|
27
|
+
Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
|
28
|
+
action: 'log::debug'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
33
|
+
executor.report_function_call(self.class.name)
|
34
|
+
executor.publish_event(type: :log, level: :debug, message: Bolt::Util::Format.stringify(message))
|
35
|
+
end
|
36
|
+
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
5
|
+
# Log an error message.
|
6
|
+
#
|
7
|
+
# Messages logged at this level typically indicate that the plan encountered an
|
8
|
+
# error that can be recovered from. For example, you might log a message at the
|
9
|
+
# `error` level if you want to inform the user an action running on a target
|
10
|
+
# failed but that the plan will continue running.
|
11
|
+
#
|
12
|
+
# See [Logs](logs.md) for more information about Bolt's log levels.
|
13
|
+
#
|
14
|
+
# > **Note:** Not available in apply block
|
15
|
+
Puppet::Functions.create_function(:'log::error') do
|
16
|
+
# Log an error message.
|
17
|
+
# @param message The message to log.
|
18
|
+
# @example Log an error message
|
19
|
+
# log::error("The HTTP request returned an error, continuing the plan: ${result}")
|
20
|
+
dispatch :log_error do
|
21
|
+
param 'Any', :message
|
22
|
+
return_type 'Undef'
|
23
|
+
end
|
24
|
+
|
25
|
+
def log_error(message)
|
26
|
+
unless Puppet[:tasks]
|
27
|
+
raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
|
28
|
+
Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
|
29
|
+
action: 'log::error'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
34
|
+
executor.report_function_call(self.class.name)
|
35
|
+
executor.publish_event(type: :log, level: :error, message: Bolt::Util::Format.stringify(message))
|
36
|
+
end
|
37
|
+
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
5
|
+
# Log a fatal message.
|
6
|
+
#
|
7
|
+
# Messages logged at this level indicate that the plan encountered an error that
|
8
|
+
# could not be recovered from. For example, you might log a message at the
|
9
|
+
# `fatal` level if a service is unavailable and the plan cannot continue running
|
10
|
+
# without it.
|
11
|
+
#
|
12
|
+
# See [Logs](logs.md) for more information about Bolt's log levels.
|
13
|
+
#
|
14
|
+
# > **Note:** Not available in apply block
|
15
|
+
Puppet::Functions.create_function(:'log::fatal') do
|
16
|
+
# Log a fatal message.
|
17
|
+
# @param message The message to log.
|
18
|
+
# @example Log a fatal message
|
19
|
+
# log::fatal("The service is unavailable, unable to continue running: ${result}")
|
20
|
+
dispatch :log_fatal do
|
21
|
+
param 'Any', :message
|
22
|
+
return_type 'Undef'
|
23
|
+
end
|
24
|
+
|
25
|
+
def log_fatal(message)
|
26
|
+
unless Puppet[:tasks]
|
27
|
+
raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
|
28
|
+
Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
|
29
|
+
action: 'log::fatal'
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
34
|
+
executor.report_function_call(self.class.name)
|
35
|
+
executor.publish_event(type: :log, level: :fatal, message: Bolt::Util::Format.stringify(message))
|
36
|
+
end
|
37
|
+
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
5
|
+
# Log an info message.
|
6
|
+
#
|
7
|
+
# Messages logged at this level typically include high-level information about
|
8
|
+
# what a plan is doing. For example, you might log a message at the `info` level
|
9
|
+
# that informs users that the plan is reading a file on disk.
|
10
|
+
#
|
11
|
+
# See [Logs](logs.md) for more information about Bolt's log levels.
|
12
|
+
#
|
13
|
+
# > **Note:** Not available in apply block
|
14
|
+
Puppet::Functions.create_function(:'log::info') do
|
15
|
+
# Log an info message.
|
16
|
+
# @param message The message to log.
|
17
|
+
# @example Log an info message
|
18
|
+
# log::info("Reading network device command file ${file}.")
|
19
|
+
dispatch :log_info do
|
20
|
+
param 'Any', :message
|
21
|
+
return_type 'Undef'
|
22
|
+
end
|
23
|
+
|
24
|
+
def log_info(message)
|
25
|
+
unless Puppet[:tasks]
|
26
|
+
raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
|
27
|
+
Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
|
28
|
+
action: 'log::info'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
33
|
+
executor.report_function_call(self.class.name)
|
34
|
+
executor.publish_event(type: :log, level: :info, message: Bolt::Util::Format.stringify(message))
|
35
|
+
end
|
36
|
+
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
5
|
+
# Log a trace message.
|
6
|
+
#
|
7
|
+
# Messages logged at this level typically include the most detailed information
|
8
|
+
# about what a plan is doing. For example, you might log a message at the `trace`
|
9
|
+
# level that describes how a plan is manipulating data.
|
10
|
+
#
|
11
|
+
# See [Logs](logs.md) for more information about Bolt's log levels.
|
12
|
+
#
|
13
|
+
# > **Note:** Not available in apply block
|
14
|
+
Puppet::Functions.create_function(:'log::trace') do
|
15
|
+
# Log a trace message.
|
16
|
+
# @param message The message to log.
|
17
|
+
# @example Log a trace message
|
18
|
+
# log::trace("Creating Target object with data ${data} from file ${file}")
|
19
|
+
dispatch :log_trace do
|
20
|
+
param 'Any', :message
|
21
|
+
return_type 'Undef'
|
22
|
+
end
|
23
|
+
|
24
|
+
def log_trace(message)
|
25
|
+
unless Puppet[:tasks]
|
26
|
+
raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
|
27
|
+
Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
|
28
|
+
action: 'log::trace'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
33
|
+
executor.report_function_call(self.class.name)
|
34
|
+
executor.publish_event(type: :log, level: :trace, message: Bolt::Util::Format.stringify(message))
|
35
|
+
end
|
36
|
+
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
5
|
+
# Log a warning message.
|
6
|
+
#
|
7
|
+
# Messages logged at this level typically include messages about deprecated
|
8
|
+
# behavior or potentially harmful situations that might affect the plan run.
|
9
|
+
# For example, you might log a message at the `warn` level if you are
|
10
|
+
# planning to make a breaking change to your plan in a future release and
|
11
|
+
# want to notify users.
|
12
|
+
#
|
13
|
+
# See [Logs](logs.md) for more information about Bolt's log levels.
|
14
|
+
#
|
15
|
+
# > **Note:** Not available in apply block
|
16
|
+
Puppet::Functions.create_function(:'log::warn') do
|
17
|
+
# Log a warning message.
|
18
|
+
# @param message The message to log.
|
19
|
+
# @example Log a warning message
|
20
|
+
# log::warn('This plan will no longer install the package in a future release.')
|
21
|
+
dispatch :log_warn do
|
22
|
+
param 'Any', :message
|
23
|
+
return_type 'Undef'
|
24
|
+
end
|
25
|
+
|
26
|
+
def log_warn(message)
|
27
|
+
unless Puppet[:tasks]
|
28
|
+
raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
|
29
|
+
Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
|
30
|
+
action: 'log::warn'
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
35
|
+
executor.report_function_call(self.class.name)
|
36
|
+
executor.publish_event(type: :log, level: :warn, message: Bolt::Util::Format.stringify(message))
|
37
|
+
end
|
38
|
+
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
3
5
|
# Output a message for the user.
|
4
6
|
#
|
5
7
|
# This will print a message to stdout when using the human output format,
|
@@ -22,55 +24,11 @@ Puppet::Functions.create_function(:'out::message') do
|
|
22
24
|
.from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'out::message')
|
23
25
|
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
executor.publish_event(type: :message, message: stringify(message))
|
30
|
-
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
|
34
|
-
def stringify(message)
|
35
|
-
formatted = format_message(message)
|
36
|
-
if formatted.is_a?(Hash) || formatted.is_a?(Array)
|
37
|
-
::JSON.pretty_generate(formatted)
|
38
|
-
else
|
39
|
-
formatted
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def format_message(message)
|
44
|
-
case message
|
45
|
-
when Array
|
46
|
-
message.map { |item| format_message(item) }
|
47
|
-
when Bolt::ApplyResult
|
48
|
-
format_apply_result(message)
|
49
|
-
when Bolt::Result, Bolt::ResultSet
|
50
|
-
# This is equivalent to to_s, but formattable
|
51
|
-
message.to_data
|
52
|
-
when Bolt::RunFailure
|
53
|
-
formatted_resultset = message.result_set.to_data
|
54
|
-
message.to_h.merge('result_set' => formatted_resultset)
|
55
|
-
when Hash
|
56
|
-
message.each_with_object({}) do |(k, v), h|
|
57
|
-
h[format_message(k)] = format_message(v)
|
58
|
-
end
|
59
|
-
when Integer, Float, NilClass
|
60
|
-
message
|
61
|
-
else
|
62
|
-
message.to_s
|
27
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
28
|
+
executor.report_function_call(self.class.name)
|
29
|
+
executor.publish_event(type: :message, message: Bolt::Util::Format.stringify(message))
|
63
30
|
end
|
64
|
-
end
|
65
31
|
|
66
|
-
|
67
|
-
logs = result.resource_logs&.map do |log|
|
68
|
-
# Omit low-level info/debug messages
|
69
|
-
next if %w[info debug].include?(log['level'])
|
70
|
-
indent(2, format_log(log))
|
71
|
-
end
|
72
|
-
hash = result.to_data
|
73
|
-
hash['logs'] = logs unless logs.empty?
|
74
|
-
hash
|
32
|
+
nil
|
75
33
|
end
|
76
34
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bolt/util/format'
|
4
|
+
|
5
|
+
# Output a message for the user when running in verbose mode.
|
6
|
+
#
|
7
|
+
# This will print a message to stdout when using the human output format,
|
8
|
+
# and print to stderr when using the json output format.
|
9
|
+
#
|
10
|
+
# > **Note:** Not available in apply block
|
11
|
+
Puppet::Functions.create_function(:'out::verbose') do
|
12
|
+
# @param message The message to output.
|
13
|
+
# @example Print a message
|
14
|
+
# out::verbose('Something went wrong')
|
15
|
+
dispatch :output_verbose do
|
16
|
+
param 'Any', :message
|
17
|
+
return_type 'Undef'
|
18
|
+
end
|
19
|
+
|
20
|
+
def output_verbose(message)
|
21
|
+
unless Puppet[:tasks]
|
22
|
+
raise Puppet::ParseErrorWithIssue
|
23
|
+
.from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'out::verbose')
|
24
|
+
end
|
25
|
+
|
26
|
+
Puppet.lookup(:bolt_executor).tap do |executor|
|
27
|
+
executor.report_function_call(self.class.name)
|
28
|
+
executor.publish_event(type: :verbose, message: Bolt::Util::Format.stringify(message))
|
29
|
+
end
|
30
|
+
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
@@ -1088,7 +1088,7 @@ module Bolt
|
|
1088
1088
|
end
|
1089
1089
|
define('--log-level LEVEL',
|
1090
1090
|
"Set the log level for the console. Available options are",
|
1091
|
-
"trace, debug, info, warn, error, fatal
|
1091
|
+
"trace, debug, info, warn, error, fatal.") do |level|
|
1092
1092
|
@options[:log] = { 'console' => { 'level' => level } }
|
1093
1093
|
end
|
1094
1094
|
define('--clear-cache',
|
data/lib/bolt/cli.rb
CHANGED
@@ -787,8 +787,8 @@ module Bolt
|
|
787
787
|
if %w[human rainbow].include?(options.fetch(:format, 'human'))
|
788
788
|
executor.subscribe(outputter)
|
789
789
|
else
|
790
|
-
# Only subscribe to out
|
791
|
-
executor.subscribe(outputter, [
|
790
|
+
# Only subscribe to out module events for JSON outputter
|
791
|
+
executor.subscribe(outputter, %i[message verbose])
|
792
792
|
end
|
793
793
|
|
794
794
|
executor.subscribe(log_outputter)
|
data/lib/bolt/config/options.rb
CHANGED
@@ -202,7 +202,7 @@ module Bolt
|
|
202
202
|
"level" => {
|
203
203
|
description: "The type of information to log.",
|
204
204
|
type: String,
|
205
|
-
enum: %w[trace debug error info warn fatal
|
205
|
+
enum: %w[trace debug error info warn fatal],
|
206
206
|
_default: "warn"
|
207
207
|
}
|
208
208
|
}
|
@@ -221,7 +221,7 @@ module Bolt
|
|
221
221
|
"level" => {
|
222
222
|
description: "The type of information to log.",
|
223
223
|
type: String,
|
224
|
-
enum: %w[trace debug error info warn fatal
|
224
|
+
enum: %w[trace debug error info warn fatal],
|
225
225
|
_default: "warn"
|
226
226
|
}
|
227
227
|
}
|
data/lib/bolt/outputter/human.rb
CHANGED
data/lib/bolt/outputter/json.rb
CHANGED
@@ -24,6 +24,8 @@ module Bolt
|
|
24
24
|
log_container_start(event)
|
25
25
|
when :container_finish
|
26
26
|
log_container_finish(event)
|
27
|
+
when :log
|
28
|
+
log_message(**event)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -65,6 +67,10 @@ module Bolt
|
|
65
67
|
@logger.info("Finished: run container '#{result.object}' failed.")
|
66
68
|
end
|
67
69
|
end
|
70
|
+
|
71
|
+
def log_message(level:, message:, **_kwargs)
|
72
|
+
@logger.send(level, message)
|
73
|
+
end
|
68
74
|
end
|
69
75
|
end
|
70
76
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bolt
|
4
|
+
module Util
|
5
|
+
module Format
|
6
|
+
class << self
|
7
|
+
# Stringifies an object, formatted as valid JSON.
|
8
|
+
#
|
9
|
+
# @param message [Object] The object to stringify.
|
10
|
+
# @return [String] The JSON string.
|
11
|
+
#
|
12
|
+
def stringify(message)
|
13
|
+
formatted = format_message(message)
|
14
|
+
if formatted.is_a?(Hash) || formatted.is_a?(Array)
|
15
|
+
::JSON.pretty_generate(formatted)
|
16
|
+
else
|
17
|
+
formatted
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Recursively formats an object into a format that can be represented by
|
22
|
+
# JSON.
|
23
|
+
#
|
24
|
+
# @param message [Object] The object to stringify.
|
25
|
+
# @return [Array, Hash, String]
|
26
|
+
#
|
27
|
+
private def format_message(message)
|
28
|
+
case message
|
29
|
+
when Array
|
30
|
+
message.map { |item| format_message(item) }
|
31
|
+
when Bolt::ApplyResult
|
32
|
+
format_apply_result(message)
|
33
|
+
when Bolt::Result, Bolt::ResultSet
|
34
|
+
# This is equivalent to to_s, but formattable
|
35
|
+
message.to_data
|
36
|
+
when Bolt::RunFailure
|
37
|
+
formatted_resultset = message.result_set.to_data
|
38
|
+
message.to_h.merge('result_set' => formatted_resultset)
|
39
|
+
when Hash
|
40
|
+
message.each_with_object({}) do |(k, v), h|
|
41
|
+
h[format_message(k)] = format_message(v)
|
42
|
+
end
|
43
|
+
when Integer, Float, NilClass
|
44
|
+
message
|
45
|
+
else
|
46
|
+
message.to_s
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Formats a Bolt::ApplyResult object.
|
51
|
+
#
|
52
|
+
# @param result [Bolt::ApplyResult] The apply result.
|
53
|
+
# @return [Hash]
|
54
|
+
#
|
55
|
+
private def format_apply_result(result)
|
56
|
+
logs = result.resource_logs&.map do |log|
|
57
|
+
# Omit low-level info/debug messages
|
58
|
+
next if %w[info debug].include?(log['level'])
|
59
|
+
indent(2, format_log(log))
|
60
|
+
end
|
61
|
+
hash = result.to_data
|
62
|
+
hash['logs'] = logs unless logs.empty?
|
63
|
+
hash
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/bolt/version.rb
CHANGED
@@ -120,9 +120,20 @@ module BoltServer
|
|
120
120
|
|
121
121
|
def run_task(target, body)
|
122
122
|
validate_schema(@schemas["action-run_task"], body)
|
123
|
+
|
123
124
|
task_data = body['task']
|
124
125
|
task = Bolt::Task::PuppetServer.new(task_data['name'], task_data['metadata'], task_data['files'], @file_cache)
|
125
126
|
parameters = body['parameters'] || {}
|
127
|
+
# Wrap parameters marked with '"sensitive": true' in the task metadata with a
|
128
|
+
# Sensitive wrapper type. This way it's not shown in logs.
|
129
|
+
if (param_spec = task.parameters)
|
130
|
+
parameters.each do |k, v|
|
131
|
+
if param_spec[k] && param_spec[k]['sensitive']
|
132
|
+
parameters[k] = Puppet::Pops::Types::PSensitiveType::Sensitive.new(v)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
126
137
|
@executor.run_task(target, task, parameters).each do |result|
|
127
138
|
value = result.value
|
128
139
|
next unless value.is_a?(Hash)
|
@@ -191,6 +191,15 @@ module BoltSpec
|
|
191
191
|
allow_out_message.expect_call
|
192
192
|
end
|
193
193
|
|
194
|
+
def allow_out_verbose
|
195
|
+
executor.stub_out_verbose.add_stub
|
196
|
+
end
|
197
|
+
alias allow_any_out_verbose allow_out_verbose
|
198
|
+
|
199
|
+
def expect_out_verbose
|
200
|
+
allow_out_verbose.expect_call
|
201
|
+
end
|
202
|
+
|
194
203
|
# Example helpers to mock other run functions
|
195
204
|
# The with_targets method makes sense for all stubs
|
196
205
|
# with_params could be reused for options
|
data/lib/bolt_spec/plans.rb
CHANGED
@@ -98,7 +98,7 @@ module BoltSpec
|
|
98
98
|
Puppet[:tasks] = true
|
99
99
|
|
100
100
|
# Ensure logger is initialized with Puppet levels so 'notice' works when running plan specs.
|
101
|
-
Logging.init :trace, :debug, :info, :notice, :warn, :error, :fatal
|
101
|
+
Logging.init :trace, :debug, :info, :notice, :warn, :error, :fatal
|
102
102
|
end
|
103
103
|
|
104
104
|
# Provided as a class so expectations can be placed on it.
|
@@ -29,6 +29,7 @@ module BoltSpec
|
|
29
29
|
@modulepath = [modulepath].flatten.map { |path| File.absolute_path(path) }
|
30
30
|
MOCKED_ACTIONS.each { |action| instance_variable_set(:"@#{action}_doubles", {}) }
|
31
31
|
@stub_out_message = nil
|
32
|
+
@stub_out_verbose = nil
|
32
33
|
@transport_features = ['puppet-agent']
|
33
34
|
@executor_real = Bolt::Executor.new
|
34
35
|
# by default, we want to execute any plan that we come across without error
|
@@ -187,6 +188,7 @@ module BoltSpec
|
|
187
188
|
end
|
188
189
|
end
|
189
190
|
@stub_out_message.assert_called('out::message') if @stub_out_message
|
191
|
+
@stub_out_verbose.assert_called('out::verbose') if @stub_out_verbose
|
190
192
|
end
|
191
193
|
|
192
194
|
MOCKED_ACTIONS.each do |action|
|
@@ -199,6 +201,10 @@ module BoltSpec
|
|
199
201
|
@stub_out_message ||= ActionDouble.new(:PublishStub)
|
200
202
|
end
|
201
203
|
|
204
|
+
def stub_out_verbose
|
205
|
+
@stub_out_verbose ||= ActionDouble.new(:PublishStub)
|
206
|
+
end
|
207
|
+
|
202
208
|
def stub_apply
|
203
209
|
@allow_apply = true
|
204
210
|
end
|
@@ -220,12 +226,20 @@ module BoltSpec
|
|
220
226
|
end
|
221
227
|
|
222
228
|
def publish_event(event)
|
223
|
-
|
229
|
+
case event[:type]
|
230
|
+
when :message
|
224
231
|
unless @stub_out_message
|
225
232
|
@error_message = "Unexpected call to 'out::message(#{event[:message]})'"
|
226
233
|
raise UnexpectedInvocation, @error_message
|
227
234
|
end
|
228
235
|
@stub_out_message.process(event[:message])
|
236
|
+
|
237
|
+
when :verbose
|
238
|
+
unless @stub_out_verbose
|
239
|
+
@error_message = "Unexpected call to 'out::verbose(#{event[:message]})'"
|
240
|
+
raise UnexpectedInvocation, @error_message
|
241
|
+
end
|
242
|
+
@stub_out_verbose.process(event[:message])
|
229
243
|
end
|
230
244
|
end
|
231
245
|
|
@@ -7,19 +7,19 @@ module BoltSpec
|
|
7
7
|
module Plans
|
8
8
|
class PublishStub < ActionStub
|
9
9
|
def return
|
10
|
-
raise "return is not implemented for
|
10
|
+
raise "return is not implemented for out module functions"
|
11
11
|
end
|
12
12
|
|
13
13
|
def return_for_targets(_data)
|
14
|
-
raise "return_for_targets is not implemented for
|
14
|
+
raise "return_for_targets is not implemented for out module functions"
|
15
15
|
end
|
16
16
|
|
17
17
|
def always_return(_data)
|
18
|
-
raise "always_return is not implemented for
|
18
|
+
raise "always_return is not implemented for out module functions"
|
19
19
|
end
|
20
20
|
|
21
21
|
def error_with(_data)
|
22
|
-
raise "error_with is not implemented for
|
22
|
+
raise "error_with is not implemented for out module functions"
|
23
23
|
end
|
24
24
|
|
25
25
|
def matches(message)
|
@@ -47,7 +47,7 @@ _bolt_complete() {
|
|
47
47
|
next=$(compgen -f -d "" -- $cur)
|
48
48
|
# Handle tab completing enumerable CLI options
|
49
49
|
elif [ "$prev" == "--log-level" ]; then
|
50
|
-
next="trace debug info warn error fatal
|
50
|
+
next="trace debug info warn error fatal"
|
51
51
|
elif [ "$prev" == "--transport" ]; then
|
52
52
|
next="docker local lxd pcp podman remote ssh winrm"
|
53
53
|
elif [ "$prev" == "--format" ]; then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -448,7 +448,14 @@ files:
|
|
448
448
|
- bolt-modules/file/lib/puppet/functions/file/read.rb
|
449
449
|
- bolt-modules/file/lib/puppet/functions/file/readable.rb
|
450
450
|
- bolt-modules/file/lib/puppet/functions/file/write.rb
|
451
|
+
- bolt-modules/log/lib/puppet/functions/log/debug.rb
|
452
|
+
- bolt-modules/log/lib/puppet/functions/log/error.rb
|
453
|
+
- bolt-modules/log/lib/puppet/functions/log/fatal.rb
|
454
|
+
- bolt-modules/log/lib/puppet/functions/log/info.rb
|
455
|
+
- bolt-modules/log/lib/puppet/functions/log/trace.rb
|
456
|
+
- bolt-modules/log/lib/puppet/functions/log/warn.rb
|
451
457
|
- bolt-modules/out/lib/puppet/functions/out/message.rb
|
458
|
+
- bolt-modules/out/lib/puppet/functions/out/verbose.rb
|
452
459
|
- bolt-modules/prompt/lib/puppet/functions/prompt.rb
|
453
460
|
- bolt-modules/prompt/lib/puppet/functions/prompt/menu.rb
|
454
461
|
- bolt-modules/system/lib/puppet/functions/system/env.rb
|
@@ -586,6 +593,7 @@ files:
|
|
586
593
|
- lib/bolt/transport/winrm.rb
|
587
594
|
- lib/bolt/transport/winrm/connection.rb
|
588
595
|
- lib/bolt/util.rb
|
596
|
+
- lib/bolt/util/format.rb
|
589
597
|
- lib/bolt/util/puppet_log_level.rb
|
590
598
|
- lib/bolt/validator.rb
|
591
599
|
- lib/bolt/version.rb
|