bolt 0.11.0 → 0.12.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 (165) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/cli.rb +127 -31
  3. data/lib/bolt/config.rb +39 -6
  4. data/lib/bolt/execution_result.rb +109 -0
  5. data/lib/bolt/executor.rb +4 -1
  6. data/lib/bolt/node.rb +6 -1
  7. data/lib/bolt/node/orch.rb +20 -2
  8. data/lib/bolt/node/winrm.rb +22 -10
  9. data/lib/bolt/node_uri.rb +5 -7
  10. data/lib/bolt/outputter/human.rb +60 -1
  11. data/lib/bolt/outputter/json.rb +11 -0
  12. data/lib/bolt/target.rb +32 -0
  13. data/lib/bolt/version.rb +1 -1
  14. data/modules/boltlib/lib/puppet/datatypes/executionresult.rb +30 -0
  15. data/modules/boltlib/lib/puppet/datatypes/target.rb +12 -0
  16. data/modules/boltlib/lib/puppet/functions/file_upload.rb +3 -3
  17. data/modules/boltlib/lib/puppet/functions/run_command.rb +3 -3
  18. data/modules/boltlib/lib/puppet/functions/run_script.rb +3 -3
  19. data/modules/boltlib/lib/puppet/functions/run_task.rb +10 -2
  20. data/vendored/puppet/lib/puppet/application/describe.rb +0 -1
  21. data/vendored/puppet/lib/puppet/configurer.rb +1 -1
  22. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +15 -9
  23. data/vendored/puppet/lib/puppet/datatypes.rb +213 -0
  24. data/vendored/puppet/lib/puppet/datatypes/error.rb +19 -0
  25. data/vendored/puppet/lib/puppet/datatypes/impl/error.rb +42 -0
  26. data/vendored/puppet/lib/puppet/error.rb +1 -1
  27. data/vendored/puppet/lib/puppet/face/catalog.rb +1 -1
  28. data/vendored/puppet/lib/puppet/face/epp.rb +3 -3
  29. data/vendored/puppet/lib/puppet/face/help.rb +12 -14
  30. data/vendored/puppet/lib/puppet/face/man.rb +1 -0
  31. data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
  32. data/vendored/puppet/lib/puppet/face/node.rb +1 -0
  33. data/vendored/puppet/lib/puppet/face/parser.rb +0 -1
  34. data/vendored/puppet/lib/puppet/face/status.rb +1 -0
  35. data/vendored/puppet/lib/puppet/feature/base.rb +1 -1
  36. data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +0 -1
  37. data/vendored/puppet/lib/puppet/file_system/uniquefile.rb +2 -2
  38. data/vendored/puppet/lib/puppet/forge/errors.rb +21 -29
  39. data/vendored/puppet/lib/puppet/functions.rb +64 -84
  40. data/vendored/puppet/lib/puppet/functions/defined.rb +0 -3
  41. data/vendored/puppet/lib/puppet/functions/find_file.rb +0 -1
  42. data/vendored/puppet/lib/puppet/functions/map.rb +0 -1
  43. data/vendored/puppet/lib/puppet/functions/regsubst.rb +1 -1
  44. data/vendored/puppet/lib/puppet/graph/simple_graph.rb +6 -10
  45. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +37 -25
  46. data/vendored/puppet/lib/puppet/indirector/file_server.rb +1 -1
  47. data/vendored/puppet/lib/puppet/indirector/indirection.rb +0 -2
  48. data/vendored/puppet/lib/puppet/indirector/rest.rb +9 -8
  49. data/vendored/puppet/lib/puppet/info_service/class_information_service.rb +1 -1
  50. data/vendored/puppet/lib/puppet/interface/option_manager.rb +1 -1
  51. data/vendored/puppet/lib/puppet/loaders.rb +1 -0
  52. data/vendored/puppet/lib/puppet/module.rb +6 -2
  53. data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  54. data/vendored/puppet/lib/puppet/module_tool/errors/installer.rb +29 -41
  55. data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +63 -138
  56. data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +15 -37
  57. data/vendored/puppet/lib/puppet/module_tool/errors/upgrader.rb +18 -30
  58. data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +1 -1
  59. data/vendored/puppet/lib/puppet/module_tool/metadata.rb +0 -1
  60. data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  61. data/vendored/puppet/lib/puppet/network/rights.rb +1 -1
  62. data/vendored/puppet/lib/puppet/node.rb +1 -1
  63. data/vendored/puppet/lib/puppet/node/environment.rb +1 -1
  64. data/vendored/puppet/lib/puppet/parameter/value_collection.rb +4 -17
  65. data/vendored/puppet/lib/puppet/parser/compiler.rb +1 -0
  66. data/vendored/puppet/lib/puppet/parser/functions.rb +0 -1
  67. data/vendored/puppet/lib/puppet/parser/functions/scanf.rb +1 -1
  68. data/vendored/puppet/lib/puppet/parser/scope.rb +4 -3
  69. data/vendored/puppet/lib/puppet/parser/script_compiler.rb +1 -0
  70. data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +3 -2
  71. data/vendored/puppet/lib/puppet/parser/type_loader.rb +1 -1
  72. data/vendored/puppet/lib/puppet/pops.rb +1 -0
  73. data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +3 -2
  74. data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +1 -1
  75. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -2
  76. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +6 -5
  77. data/vendored/puppet/lib/puppet/pops/functions/function.rb +2 -2
  78. data/vendored/puppet/lib/puppet/pops/loader/loader.rb +1 -1
  79. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +40 -4
  80. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +6 -2
  81. data/vendored/puppet/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +8 -8
  82. data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
  83. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +6 -26
  84. data/vendored/puppet/lib/puppet/pops/loaders.rb +11 -2
  85. data/vendored/puppet/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
  86. data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +4 -14
  87. data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +1 -1
  88. data/vendored/puppet/lib/puppet/pops/parser/code_merger.rb +2 -2
  89. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1471 -1501
  90. data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +0 -2
  91. data/vendored/puppet/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
  92. data/vendored/puppet/lib/puppet/pops/parser/interpolation_support.rb +1 -1
  93. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +2 -26
  94. data/vendored/puppet/lib/puppet/pops/parser/locator.rb +5 -7
  95. data/vendored/puppet/lib/puppet/pops/parser/parser_support.rb +2 -2
  96. data/vendored/puppet/lib/puppet/pops/parser/slurp_support.rb +0 -3
  97. data/vendored/puppet/lib/puppet/pops/pcore.rb +0 -11
  98. data/vendored/puppet/lib/puppet/pops/serialization/object.rb +3 -4
  99. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
  100. data/vendored/puppet/lib/puppet/pops/time/timespan.rb +1 -1
  101. data/vendored/puppet/lib/puppet/pops/types/iterable.rb +14 -7
  102. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +38 -7
  103. data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +21 -22
  104. data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
  105. data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +0 -1
  106. data/vendored/puppet/lib/puppet/pops/types/p_uri_type.rb +0 -1
  107. data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +1 -1
  108. data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +5 -1
  109. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +5 -1
  110. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +1 -5
  111. data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +21 -0
  112. data/vendored/puppet/lib/puppet/pops/types/types.rb +2 -7
  113. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +1 -3
  114. data/vendored/puppet/lib/puppet/property.rb +1 -1
  115. data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +3 -4
  116. data/vendored/puppet/lib/puppet/provider/exec.rb +0 -2
  117. data/vendored/puppet/lib/puppet/provider/nameservice.rb +6 -1
  118. data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
  119. data/vendored/puppet/lib/puppet/provider/package/appdmg.rb +0 -1
  120. data/vendored/puppet/lib/puppet/provider/package/apple.rb +0 -1
  121. data/vendored/puppet/lib/puppet/provider/package/macports.rb +2 -2
  122. data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +0 -1
  123. data/vendored/puppet/lib/puppet/provider/package/portage.rb +0 -1
  124. data/vendored/puppet/lib/puppet/provider/package/zypper.rb +2 -2
  125. data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  126. data/vendored/puppet/lib/puppet/provider/service/init.rb +1 -0
  127. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +3 -3
  128. data/vendored/puppet/lib/puppet/provider/user/aix.rb +1 -1
  129. data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +1 -1
  130. data/vendored/puppet/lib/puppet/provider/user/pw.rb +1 -1
  131. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -4
  132. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +1 -1
  133. data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +1 -1
  134. data/vendored/puppet/lib/puppet/reference/type.rb +0 -1
  135. data/vendored/puppet/lib/puppet/resource.rb +1 -2
  136. data/vendored/puppet/lib/puppet/resource/status.rb +0 -1
  137. data/vendored/puppet/lib/puppet/resource/type.rb +3 -3
  138. data/vendored/puppet/lib/puppet/resource/type_collection.rb +1 -1
  139. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +0 -1
  140. data/vendored/puppet/lib/puppet/ssl/host.rb +1 -1
  141. data/vendored/puppet/lib/puppet/syntax_checkers/base64.rb +1 -1
  142. data/vendored/puppet/lib/puppet/transaction/persistence.rb +1 -1
  143. data/vendored/puppet/lib/puppet/type.rb +17 -4
  144. data/vendored/puppet/lib/puppet/type/file.rb +3 -3
  145. data/vendored/puppet/lib/puppet/type/mount.rb +9 -0
  146. data/vendored/puppet/lib/puppet/type/schedule.rb +25 -13
  147. data/vendored/puppet/lib/puppet/type/tidy.rb +2 -2
  148. data/vendored/puppet/lib/puppet/type/user.rb +1 -1
  149. data/vendored/puppet/lib/puppet/util.rb +19 -14
  150. data/vendored/puppet/lib/puppet/util/filetype.rb +2 -2
  151. data/vendored/puppet/lib/puppet/util/json_lockfile.rb +1 -1
  152. data/vendored/puppet/lib/puppet/util/log.rb +5 -3
  153. data/vendored/puppet/lib/puppet/util/log/destinations.rb +0 -1
  154. data/vendored/puppet/lib/puppet/util/monkey_patches.rb +1 -1
  155. data/vendored/puppet/lib/puppet/util/network_device/config.rb +2 -2
  156. data/vendored/puppet/lib/puppet/util/plist.rb +6 -4
  157. data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  158. data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
  159. data/vendored/puppet/lib/puppet/util/storage.rb +2 -2
  160. data/vendored/puppet/lib/puppet/util/windows/registry.rb +2 -2
  161. data/vendored/puppet/lib/puppet/util/windows/sid.rb +0 -2
  162. data/vendored/puppet/lib/puppet/version.rb +1 -1
  163. data/vendored/puppet/lib/puppet_pal.rb +30 -17
  164. metadata +28 -7
  165. data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +0 -137
@@ -11,22 +11,13 @@ module Puppet::ModuleTool::Errors
11
11
  end
12
12
 
13
13
  def multiline
14
- module_versions_list = @modules.map do |mod|
14
+ message = []
15
+ message << _("Could not uninstall module '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@version) }
16
+ message << _(" No installed version of '%{module_name}' matches (%{version})") % { module_name: @module_name, version: v(@version) }
17
+ message += @modules.map do |mod|
15
18
  _(" '%{module_name}' (%{version}) is installed in %{path}") % { module_name: mod[:name], version: v(mod[:version]), path: mod[:path] }
16
- end.join("\n")
17
-
18
- if module_versions_list.empty?
19
- _(<<-MSG).chomp % { module_name: @module_name, version: v(@version)}
20
- Could not uninstall module '%{module_name}' (%{version})
21
- No installed version of '%{module_name}' matches (%{version})
22
- MSG
23
- else
24
- _(<<-MSG).chomp % { module_name: @module_name, version: v(@version), module_versions_list: module_versions_list }
25
- Could not uninstall module '%{module_name}' (%{version})
26
- No installed version of '%{module_name}' matches (%{version})
27
- %{module_versions_list}
28
- MSG
29
19
  end
20
+ message.join("\n")
30
21
  end
31
22
  end
32
23
 
@@ -41,32 +32,19 @@ Could not uninstall module '%{module_name}' (%{version})
41
32
  end
42
33
 
43
34
  def multiline
44
-
45
- module_requirements_list = @required_by.map do |mod|
46
- msg_variables = { module_name: mod['name'], version: v(mod['version']), module_dependency: @module_name,
47
- dependency_version: v(mod['version_requirement']) }
48
- _(" '%{module_name}' (%{version}) requires '%{module_dependency}' (%{dependency_version})") % msg_variables
49
- end.join("\n")
50
-
35
+ message = []
51
36
  if @requested_version
52
- msg_variables = { module_name: @module_name, requested_version: @requested_version, version: v(@installed_version),
53
- module_requirements_list: module_requirements_list }
54
- #TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
55
- _(<<-EOF).chomp % msg_variables
56
- Could not uninstall module '%{module_name}' (v%{requested_version})
57
- Other installed modules have dependencies on '%{module_name}' (%{version})
58
- %{module_requirements_list}
59
- Use `puppet module uninstall --force` to uninstall this module anyway
60
- EOF
37
+ message << _("Could not uninstall module '%{module_name}' (v%{requested_version})") % { module_name: @module_name, requested_version: @requested_version }
61
38
  else
62
- #TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
63
- _(<<-EOF) % { module_name: @module_name, version: v(@installed_version), module_requirements_list: module_requirements_list }
64
- Could not uninstall module '%{module_name}'
65
- Other installed modules have dependencies on '%{module_name}' (%{version})
66
- %{module_requirements_list}
67
- Use `puppet module uninstall --force` to uninstall this module anyway
68
- EOF
39
+ message << _("Could not uninstall module '%{module_name}'") % { module_name: @module_name }
40
+ end
41
+ message << _(" Other installed modules have dependencies on '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@installed_version) }
42
+ message += @required_by.map do |mod|
43
+ _(" '%{module_name}' (%{version}) requires '%{module_dep}' (%{dep_version})") % { module_name: mod['name'], version: v(mod['version']), module_dep: @module_name, dep_version: v(mod['version_requirement']) }
69
44
  end
45
+ #TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
46
+ message << _(" Use `puppet module uninstall --force` to uninstall this module anyway")
47
+ message.join("\n")
70
48
  end
71
49
  end
72
50
  end
@@ -21,36 +21,24 @@ module Puppet::ModuleTool::Errors
21
21
  end
22
22
 
23
23
  def multiline
24
+ message = []
25
+ message << _("Could not upgrade module '%{module_name}' (%{version})") % { module_name: @module_name, version: vstring }
24
26
  if @newer_versions.empty?
25
- # TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
26
- _(<<-MSG).chomp % { module_name: @module_name, version: vstring }
27
- Could not upgrade module '%{module_name}' (%{version})
28
- The installed version is already the latest version matching %{version}
29
- Use `puppet module upgrade --force` to upgrade only this module
30
- MSG
27
+ message << _(" The installed version is already the latest version matching %{version}") % { version: vstring }
31
28
  else
32
- if @possible_culprits.empty?
33
- # TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
34
- _(<<-MSG).chomp % { module_name: @module_name, version: vstring, count: @newer_versions.length }
35
- Could not upgrade module '%{module_name}' (%{version})
36
- There are %{count} newer versions
37
- No combination of dependency upgrades would satisfy all dependencies
38
- Use `puppet module upgrade --force` to upgrade only this module
39
- MSG
40
- else
41
- module_dependency_list = @possible_culprits.map {|name| " - #{name}"}.join("\n")
42
- # TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
43
- _(<<-MSG).chomp % { module_name: @module_name, version: vstring, count: @newer_versions.length, module_dependency_list: module_dependency_list }
44
- Could not upgrade module '%{module_name}' (%{version})
45
- There are %{count} newer versions
46
- No combination of dependency upgrades would satisfy all dependencies
47
- Dependencies will not be automatically upgraded across major versions
48
- Upgrading one or more of these modules may permit the upgrade to succeed:
49
- %{module_dependency_list}
50
- Use `puppet module upgrade --force` to upgrade only this module
51
- MSG
29
+ message << _(" There are %{count} newer versions") % { count: @newer_versions.length }
30
+ message << _(" No combination of dependency upgrades would satisfy all dependencies")
31
+ unless @possible_culprits.empty?
32
+ message << _(" Dependencies will not be automatically upgraded across major versions")
33
+ message << _(" Upgrading one or more of these modules may permit the upgrade to succeed:")
34
+ @possible_culprits.each do |name|
35
+ message << " - #{name}"
36
+ end
52
37
  end
53
38
  end
39
+ #TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
40
+ message << _(" Use `puppet module upgrade --force` to upgrade only this module")
41
+ message.join("\n")
54
42
  end
55
43
  end
56
44
 
@@ -66,10 +54,10 @@ Could not upgrade module '%{module_name}' (%{version})
66
54
  end
67
55
 
68
56
  def multiline
69
- _(<<-MSG).chomp % { action: @action, module_name: @module_name, version: vstring }
70
- Could not %{action} module '%{module_name}' (%{version})
71
- Downgrading is not allowed.
72
- MSG
57
+ message = []
58
+ message << _("Could not %{action} module '%{module_name}' (%{version})") % { action: @action, module_name: @module_name, version: vstring }
59
+ message << _(" Downgrading is not allowed.")
60
+ message.join("\n")
73
61
  end
74
62
  end
75
63
  end
@@ -60,7 +60,7 @@ module Puppet::ModuleTool
60
60
  name = mod.forge_name.tr('/', '-')
61
61
  begin
62
62
  version = SemanticPuppet::Version.parse(mod.version)
63
- rescue SemanticPuppet::Version::ValidationFailure => e
63
+ rescue SemanticPuppet::Version::ValidationFailure
64
64
  Puppet.warning _("%{module_name} (%{path}) has an invalid version number (%{version}). The version has been set to 0.0.0. If you are the maintainer for this module, please update the metadata.json with a valid Semantic Version (http://semver.org).") % { module_name: mod.name, path: mod.path, version: mod.version }
65
65
  version = SemanticPuppet::Version.parse("0.0.0")
66
66
  end
@@ -200,7 +200,6 @@ module Puppet::ModuleTool
200
200
  #
201
201
  # @param value [Object] The value to be tested
202
202
  def validate_data_provider(value)
203
- err = nil
204
203
  if value.is_a?(String)
205
204
  unless value =~ /^[a-zA-Z][a-zA-Z0-9_]*$/
206
205
  if value =~ /^[a-zA-Z]/
@@ -191,7 +191,7 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
191
191
  begin
192
192
  yield format
193
193
  true
194
- rescue Puppet::Network::FormatHandler::FormatError => e
194
+ rescue Puppet::Network::FormatHandler::FormatError
195
195
  false
196
196
  end
197
197
  end
@@ -34,7 +34,7 @@ class Rights
34
34
 
35
35
  def is_forbidden_and_why?(name, args = {})
36
36
  res = :nomatch
37
- right = @rights.find do |acl|
37
+ @rights.find do |acl|
38
38
  found = false
39
39
  # an acl can return :dunno, which means "I'm not qualified to answer your question,
40
40
  # please ask someone else". This is used when for instance an acl matches, but not for the
@@ -30,7 +30,7 @@ class Puppet::Node
30
30
  env_name = data['environment']
31
31
  env_name = env_name.intern unless env_name.nil?
32
32
  @environment_name = env_name
33
- environment = env_name
33
+ environment = env_name # rubocop:disable Lint/UselessAssignment
34
34
  end
35
35
 
36
36
  def self.from_data_hash(data)
@@ -295,7 +295,7 @@ class Puppet::Node::Environment
295
295
  # @param forge_name [String] The module name
296
296
  # @return [Puppet::Module, nil] The module if found, else nil
297
297
  def module_by_forge_name(forge_name)
298
- author, modname = forge_name.split('/')
298
+ _, modname = forge_name.split('/')
299
299
  found_mod = self.module(modname)
300
300
  found_mod and found_mod.forge_name == forge_name ?
301
301
  found_mod :
@@ -180,23 +180,10 @@ class Puppet::Parameter::ValueCollection
180
180
  def validate(value)
181
181
  return if empty?
182
182
 
183
- unless @values.detect { |name, v| v.match?(value) }
184
- str = if values.empty?
185
- if regexes.empty?
186
- _("Invalid value %{value}.") % { value: value.inspect }
187
- else
188
- _("Invalid value %{value}. Valid values match %{patterns_list}.") %
189
- { value: value.inspect, patterns_list: regexes.join(", ") }
190
- end
191
- else
192
- if regexes.empty?
193
- _("Invalid value %{value}. Valid values are %{values_list}.") %
194
- { value: value.inspect, values_list: values.join(", ") }
195
- else
196
- _("Invalid value %{value}. Valid values are %{values_list}. Valid values match %{patterns_list}.") %
197
- { value: value.inspect, values_list: values.join(", "), patterns_list: regexes.join(", ") }
198
- end
199
- end
183
+ unless @values.detect {|name, v| v.match?(value)}
184
+ str = _("Invalid value %{value}.") % { value: value.inspect }
185
+ str += " " + _("Valid values are %{value_list}.") % { value_list: values.join(", ") } unless values.empty?
186
+ str += " " + _("Valid values match %{pattern}.") % { pattern: regexes.join(", ") } unless regexes.empty?
200
187
  raise ArgumentError, str
201
188
  end
202
189
  end
@@ -720,6 +720,7 @@ class Puppet::Parser::Compiler
720
720
  Puppet.override( @context_overrides , _("For initializing compiler")) do
721
721
  # THE MAGIC STARTS HERE ! This triggers parsing, loading etc.
722
722
  @catalog.version = environment.known_resource_types.version
723
+ @loaders.pre_load
723
724
  end
724
725
 
725
726
  @catalog.add_resource(Puppet::Parser::Resource.new("stage", :main, :scope => @topscope))
@@ -198,7 +198,6 @@ module Puppet::Parser::Functions
198
198
  def self.function(name, environment = Puppet.lookup(:current_environment))
199
199
  name = name.intern
200
200
 
201
- func = nil
202
201
  unless func = get_function(name, environment)
203
202
  autoloader.load(name, environment)
204
203
  func = get_function(name, environment)
@@ -34,5 +34,5 @@ DOC
34
34
  ) do |args|
35
35
  data = args[0]
36
36
  format = args[1]
37
- result = data.scanf(format)
37
+ data.scanf(format)
38
38
  end
@@ -884,11 +884,12 @@ class Puppet::Parser::Scope
884
884
  path = detail[0]
885
885
  env_path = nil
886
886
  env_path = environment.configuration.path_to_env unless (environment.nil? || environment.configuration.nil?)
887
- if env_path && path && path.start_with?(env_path)
887
+ # check module paths first since they may be in the environment (i.e. they are longer)
888
+ if module_path = environment.full_modulepath.detect {|m_path| path.start_with?(m_path) }
889
+ path = "<module>" + path[module_path.length..-1]
890
+ elsif env_path && path && path.start_with?(env_path)
888
891
  path = "<env>" + path[env_path.length..-1]
889
892
  end
890
- # TODO: also shorten module paths to <module>/name/...
891
-
892
893
  # Make the output appear as "Scope(path, line)"
893
894
  "Scope(#{[path, detail[1]].join(', ')})"
894
895
  end
@@ -111,6 +111,7 @@ class Puppet::Parser::ScriptCompiler
111
111
 
112
112
  # Find and evaluate the top level code.
113
113
  def evaluate_main
114
+ @loaders.pre_load
114
115
  program = @loaders.load_main_manifest
115
116
  return program.nil? ? nil : Puppet::Pops::Parser::EvaluatingParser.singleton.evaluator.evaluate(program, @topscope)
116
117
  end
@@ -78,7 +78,8 @@ class Puppet::Parser::TemplateWrapper
78
78
  # Expose all the variables in our scope as instance variables of the
79
79
  # current object, making it possible to access them without conflict
80
80
  # to the regular methods.
81
- benchmark(:debug, _("Bound template variables for %{template_source}") % { template_source: template_source }) do
81
+ escaped_template_source = template_source.gsub(/%/, '%%')
82
+ benchmark(:debug, _("Bound template variables for %{template_source} in %%{seconds} seconds") % { template_source: escaped_template_source }) do
82
83
  scope.to_hash.each do |name, value|
83
84
  realname = name.gsub(/[^\w]/, "_")
84
85
  instance_variable_set("@#{realname}", value)
@@ -86,7 +87,7 @@ class Puppet::Parser::TemplateWrapper
86
87
  end
87
88
 
88
89
  result = nil
89
- benchmark(:debug, _("Interpolated template %{template_source}") % { template_source: template_source }) do
90
+ benchmark(:debug, _("Interpolated template %{template_source} in %%{seconds} seconds") % { template_source: escaped_template_source }) do
90
91
  template = ERB.new(string, 0, "-")
91
92
  template.filename = @__file__
92
93
  result = template.result(binding)
@@ -70,7 +70,7 @@ class Puppet::Parser::TypeLoader
70
70
  Puppet.debug {"Automatically imported #{fqname} from #{filename} into #{environment}"}
71
71
  return result
72
72
  end
73
- rescue TypeLoaderError => detail
73
+ rescue TypeLoaderError
74
74
  # I'm not convinced we should just drop these errors, but this
75
75
  # preserves existing behaviours.
76
76
  end
@@ -114,6 +114,7 @@ module Puppet
114
114
 
115
115
  require 'puppet/parser/ast/pops_bridge'
116
116
  require 'puppet/functions'
117
+ require 'puppet/datatypes'
117
118
 
118
119
  Puppet::Pops::Model.register_pcore_types
119
120
  end
@@ -27,8 +27,9 @@ class AccessOperator
27
27
  protected
28
28
 
29
29
  def access_Object(o, scope, keys)
30
- if o.is_a?(Puppet::Pops::Types::PuppetObject)
31
- access_func = o._pcore_type.functions(true)['[]']
30
+ type = Puppet::Pops::Types::TypeCalculator.infer(o)
31
+ if type.is_a?(Puppet::Pops::Types::TypeWithMembers)
32
+ access_func = type['[]']
32
33
  return access_func.invoke(o, scope, keys) unless access_func.nil?
33
34
  end
34
35
  fail(Issues::OPERATOR_NOT_APPLICABLE, @semantic.left_expr, :operator=>'[]', :left_value => o)
@@ -318,7 +318,7 @@ class Closure < CallableSignature
318
318
  closure_scope = enclosing_scope
319
319
 
320
320
  parameters.each do |param|
321
- arg_type, param_range = create_param_type(param, closure_scope)
321
+ arg_type, _ = create_param_type(param, closure_scope)
322
322
  key_type = type_factory.string(param.name.to_s)
323
323
  key_type = type_factory.optional(key_type) unless param.value.nil?
324
324
  members[key_type] = arg_type
@@ -442,9 +442,9 @@ class EvaluatorImpl
442
442
  end
443
443
  end
444
444
  result = left.send(operator, right)
445
- rescue NoMethodError => e
445
+ rescue NoMethodError
446
446
  fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left})
447
- rescue ZeroDivisionError => e
447
+ rescue ZeroDivisionError
448
448
  fail(Issues::DIV_BY_ZERO, bin_expr.right_expr)
449
449
  end
450
450
  case result
@@ -72,14 +72,15 @@ class Dispatch < Evaluator::CallableSignature
72
72
  new_args = []
73
73
  @weaving.each do |knit|
74
74
  if knit.is_a?(Array)
75
- injection_data = @injections[knit[0]]
75
+ injection_name = @injections[knit[0]]
76
76
  new_args <<
77
- case injection_data[3]
78
- when :dispatcher_internal
79
- # currently only supports :scope injection
77
+ case injection_name
78
+ when :scope
80
79
  scope
80
+ when :pal_script_compiler
81
+ Puppet.lookup(:pal_script_compiler)
81
82
  else
82
- raise_error ArgumentError, "Unknown injection #{injection_data[3]}"
83
+ raise ArgumentError, "Unknown injection #{injection_name}"
83
84
  end
84
85
  else
85
86
  # Careful so no new nil arguments are added since they would override default
@@ -49,13 +49,13 @@ class Puppet::Pops::Functions::Function
49
49
  rescue Puppet::Pops::Evaluator::Next => jumper
50
50
  begin
51
51
  throw :next, jumper.value
