bolt 0.7.0 → 0.8.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.

Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/cli.rb +65 -28
  3. data/lib/bolt/config.rb +18 -8
  4. data/lib/bolt/executor.rb +21 -6
  5. data/lib/bolt/node.rb +3 -0
  6. data/lib/bolt/node/result.rb +5 -0
  7. data/lib/bolt/node/ssh.rb +81 -25
  8. data/lib/bolt/node/winrm.rb +70 -31
  9. data/lib/bolt/notifier.rb +20 -0
  10. data/lib/bolt/outputter.rb +21 -0
  11. data/lib/bolt/outputter/human.rb +30 -0
  12. data/lib/bolt/outputter/json.rb +51 -0
  13. data/lib/bolt/result.rb +32 -5
  14. data/lib/bolt/version.rb +1 -1
  15. data/vendored/puppet/lib/puppet.rb +4 -5
  16. data/vendored/puppet/lib/puppet/agent.rb +22 -2
  17. data/vendored/puppet/lib/puppet/application/agent.rb +1 -1
  18. data/vendored/puppet/lib/puppet/application/apply.rb +1 -1
  19. data/vendored/puppet/lib/puppet/configurer/downloader_factory.rb +10 -0
  20. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +4 -4
  21. data/vendored/puppet/lib/puppet/defaults.rb +21 -2
  22. data/vendored/puppet/lib/puppet/external/nagios/parser.rb +1 -1
  23. data/vendored/puppet/lib/puppet/file_serving/configuration.rb +3 -0
  24. data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +2 -0
  25. data/vendored/puppet/lib/puppet/file_serving/mount/locales.rb +35 -0
  26. data/vendored/puppet/lib/puppet/forge.rb +9 -3
  27. data/vendored/puppet/lib/puppet/forge/repository.rb +1 -1
  28. data/vendored/puppet/lib/puppet/functions/file_upload.rb +20 -15
  29. data/vendored/puppet/lib/puppet/functions/new.rb +1 -4
  30. data/vendored/puppet/lib/puppet/functions/run_command.rb +15 -13
  31. data/vendored/puppet/lib/puppet/functions/run_script.rb +27 -14
  32. data/vendored/puppet/lib/puppet/functions/run_task.rb +21 -19
  33. data/vendored/puppet/lib/puppet/gettext/config.rb +86 -28
  34. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +25 -5
  35. data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +1 -1
  36. data/vendored/puppet/lib/puppet/module.rb +13 -17
  37. data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +20 -21
  38. data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +3 -3
  39. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -0
  40. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +20 -1
  41. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +2 -1
  42. data/vendored/puppet/lib/puppet/pops/loaders.rb +6 -41
  43. data/vendored/puppet/lib/puppet/pops/pcore.rb +9 -0
  44. data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
  45. data/vendored/puppet/lib/puppet/pops/serialization/json_path.rb +2 -1
  46. data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +7 -4
  47. data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +9 -2
  48. data/vendored/puppet/lib/puppet/pops/types/p_init_type.rb +1 -1
  49. data/vendored/puppet/lib/puppet/pops/types/p_meta_type.rb +4 -0
  50. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +81 -4
  51. data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +213 -0
  52. data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
  53. data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +11 -1
  54. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +2 -2
  55. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +16 -6
  56. data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +22 -14
  57. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +17 -15
  58. data/vendored/puppet/lib/puppet/pops/types/types.rb +181 -72
  59. data/vendored/puppet/lib/puppet/provider.rb +18 -8
  60. data/vendored/puppet/lib/puppet/provider/package/yum.rb +22 -7
  61. data/vendored/puppet/lib/puppet/provider/service/base.rb +21 -8
  62. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +2 -3
  63. data/vendored/puppet/lib/puppet/provider/user/aix.rb +1 -0
  64. data/vendored/puppet/lib/puppet/provider/user/user_role_add.rb +7 -1
  65. data/vendored/puppet/lib/puppet/provider/user/useradd.rb +3 -2
  66. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +5 -1
  67. data/vendored/puppet/lib/puppet/type/exec.rb +5 -4
  68. data/vendored/puppet/lib/puppet/type/macauthorization.rb +1 -1
  69. data/vendored/puppet/lib/puppet/type/user.rb +19 -0
  70. data/vendored/puppet/lib/puppet/util/log/destinations.rb +10 -0
  71. data/vendored/puppet/lib/puppet/util/windows/file.rb +35 -4
  72. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +1 -1
  73. data/vendored/puppet/lib/puppet/version.rb +1 -1
  74. data/vendored/puppet/lib/puppet_pal.rb +15 -5
  75. metadata +8 -3
  76. data/vendored/puppet/lib/puppet/pops/types/p_error_type.rb +0 -158
@@ -10,19 +10,58 @@ module Puppet::GettextConfig
10
10
  # Used instead of features because we initialize gettext before features is available.
11
11
  # Stubbing gettext if unavailable is handled in puppet.rb.
12
12
  begin
13
- require 'gettext-setup'
13
+ require 'fast_gettext'
14
14
  require 'locale'
15
+
16
+ # Make translation methods (e.g. `_()` and `n_()`) available everywhere.
17
+ class ::Object
18
+ include FastGettext::Translation
19
+ end
20
+
15
21
  @gettext_loaded = true
16
22
  rescue LoadError
23
+ # Stub out gettext's `_` and `n_()` methods, which attempt to load translations,
24
+ # with versions that do nothing
25
+ require 'puppet/gettext/stubs'
17
26
  @gettext_loaded = false
18
27
  end
19
28
 
20
- # Whether we were able to require gettext-setup and locale
21
- # @return [Boolean] true if gettext-setup was successfully loaded
29
+ # @api private
30
+ # Whether we were able to require fast_gettext and locale
31
+ # @return [Boolean] true if translation gems were successfully loaded
22
32
  def self.gettext_loaded?
23
33
  @gettext_loaded
24
34
  end
25
35
 
36
+ # @api private
37
+ # Whether translations have been loaded for a given project
38
+ # @param project_name [String] the project whose translations we are querying
39
+ # @return [Boolean] true if translations have been loaded for the project
40
+ def self.translations_loaded?(project_name)
41
+ return false unless gettext_loaded?
42
+ if @loaded_repositories[project_name]
43
+ return true
44
+ else
45
+ return false
46
+ end
47
+ end
48
+
49
+ # @api private
50
+ # Creates a new empty text domain with the given name, replacing
51
+ # any existing domain with that name, then switches to using
52
+ # that domain. Also clears the cache of loaded translations.
53
+ # @param domain_name [String] the name of the domain to create
54
+ def self.create_text_domain(domain_name)
55
+ return unless gettext_loaded?
56
+ # Clear the cache of loaded translation repositories
57
+ @loaded_repositories = {}
58
+ FastGettext.add_text_domain(domain_name, type: :chain, chain: [])
59
+ #TODO remove this when we start managing domains per environment
60
+ FastGettext.default_text_domain = domain_name
61
+ FastGettext.text_domain = domain_name
62
+ end
63
+
64
+ # @api private
26
65
  # Search for puppet gettext config files
27
66
  # @return [String] path to the config, or nil if not found
28
67
  def self.puppet_locale_path
@@ -37,6 +76,7 @@ module Puppet::GettextConfig
37
76
  end
38
77
  end
39
78
 
79
+ # @api private
40
80
  # Determine which translation file format to use
41
81
  # @param conf_path [String] the path to the gettext config file
42
82
  # @return [Symbol] :mo if in a package structure, :po otherwise
@@ -48,44 +88,62 @@ module Puppet::GettextConfig
48
88
  end
49
89
  end
50
90
 
91
+ # @api private
51
92
  # Prevent future gettext initializations
