bolt 2.18.0 → 2.19.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87eb513700afc2d9fefa9f2497e8718f0e14e511ea2004c59eecfcb19e41bdbc
4
- data.tar.gz: 499d4c8a1a3c0d4b883d83f6478019467a44999beba83712ce49a30ee2ff1fc8
3
+ metadata.gz: 84c1deb7ddf2b30daf415a36f7949544d3113db8ae05cf927516cf0ecfb21ca8
4
+ data.tar.gz: 233d6da93d218e63e50287cbcb5ea863a16f15aa8ae6b02c62f26e87d1d43197
5
5
  SHA512:
6
- metadata.gz: 6046f666fe9bccc4df2a70b191582b14b834063caf31987c1131e7e7c57ac9280e0bf76d719f9b82f27f5de7205b744a2dd3d485f53e9aa867661b824a5b0945
7
- data.tar.gz: fc77aa2acd93b4aab739f468a2aa6a6a2da2c9c10bbc4927005f60aeb20148ecb29884d6f2c6cf86bf84d76af276a55f1a8588734157444ab5844c0b9d9878c9
6
+ metadata.gz: a9432c3f9d79ae864971ed4e37cd258fe884b5f96addb7dac19688b9b0a8e9b8044a686321b8f6dbaecf0fdfd41ba962ae9b67d0dbc88744357acd8fafa07e15
7
+ data.tar.gz: 0a62d1499e578c06900855c5cca20e834a73a7a572f81feb602e60fe72775c02cfba97c39a224477b69098948bf2d40c4dc4229ff4e43d3cb784d4d787dc2d85
@@ -594,13 +594,13 @@ module Bolt
594
594
  bolt task show canary
595
595
  HELP
596
596
 
597
- attr_reader :warnings
597
+ attr_reader :deprecations
598
598
 
599
599
  def initialize(options)
600
600
  super()
601
601
 
602
602
  @options = options
603
- @warnings = []
603
+ @deprecations = []
604
604
 
605
605
  separator "\nINVENTORY OPTIONS"