52
- rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION => uncaught
52
+ rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
53
53
  raise Puppet::ParseError.new("next() from context where this is illegal", jumper.file, jumper.line)
54
54
  end
55
55
  rescue Puppet::Pops::Evaluator::Return => jumper
56
56
  begin
57
57
  throw :return, jumper
58
- rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION => uncaught
58
+ rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
59
59
  raise Puppet::ParseError.new("return() from context where this is illegal", jumper.file, jumper.line)
60
60
  end
61
61
  end
@@ -29,7 +29,7 @@ class Loader
29
29
  attr_reader :loader_name
30
30
 
31
31
  # Describes the kinds of things that loaders can load
32
- LOADABLE_KINDS = [:func_4x, :func_4xpp, :type_pp, :resource_type_pp, :plan, :task].freeze
32
+ LOADABLE_KINDS = [:func_4x, :func_4xpp, :datatype, :type_pp, :resource_type_pp, :plan, :task].freeze
33
33
 
34
34
  # @param [String] name the name of the loader. Must be unique among all loaders maintained by a {Loader} instance
35
35
  def initialize(loader_name)
@@ -31,6 +31,7 @@ module LoaderPaths
31
31
  when :task
32
32
  result << TaskPath.new(loader) if Puppet[:tasks] && loader.loadables.include?(:task)
33
33
  when :type
34
+ result << DataTypePath.new(loader) if loader.loadables.include?(:datatype)
34
35
  result << TypePathPP.new(loader) if loader.loadables.include?(:type_pp)
35
36
  when :resource_type_pp
36
37
  result << ResourceTypeImplPP.new(loader) if loader.loadables.include?(:resource_type_pp)
@@ -203,6 +204,19 @@ module LoaderPaths
203
204
  end
204
205
  end
205
206
 
207
+ class DataTypePath < RubySmartPath
208
+ SYSTEM_TYPE_PATH = File.join('puppet', 'datatypes').freeze
209
+ TYPE_PATH = File.join('lib', SYSTEM_TYPE_PATH).freeze
210
+
211
+ def relative_path
212
+ lib_root? ? SYSTEM_TYPE_PATH : TYPE_PATH
213
+ end
214
+
215
+ def instantiator
216
+ RubyDataTypeInstantiator
217
+ end
218
+ end
219
+
206
220
  class TypePathPP < PuppetSmartPath
207
221
  TYPE_PATH_PP = 'types'.freeze
208
222
 
@@ -240,11 +254,15 @@ module LoaderPaths
240
254
  # Remove extension regardless of what it is. A task name cannot contain dots
241
255
  relative_path = relative_path.sub(/\.[^\/]*\z/, '')
242
256
 
243
- relative_path.split('/').each do |segment|
244
- n << '::' if n.size > 0
245
- n << segment
257
+ if relative_path == 'init' && !(module_name.nil? || module_name.empty?)
258
+ TypedName.new(type, module_name, name_authority)
259
+ else
260
+ relative_path.split('/').each do |segment|
261
+ n << '::' if n.size > 0
262
+ n << segment
263
+ end
264
+ TypedName.new(type, n, name_authority)
246
265
  end
247
- TypedName.new(type, n, name_authority)
248
266
  end
249
267
 
250
268
  def instantiator
@@ -302,6 +320,24 @@ module LoaderPaths
302
320
  def instantiator()
303
321
  Puppet::Pops::Loader::PuppetPlanInstantiator
304
322
  end
323
+
324
+ def typed_name(type, name_authority, relative_path, module_name)
325
+ if relative_path == 'init.pp' && !(module_name.nil? || module_name.empty?)
326
+ TypedName.new(type, module_name, name_authority)
327
+ else
328
+ n = ''
329
+ n << module_name unless module_name.nil?
330
+ unless extension.empty?
331
+ # Remove extension
332
+ relative_path = relative_path[0..-(extension.length+1)]
333
+ end
334
+ relative_path.split('/').each do |segment|
335
+ n << '::' if n.size > 0
336
+ n << segment
337
+ end
338
+ TypedName.new(type, n, name_authority)
339
+ end
340
+ end
305
341
  end
306
342
 
307
343
  # SmartPaths