52
93
  def self.disable_gettext
53
94
  @gettext_disabled = true
54
95
  end
55
96
 
56
- # Attempt to initialize the gettext-setup gem
57
- # @param path [String] to gettext config file
97
+ # @api private
98
+ # Attempt to load tranlstions for the given project.
99
+ # @param project_name [String] the project whose translations we want to load
100
+ # @param locale_dir [String] the path to the directory containing translations
58
101
  # @param file_format [Symbol] translation file format to use, either :po or :mo
59
102
  # @return true if initialization succeeded, false otherwise
60
- def self.initialize(conf_file_dir, file_format)
103
+ def self.load_translations(project_name, locale_dir, file_format)
61
104
  return false if @gettext_disabled || !@gettext_loaded
62
105
 
106
+ return false unless locale_dir && Puppet::FileSystem.exist?(locale_dir)
107
+
63
108
  unless file_format == :po || file_format == :mo
64
109
  raise Puppet::Error, "Unsupported translation file format #{file_format}; please use :po or :mo"
65
110
  end
66
111
 
67
- return false if conf_file_dir.nil?
68
-
69
- conf_file = File.join(conf_file_dir, "config.yaml")
70
- if Puppet::FileSystem.exist?(conf_file)
71
- if GettextSetup.method(:initialize).parameters.count == 1
72
- # For use with old gettext-setup gem versions, will load PO files only
73
- GettextSetup.initialize(conf_file_dir)
74
- else
75
- GettextSetup.initialize(conf_file_dir, :file_format => file_format)
76
- end
77
- # Only change this once.
78
- # Because negotiate_locales will only return a non-default locale if
79
- # the system locale matches a translation set actually available for the
80
- # given gettext project, we don't want this to get set back to default if
81
- # we load a module that doesn't have translations, but Puppet does have
82
- # translations for the user's locale.
83
- if FastGettext.locale == GettextSetup.default_locale
84
- FastGettext.locale = GettextSetup.negotiate_locale(Locale.current.language)
85
- end
86
- true
87
- else
88
- false
112
+ if project_name.nil? || project_name.empty?
113
+ raise Puppet::Error, "A project name must be specified in order to initialize translations."
89
114
  end
115
+
116
+ add_repository_to_domain(project_name, locale_dir, file_format)
117
+ return true
118
+ end
119
+
120
+ # @api private
121
+ # Add the translations for this project to the domain's repository chain
122
+ # chain for the currently selected text domain, if needed.
123
+ # @param project_name [String] the name of the project for which to load translations
124
+ # @param locale_dir [String] the path to the directory containing translations
125
+ # @param file_format [Symbol] the fomat of the translations files, :po or :mo
126
+ def self.add_repository_to_domain(project_name, locale_dir, file_format)
127
+ # check if we've already loaded these transltaions
128
+ current_chain = FastGettext.translation_repositories[FastGettext.text_domain].chain
129
+ return current_chain if @loaded_repositories[project_name]
130
+
131
+ repository = FastGettext::TranslationRepository.build(project_name,
132
+ path: locale_dir,
133
+ type: file_format,
134
+ ignore_fuzzy: false)
135
+ @loaded_repositories[project_name] = true
136
+ current_chain << repository
137
+ end
138
+
139
+ # @api private
140
+ # Sets the language in which to display strings.
141
+ # @param locale [String] the language portion of a locale string (e.g. "ja")
142
+ def self.set_locale(locale)
143
+ return if !gettext_loaded?
144
+ # make sure we're not using the `available_locales` machinery
145
+ FastGettext.default_available_locales = nil
146
+
147
+ FastGettext.default_locale = locale
90
148
  end
91
149
  end
@@ -129,10 +129,13 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
129
129
  def inlineable?(resource, sources)
130
130
  case
131
131
  when resource[:ensure] == 'absent'
132
+ #TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
132
133
  return Puppet::Util::Profiler.profile(_("Not inlining absent resource"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :absent]) { false }
133
134
  when sources.empty?
135
+ #TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
134
136
  return Puppet::Util::Profiler.profile(_("Not inlining resource without sources"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :no_sources]) { false }
135
137
  when (not (sources.all? {|source| source =~ /^puppet:/}))
138
+ #TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
136
139
  return Puppet::Util::Profiler.profile(_("Not inlining unsupported source scheme"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :unsupported_scheme]) { false }
137
140
  else
138
141
  return true
@@ -154,11 +157,13 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
154
157
  # Helper method to log file resources that could not be inlined because they
155
158
  # fall outside of an environment.
156
159
  def log_file_outside_environment
160
+ #TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
157
161
  Puppet::Util::Profiler.profile(_("Not inlining file outside environment"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :file_outside_environment]) { true }
158
162
  end
159
163
 
160
164
  # Helper method to log file resources that were successfully inlined.
161
165
  def log_metadata_inlining
166
+ #TRANSLATORS Inlining refers to adding additional metadata
162
167
  Puppet::Util::Profiler.profile(_("Inlining file metadata"), [:compiler, :static_compile_inlining, :inlined_file_metadata]) { true }
163
168
  end
164
169
 
@@ -270,9 +275,19 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
270
275
  raise Puppet::Error, _("Unable to find a common checksum type between agent '%{agent_type}' and master '%{master_type}'.") % { agent_type: options[:checksum_type], master_type: known_checksum_types } unless checksum_type
271
276
  end
272
277
 
273
- str = _("Compiled %s for ") % (checksum_type ? _('static catalog') : _('catalog'))
274
- str += node.name
275
- str += _(" in environment %{env}") % { env: node.environment } if node.environment
278
+ str = if checksum_type
279
+ if node.environment
280
+ _("Compiled static catalog for %{node} in environment %{environment}") % { node: node.name, environment: node.environment }
281
+ else
282
+ _("Compiled static catalog for %{node}") % { node: node.name }
283
+ end
284
+ else
285
+ if node.environment
286
+ _("Compiled catalog for %{node} in environment %{environment}") % { node: node.name, environment: node.environment }
287
+ else
288
+ _("Compiled catalog for %{node}") % { node: node.name }
289
+ end
290
+ end
276
291
  config = nil
277
292
 
278
293
  benchmark(:notice, str) do
@@ -288,8 +303,13 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
288
303
  end
289
304
 
290
305
  if checksum_type && config.is_a?(model)
291
- str = _("Inlined resource metadata into static catalog for %{node}") % { node: node.name }
292
- str += _(" in environment %{env}") % { env: node.environment } if node.environment
306
+ str = if node.environment
307
+ #TRANSLATORS Inlined refers to adding additional metadata
308
+ _("Inlined resource metadata into static catalog for %{node} in environment %{environment}") % { node: node.name, environment: node.environment }
309
+ else
310
+ #TRANSLATORS Inlined refers to adding additional metadata
311
+ _("Inlined resource metadata into static catalog for %{node}") % { node: node.name }
312
+ end
293
313
  benchmark(:notice, str) do
294
314
  Puppet::Util::Profiler.profile(str, [:compiler, :static_compile_postprocessing, node.environment, node.name]) do
295
315
  inline_metadata(config, checksum_type)
@@ -219,7 +219,7 @@ module Puppet::FileBucketFile
219
219
  # and content as that in the bucket_file
220
220
  # @api private
221
221
  def verify_identical_file(contents_file, bucket_file)
222
- (bucket_file.size == Puppet::FileSystem.size(contents_file)) &&
222
+ (bucket_file.to_binary.bytesize == Puppet::FileSystem.size(contents_file)) &&
223
223
  (bucket_file.stream() {|s| Puppet::FileSystem.compare_stream(contents_file, s) })
224
224
  end
225
225
 