606
606
  define('-t', '--targets TARGETS',
@@ -809,7 +809,8 @@ module Bolt
809
809
  @options[:debug] = true
810
810
  # We don't actually set '--log-level debug' here, but once the options are evaluated by
811
811
  # the config class the end result is the same.
812
- @warnings << { msg: "Command line option '--debug' is deprecated, set '--log-level debug' instead." }
812
+ msg = "Command line option '--debug' is deprecated, set '--log-level debug' instead."
813
+ @deprecations << { type: 'Using --debug instead of --log-level debug', msg: msg }
813
814
  end
814
815
  define('--log-level LEVEL',
815
816
  "Set the log level for the console. Available options are",
@@ -131,6 +131,7 @@ module Bolt
131
131
  end
132
132
 
133
133
  Bolt::Logger.configure(config.log, config.color)
134
+ Bolt::Logger.analytics = analytics
134
135
  rescue Bolt::Error => e
135
136
  if $stdout.isatty
136
137
  # Print the error message in red, mimicking outputter.fatal_error
@@ -149,8 +150,9 @@ module Bolt
149
150
  config_loaded
150
151
 
151
152
  # Display warnings created during parser and config initialization
152
- parser.warnings.each { |warning| @logger.warn(warning[:msg]) }
153
153
  config.warnings.each { |warning| @logger.warn(warning[:msg]) }
154
+ parser.deprecations.each { |dep| Bolt::Logger.deprecation_warning(dep[:type], dep[:msg]) }
155
+ config.deprecations.each { |dep| Bolt::Logger.deprecation_warning(dep[:type], dep[:msg]) }
154
156
 
155
157
  # After validation, initialize inventory and targets. Errors here are better to catch early.
156
158
  # After this step
@@ -19,7 +19,7 @@ module Bolt
19
19
  class Config
20
20
  include Bolt::Config::Options
21
21
 
22
- attr_reader :config_files, :warnings, :data, :transports, :project, :modified_concurrency
22
+ attr_reader :config_files, :warnings, :data, :transports, :project, :modified_concurrency, :deprecations
23
23
 
24
24
  BOLT_CONFIG_NAME = 'bolt.yaml'
25
25
  BOLT_DEFAULTS_NAME = 'bolt-defaults.yaml'
@@ -41,7 +41,8 @@ module Bolt
41
41
  data = load_defaults(project).push(
42
42
  filepath: project.config_file,
43
43
  data: conf,
44
- warnings: []
44
+ warnings: [],
45
+ deprecations: []
45
46
  )
46
47
 
47
48
  new(project, data, overrides)
@@ -59,7 +60,8 @@ module Bolt
59
60
  data = load_defaults(project).push(
60
61
  filepath: project.config_file,
61
62
  data: conf,
62
- warnings: []
63
+ warnings: [],
64
+ deprecations: []
63
65
  )
64
66
 
65
67
  new(project, data, overrides)
@@ -140,7 +142,7 @@ module Bolt
140
142
  data = data.merge(data.delete('inventory-config'))
141
143
  end
142
144
 
143
- { filepath: filepath, data: data, warnings: warnings }
145
+ { filepath: filepath, data: data, warnings: warnings, deprecations: [] }
144
146
  end
145
147
 
146
148
  # Loads a 'bolt.yaml' file, the legacy configuration file. There's no special munging needed
@@ -148,10 +150,11 @@ module Bolt
148
150
  def self.load_bolt_yaml(dir)
149
151
  filepath = dir + BOLT_CONFIG_NAME
150
152
  data = Bolt::Util.read_yaml_hash(filepath, 'config')
151
- warnings = [msg: "Configuration file #{filepath} is deprecated and will be removed in a future version "\
152
- "of Bolt. Use '#{dir + BOLT_DEFAULTS_NAME}' instead."]
153
+ deprecations = [{ type: 'Using bolt.yaml for system configuration',
154
+ msg: "Configuration file #{filepath} is deprecated and will be removed in a future version "\
155
+ "of Bolt. Use '#{dir + BOLT_DEFAULTS_NAME}' instead." }]
153
156
 
154
- { filepath: filepath, data: data, warnings: warnings }
157
+ { filepath: filepath, data: data, warnings: [], deprecations: deprecations }
155
158
  end
156
159
 
157
160
  def self.load_defaults(project)
@@ -182,12 +185,16 @@ module Bolt
182
185
 
183
186
  def initialize(project, config_data, overrides = {})
184
187
  unless config_data.is_a?(Array)
185
- config_data = [{ filepath: project.config_file, data: config_data, warnings: [] }]
188
+ config_data = [{ filepath: project.config_file,
189
+ data: config_data,
190
+ warnings: [],
191
+ deprecations: [] }]
186
192
  end
187
193
 
188
194
  @logger = Logging.logger[self]
189
195
  @project = project
190
196
  @warnings = @project.warnings.dup
197
+ @deprecations = @project.deprecations.dup
191
198
  @transports = {}
192
199
  @config_files = []
193
200
 
@@ -208,6 +215,7 @@ module Bolt
208
215
 
209
216
  loaded_data = config_data.each_with_object([]) do |data, acc|
210
217
  @warnings.concat(data[:warnings]) if data[:warnings].any?
218
+ @deprecations.concat(data[:deprecations]) if data[:deprecations].any?
211
219
 
212
220
  if data[:data].any?
213
221
  @config_files.push(data[:filepath])
@@ -378,7 +386,7 @@ module Bolt
378
386
  raise Bolt::ValidationError, "Compilation is CPU-intensive, set concurrency less than #{compile_limit}"
379
387
  end
380
388
 
381
- if (format == 'rainbow' && Bolt::Util.windows?) || !(%w[human json rainbow].include? format)
389
+ unless %w[human json rainbow].include? format
382
390
  raise Bolt::ValidationError, "Unsupported format: '#{format}'"
383
391
  end
384
392
 
@@ -67,6 +67,10 @@ module Bolt
67
67
  end
68
68
  end
69
69
 
70
+ def self.analytics=(analytics)
71
+ @analytics = analytics
72
+ end
73
+
70
74
  def self.console_layout(color)
71
75
  color_scheme = :bolt if color
72
76
  Logging.layouts.pattern(
@@ -114,5 +118,10 @@ module Bolt
114
118
  end
115
119
  }
116
120
  end
121
+
122
+ def self.deprecation_warning(type, msg)
123
+ @analytics&.event('Warn', 'deprecation', label: type)
124
+ warn_once(type, msg)
125
+ end
117
126
  end
118
127
  end
@@ -8,6 +8,12 @@ module Bolt
8
8
  def initialize(color, verbose, trace, stream = $stdout)
9
9
  begin
10
10
  require 'paint'
11
+ if Bolt::Util.windows?
12
+ # the Paint gem thinks that windows does not support ansi colors
13
+ # but windows 10 or later does
14
+ # we can display colors if we force mode to TRUE_COLOR
15
+ Paint.mode = 0xFFFFFF
16
+ end
11
17
  rescue LoadError
12
18
  raise "The 'paint' gem is required to use the rainbow outputter."
13
19
  end
@@ -142,7 +142,7 @@ module Bolt
142
142
  if plan.steps.any? { |step| step.body.key?('target') }
143
143
  msg = "The 'target' parameter for YAML plan steps is deprecated and will be removed "\
144
144
  "in a future version of Bolt. Use the 'targets' parameter instead."
145
- @logger.warn(msg)
145
+ Bolt::Logger.deprecation_warning("Using 'target' parameter for YAML plan steps, not 'targets'", msg)
146
146
  end
147
147
 
148
148
  plan_result = closure_scope.with_local_scope(args_hash) do |scope|
@@ -184,12 +184,10 @@ module Bolt
184
184
  # Raises a deprecation warning if the pkcs7 plugin is using deprecated keys and
185
185
  # modifies the keys so they are the correct format
186
186
  def handle_deprecated_pkcs7_keys(params)
187
- if (params.key?('private-key') || params.key?('public-key')) && !@deprecation_warning_issued
188
- @deprecation_warning_issued = true
189
-
187
+ if params.key?('private-key') || params.key?('public-key')
190
188
  message = "pkcs7 keys 'private-key' and 'public-key' have been deprecated and will be "\
191
189
  "removed in a future version of Bolt; use 'private_key' and 'public_key' instead."
192
- Logging.logger[self].warn(message)
190
+ Bolt::Logger.deprecation_warning('PKCS7 keys using hyphens, not underscores', message)
193
191
  end
194
192
 
195
193
  params['private_key'] = params.delete('private-key') if params.key?('private-key')
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pathname'
4
- require 'bolt/pal'
5
4
  require 'bolt/config'
5
+ require 'bolt/pal'
6
6
 
7
7
  module Bolt
8
8
  class Project
@@ -16,7 +16,8 @@ module Bolt
16
16
  }.freeze
17
17
 
18
18
  attr_reader :path, :data, :config_file, :inventory_file, :modulepath, :hiera_config,
19
- :puppetfile, :rerunfile, :type, :resource_types, :warnings, :project_file
19
+ :puppetfile, :rerunfile, :type, :resource_types, :warnings, :project_file,
20
+ :deprecations
20
21
 
21
22
  def self.default_project
22
23
  create_project(File.expand_path(File.join('~', '.puppetlabs', 'bolt')), 'user')
@@ -65,11 +66,12 @@ module Bolt
65
66
  @project_file = @path + 'bolt-project.yaml'
66
67
 
67
68
  @warnings = []
69
+ @deprecations = []
68
70
  if (@path + 'bolt.yaml').file? && project_file?
69
71
  msg = "Project-level configuration in bolt.yaml is deprecated if using bolt-project.yaml. "\
70
72
  "Transport config should be set in inventory.yaml, all other config should be set in "\
71
73
  "bolt-project.yaml."
72
- @warnings << { msg: msg }
74
+ @deprecations << { type: 'Using bolt.yaml for project configuration', msg: msg }
73
75
  end
74
76
 
75
77
  @inventory_file = @path + 'inventory.yaml'
@@ -109,7 +111,7 @@ module Bolt
109
111
  # This API is used to prepend the project as a module to Puppet's internal
110
112
  # module_references list. CHANGE AT YOUR OWN RISK
111
113
  def to_h
112
- { path: @path, name: name }
114
+ { path: @path.to_s, name: name }
113
115
  end
114
116
 
115
117
  def eql?(other)
@@ -158,8 +160,8 @@ module Bolt
158
160
 
159
161
  def check_deprecated_file
160
162
  if (@path + 'project.yaml').file?
161
- logger = Logging.logger[self]
162
- logger.warn "Project configuration file 'project.yaml' is deprecated; use 'bolt-project.yaml' instead."
163
+ msg = "Project configuration file 'project.yaml' is deprecated; use 'bolt-project.yaml' instead."
164
+ Bolt::Logger.deprecation_warning('Using project.yaml instead of bolt-project.yaml', msg)
163
165
  end
164
166
  end
165
167
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '2.18.0'
4
+ VERSION = '2.19.0'
5
5
  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: 2.18.0
4
+ version: 2.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable