bolt 0.21.6 → 0.21.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51a8fef70687a1aeebc3a74ad7e4c6fcc69d84423c685e6c1d3d8f2b7a3121ce
4
- data.tar.gz: 7e4952ea14da675182f14d52b02d6fb72d7ab0e073bb1392b083aa521db7523d
3
+ metadata.gz: af8e2b6778a6eefcb1efcafe215e6d0642cc1f1d59b656d12bf94d66e6136c73
4
+ data.tar.gz: 36cfe00c4670dec416489ab9212928071037fd5010e381d2aab07a5fd6914b81
5
5
  SHA512:
6
- metadata.gz: 4d0a47e00bb2f14f998690878a2e78e89f3a7fe5ced902df07edd7bc5e5bdaf286058f39bf1cc62af387835e1ad2dfc7308e5ec23448107d774422dc7992ad53
7
- data.tar.gz: 8affe263f9a2ae00c849c18188c7a1493a1ecda2b15e63a0a4fd03924817ce0008f0b3b588feda9422eb213355decb2770f7cda6b2fba294eb7a9efb6c9300d4
6
+ metadata.gz: d0f08cc1c6b9f3b407c0b292e842ae4b5e21f41857c78a768b7a965877d22cff0affe9a878ebb1c551a7fb81b05d9548d056ea172e1e8e1d6204b85a8f6ccf22
7
+ data.tar.gz: c68bd35efb219e3d836e5e77e497708b1c5b8a05c1a6dcdc0025d38a754fce5fd334a3f26e989e4f0bf2131a3df82a0bbbbc5b7a74247fdf262c5bd66563f050
@@ -53,36 +53,40 @@ Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction
53
53
  )
54
54
  end
55
55
 
56
- # TODO: Add profiling around this
57
56
  if (run_as = named_args['_run_as'])
58
57
  old_run_as = executor.run_as
59
58
  executor.run_as = run_as
60
59
  end
61
- result = nil
62
- begin
63
- # If the plan does not throw :return by calling the return function it's result is
64
- # undef/nil
65
- result = catch(:return) do
66
- func.class.dispatcher.dispatchers[0].call_by_name_with_scope(scope, params, true)
67
- nil
68
- end&.value
69
- # Validate the result is a PlanResult
70
- unless Puppet::Pops::Types::TypeParser.singleton.parse('Boltlib::PlanResult').instance?(result)
71
- raise Bolt::InvalidPlanResult.new(plan_name, result.to_s)
60
+
61
+ # wrap plan execution in logging messages
62
+ executor.log_plan(plan_name) do
63
+ result = nil
64
+ begin
65
+ # If the plan does not throw :return by calling the return function it's result is
66
+ # undef/nil
67
+ result = catch(:return) do
68
+ func.class.dispatcher.dispatchers[0].call_by_name_with_scope(scope, params, true)
69
+ nil
70
+ end&.value
71
+ # Validate the result is a PlanResult
72
+ unless Puppet::Pops::Types::TypeParser.singleton.parse('Boltlib::PlanResult').instance?(result)
73
+ raise Bolt::InvalidPlanResult.new(plan_name, result.to_s)
74
+ end
75
+
76
+ result
77
+ rescue Puppet::PreformattedError => err
78
+ if named_args['_catch_errors'] && err.cause.is_a?(Bolt::Error)
79
+ result = err.cause.to_puppet_error
80
+ else
81
+ raise err
82
+ end
83
+ ensure
84
+ if run_as
85
+ executor.run_as = old_run_as
86
+ end
72
87
  end
88
+
73
89
  result
74
- rescue Puppet::PreformattedError => err
75
- if named_args['_catch_errors'] && err.cause.is_a?(Bolt::Error)
76
- result = err.cause.to_puppet_error
77
- else
78
- raise err
79
- end
80
- ensure
81
- if run_as
82
- executor.run_as = old_run_as
83
- end
84
90
  end
85
-
86
- result
87
91
  end
88
92
  end
data/lib/bolt/executor.rb CHANGED
@@ -134,6 +134,22 @@ module Bolt
134
134
  results
135
135
  end
136
136
 
137
+ def log_plan(plan_name)
138
+ log_method = @plan_logging ? :notice : :info
139
+ @logger.send(log_method, "Starting: plan #{plan_name}")
140
+ start_time = Time.now
141
+
142
+ results = nil
143
+ begin
144
+ results = yield
145
+ ensure
146
+ duration = Time.now - start_time
147
+ @logger.send(log_method, "Finished: plan #{plan_name} in #{duration.round(2)} sec")
148
+ end
149
+
150
+ results
151
+ end
152
+
137
153
  def report_transport(transport, count)
138
154
  name = transport.class.name.split('::').last.downcase
139
155
  @analytics&.event('Transport', 'initialize', name, count) unless @reported_transports.include?(name)
@@ -42,6 +42,7 @@ module Bolt
42
42
  elsif File.exist?(DEFAULT_TOKEN)
43
43
  @token = File.read(DEFAULT_TOKEN)
44
44
  end
45
+ @token = @token.strip if @token
45
46
  end
46
47
 
47
48
  def expand_paths
data/lib/bolt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '0.21.6'
4
+ VERSION = '0.21.7'
5
5
  end
@@ -209,6 +209,10 @@ module BoltSpec
209
209
  @task_doubles[task_name] ||= TaskDouble.new
210
210
  end
211
211
 
212
+ def log_plan(_plan_name)
213
+ yield
214
+ end
215
+
212
216
  def report_function_call(_function); end
213
217
 
214
218
  def report_bundled_content(_mode, _name); end
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: 0.21.6
4
+ version: 0.21.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2018-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.2'
89
+ version: 0.3.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.2'
96
+ version: 0.3.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: r10k
99
99
  requirement: !ruby/object:Gem::Requirement