@@ -23,6 +23,7 @@ class Puppet::Module
23
23
  "templates" => "templates",
24
24
  "plugins" => "lib",
25
25
  "pluginfacts" => "facts.d",
26
+ "locales" => "locales",
26
27
  }
27
28
 
28
29
  # Find and return the +module+ that +path+ belongs to. If +path+ is
@@ -302,6 +303,11 @@ class Puppet::Module
302
303
  subpath("facts.d")
303
304
  end
304
305
 
306
+ #@return [String]
307
+ def locale_directory
308
+ subpath("locales")
309
+ end
310
+
305
311
  def has_external_facts?
306
312
  File.directory?(plugin_fact_directory)
307
313
  end
@@ -423,16 +429,15 @@ class Puppet::Module
423
429
  end
424
430
 
425
431
  def initialize_i18n
426
- module_name = @forge_name.gsub("/","-") if @forge_name
427
- return if module_name.nil? || i18n_initialized?(module_name)
432
+ # this name takes the form "namespace-module", and should match the name of
433
+ # the PO file containing the translations.
434
+ module_name = @forge_name ? @forge_name.gsub("/", "-") : name
435
+ return if Puppet::GettextConfig.translations_loaded?(module_name)
428
436
 
429
- locales_path = File.absolute_path('locales', path)
430
-
431
- if Puppet::GettextConfig.initialize(locales_path, :po)
432
- Puppet.debug "#{module_name} initialized for i18n: #{GettextSetup.translation_repositories[module_name]}"
437
+ if Puppet::GettextConfig.load_translations(module_name, locale_directory, :po)
438
+ Puppet.debug "i18n initialized for #{module_name}"
433
439
  elsif Puppet::GettextConfig.gettext_loaded?
434
- config_path = File.absolute_path('config.yaml', locales_path)
435
- Puppet.debug "Could not find locales configuration file for #{module_name} at #{config_path}. Skipping i18n initialization."
440
+ Puppet.debug "Could not find translation files for #{module_name} at #{locale_directory}. Skipping i18n initialization."
436
441
  else
437
442
  Puppet.debug "No gettext library found, skipping i18n initialization."
438
443
  end
@@ -440,15 +445,6 @@ class Puppet::Module
440
445
 
441
446
  private
442
447
 
443
- def i18n_initialized?(module_name)
444
- if Puppet::GettextConfig.gettext_loaded?
445
- GettextSetup.translation_repositories.has_key? module_name
446
- else
447
- # GettextSetup not yet initialized or not found
448
- false
449
- end
450
- end
451
-
452
448
  def wanted_manifests_from(pattern)
453
449
  begin
454
450
  extended = File.extname(pattern).empty? ? "#{pattern}.pp" : pattern
@@ -148,10 +148,22 @@ class AccessOperator
148
148
  end
149
149
  end
150
150
 
151
+ def access_PBooleanType(o, scope, keys)
152
+ keys.flatten!
153
+ assert_keys(keys, o, 1, 1, TrueClass, FalseClass)
154
+ Types::TypeFactory.boolean(keys[0])
155
+ end
156
+
151
157
  def access_PEnumType(o, scope, keys)
152
158
  keys.flatten!
159
+ last = keys.last
160
+ case_insensitive = false
161
+ if last == true || last == false
162
+ keys = keys[0...-1]
163
+ case_insensitive = last
164
+ end
153
165
  assert_keys(keys, o, 1, Float::INFINITY, String)
154
- Types::TypeFactory.enum(*keys)
166
+ Types::PEnumType.new(keys, case_insensitive)
155
167
  end
156
168
 
157
169
  def access_PVariantType(o, scope, keys)
@@ -282,23 +294,6 @@ class AccessOperator
282
294
  Types::TypeFactory.pattern(*keys)
283
295
  end
284
296
 
285
- def access_PErrorType(o, scope, keys)
286
- # 1 - 2 parameters where both are string, regexp, or type
287
- keys.flatten!
288
- case keys.size
289
- when 1, 2
290
- pt = Types::PErrorType::TYPE_ERROR_PARAM
291
- keys.each_with_index do |p, i|
292
- unless pt.instance?(p)
293
- fail(Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[i], {:base_type => 'Error-Type', :actual => p.class})
294
- end
295
- end
296
- Types::TypeFactory.error(*keys)
297
- else
298
- fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Error-Type', :min => 1, :max => 2, :actual => keys.size})
299
- end
300
- end
301
-
302
297
  def access_POptionalType(o, scope, keys)
303
298
  keys.flatten!
304
299
  if keys.size == 1
@@ -331,10 +326,14 @@ class AccessOperator
331
326
 
332
327
  def access_PObjectType(o, scope, keys)
333
328
  keys.flatten!
334
- if keys.size == 1
335
- Types::TypeFactory.object(keys[0])
329
+ if o.resolved? && !o.name.nil?
330
+ Types::PObjectTypeExtension.create(o, keys)
336
331
  else
337
- fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Object-Type', :min => 1, :actual => keys.size})
332
+ if keys.size == 1
333
+ Types::TypeFactory.object(keys[0])
334
+ else
335
+ fail(Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Object-Type', :min => 1, :actual => keys.size})
336
+ end
338
337
  end
339
338
  end
340
339
 
@@ -34,7 +34,7 @@ class CompareOperator
34
34
  end
35
35
 
36
36
  # Performs a match of a and b, and returns true if b matches a
37
- def match(a, b, scope)
37
+ def match(a, b, scope = nil)
38
38
  @@match_visitor.visit_this_2(self, b, a, scope)
39
39
  end
40
40
 
@@ -200,7 +200,7 @@ class CompareOperator
200
200
  def match_Regexp(regexp, left, scope)
201
201
  return false unless left.is_a? String
202
202
  matched = regexp.match(left)
203
- set_match_data(matched, scope) # creates or clears ephemeral
203
+ set_match_data(matched, scope) unless scope.nil? # creates or clears ephemeral
204
204
  !!matched # convert to boolean
205
205
  end
206
206
 
@@ -245,7 +245,7 @@ class CompareOperator
245
245
 
246
246
  def match_Symbol(symbol, left, scope)
247
247
  return true if symbol == :default
248
- equals(left, default, scope)
248
+ equals(left, default)
249
249
  end
250
250
  end
251
251
  end
@@ -178,6 +178,15 @@ class EvaluatorImpl
178
178
  end
179
179
  end
180
180
 
181
+ # Implementation of case option matching.
182
+ #
183
+ # This is the type of matching performed in a case option, using == for every type
184
+ # of value except regular expression where a match is performed.
185
+ #
186
+ def match?(left, right)
187
+ @@compare_operator.match(left, right, nil)
188
+ end
189
+
181
190
  protected
182
191
 
183
192
  def lvalue_VariableExpression(o, scope)
@@ -76,7 +76,6 @@ class StaticLoader < Loader
76
76
  @loaded = {}
77
77
  @runtime_3_initialized = false
78
78
  create_built_in_types
79
- register_aliases
80
79
  end
81
80
 
82
81
  def discover(type, name_authority = Pcore::RUNTIME_NAME_AUTHORITY)
@@ -116,6 +115,26 @@ class StaticLoader < Loader
116
115
  @loaded[typed_name]
117
116
  end
118
117
 
118
+ def create_built_in_puppet_types
119
+ Pcore.add_object_type('Error', <<-PUPPET, self)
120
+ {
121
+ type_parameters => {
122
+ kind => Optional[Variant[String,Regexp,Type[Enum],Type[Pattern],Type[NotUndef],Type[Undef]]],
123
+ issue_code => Optional[Variant[String,Regexp,Type[Enum],Type[Pattern],Type[NotUndef],Type[Undef]]]
124
+ },
125
+ attributes => {
126
+ message => String[1],
127
+ kind => { type => Optional[String[1]], value => undef },
128
+ issue_code => { type => Optional[String[1]], value => undef },
129
+ partial_result => { type => Data, value => undef },
130
+ details => { type => Optional[Hash[String[1],Data]], value => undef },
131
+ }
132
+ }
133
+ PUPPET
134
+
135
+ register_aliases
136
+ end
137
+
119
138
  def runtime_3_init
120
139
  unless @runtime_3_initialized
121
140
  @runtime_3_initialized = true
@@ -54,7 +54,8 @@ class TaskInstantiator
54
54
  Types::Task::PARAMETER_NAME_PATTERN,
55
55
  tf.struct(
56
56
  tf.optional('description') => tf.string,
57
- tf.optional('type') => Types::PStringType::NON_EMPTY
57
+ tf.optional('type') => Types::PStringType::NON_EMPTY,
58
+ tf.optional('sensitive') => tf.boolean
58
59
  )
59
60
  )
60
61
 
@@ -84,7 +84,11 @@ class Loaders
84
84
 
85
85
  def self.static_loader
86
86
  # The static loader can only be changed after a reboot
87
- @@static_loader ||= Loader::StaticLoader.new()
87
+ if !class_variable_defined?(:@@static_loader) || @@static_loader.nil?
88
+ @@static_loader = Loader::StaticLoader.new()
89
+ @@static_loader.create_built_in_puppet_types
90
+ end
91
+ @@static_loader
88
92
  end
89
93
 
90
94
  def self.implementation_registry
@@ -436,18 +440,6 @@ class Loaders
436
440
  def resolved?
437
441
  !@private_loader.nil?
438
442
  end
439
-
440
- def restrict_to_dependencies?
441
- @puppet_module.has_metadata?
442
- end
443
-
444
- def unmet_dependencies?
445
- @puppet_module.unmet_dependencies.any?
446
- end
447
-
448
- def dependency_names
449
- @puppet_module.dependencies_as_modules.collect(&:name)
450
- end
451
443
  end
452
444
 
453
445
  # Resolves module loaders - resolution of model dependencies is done by Puppet::Module
@@ -476,42 +468,15 @@ class Loaders
476
468
  if module_data.resolved?
477
469
  nil
478
470
  else
479
- module_data.private_loader =
480
- if module_data.restrict_to_dependencies?
481
- create_loader_with_only_dependencies_visible(module_data)
482
- else
483
- create_loader_with_all_modules_visible(module_data)
484
- end
471
+ module_data.private_loader = create_loader_with_all_modules_visible(module_data)
485
472
  end
486
473
  end
487
474
 
488
475
  private
489
476
 
490
477
  def create_loader_with_all_modules_visible(from_module_data)
491
- Puppet.debug{"ModuleLoader: module '#{from_module_data.name}' has unknown dependencies - it will have all other modules visible"}
492
-
493
478
  @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", all_module_loaders()))
494
479
  end
495
-
496
- def create_loader_with_only_dependencies_visible(from_module_data)
497
- if from_module_data.unmet_dependencies?
498
- if Puppet[:strict] != :off
499
- msg = "ModuleLoader: module '#{from_module_data.name}' has unresolved dependencies" \
500
- " - it will only see those that are resolved." \
501
- " Use 'puppet module list --tree' to see information about modules"
502
- case Puppet[:strict]
503
- when :error
504
- raise LoaderError.new(msg)
505
- when :warning
506
- Puppet.warn_once(:unresolved_module_dependencies,
507
- "unresolved_dependencies_for_module_#{from_module_data.name}",
508
- msg)
509
- end
510
- end
511
- end
512
- dependency_loaders = from_module_data.dependency_names.collect { |name| @index[name].public_loader }
513
- @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", dependency_loaders))
514
- end
515
480
  end
516
481
  end
517
482
  end