puppet 7.1.0-universal-darwin → 7.6.1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +38 -30
  3. data/ext/build_defaults.yaml +0 -1
  4. data/lib/puppet/application.rb +10 -6
  5. data/lib/puppet/application/agent.rb +1 -0
  6. data/lib/puppet/application/apply.rb +3 -2
  7. data/lib/puppet/application/device.rb +1 -0
  8. data/lib/puppet/application/script.rb +1 -0
  9. data/lib/puppet/application/ssl.rb +11 -0
  10. data/lib/puppet/configurer.rb +16 -3
  11. data/lib/puppet/defaults.rb +14 -19
  12. data/lib/puppet/environments.rb +16 -1
  13. data/lib/puppet/face/facts.rb +26 -2
  14. data/lib/puppet/ffi/windows/api_types.rb +1 -1
  15. data/lib/puppet/ffi/windows/constants.rb +1 -1
  16. data/lib/puppet/file_serving/configuration/parser.rb +5 -2
  17. data/lib/puppet/file_system/memory_file.rb +8 -1
  18. data/lib/puppet/file_system/windows.rb +2 -0
  19. data/lib/puppet/functions.rb +1 -1
  20. data/lib/puppet/functions/partition.rb +8 -0
  21. data/lib/puppet/http/factory.rb +4 -0
  22. data/lib/puppet/indirector/facts/facter.rb +1 -0
  23. data/lib/puppet/loaders.rb +0 -4
  24. data/lib/puppet/module.rb +1 -0
  25. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  26. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  27. data/lib/puppet/network/formats.rb +67 -0
  28. data/lib/puppet/network/http.rb +5 -2
  29. data/lib/puppet/network/http/api.rb +10 -6
  30. data/lib/puppet/network/http/api/master.rb +3 -2
  31. data/lib/puppet/network/http/api/master/v3.rb +2 -25
  32. data/lib/puppet/network/http/api/master/v3/environments.rb +2 -33
  33. data/lib/puppet/network/http/api/server.rb +10 -0
  34. data/lib/puppet/network/http/api/server/v3.rb +39 -0
  35. data/lib/puppet/network/http/api/server/v3/environments.rb +48 -0
  36. data/lib/puppet/node/environment.rb +12 -5
  37. data/lib/puppet/parser/ast/leaf.rb +3 -2
  38. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  39. data/lib/puppet/pops/loader/base_loader.rb +42 -32
  40. data/lib/puppet/pops/loader/dependency_loader.rb +2 -2
  41. data/lib/puppet/pops/loader/loader.rb +15 -5
  42. data/lib/puppet/pops/loader/module_loaders.rb +8 -8
  43. data/lib/puppet/pops/loader/predefined_loader.rb +4 -0
  44. data/lib/puppet/pops/loader/runtime3_type_loader.rb +1 -1
  45. data/lib/puppet/pops/loader/static_loader.rb +4 -0
  46. data/lib/puppet/pops/loaders.rb +4 -4
  47. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  48. data/lib/puppet/pops/parser/lexer2.rb +0 -4
  49. data/lib/puppet/pops/types/p_type_set_type.rb +1 -1
  50. data/lib/puppet/pops/validation/checker4_0.rb +0 -1
  51. data/lib/puppet/property/list.rb +1 -1
  52. data/lib/puppet/provider/group/groupadd.rb +13 -8
  53. data/lib/puppet/provider/package/apt.rb +34 -2
  54. data/lib/puppet/provider/package/aptitude.rb +6 -0
  55. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  56. data/lib/puppet/provider/package/puppet_gem.rb +12 -1
  57. data/lib/puppet/provider/service/debian.rb +2 -0
  58. data/lib/puppet/provider/service/systemd.rb +1 -1
  59. data/lib/puppet/provider/user/useradd.rb +62 -8
  60. data/lib/puppet/reference/configuration.rb +6 -5
  61. data/lib/puppet/settings.rb +36 -30
  62. data/lib/puppet/settings/alias_setting.rb +37 -0
  63. data/lib/puppet/settings/environment_conf.rb +1 -0
  64. data/lib/puppet/type/package.rb +3 -3
  65. data/lib/puppet/util/autoload.rb +1 -8
  66. data/lib/puppet/util/monkey_patches.rb +7 -0
  67. data/lib/puppet/util/posix.rb +1 -1
  68. data/lib/puppet/util/windows/adsi.rb +46 -0
  69. data/lib/puppet/util/windows/principal.rb +9 -2
  70. data/lib/puppet/util/windows/sid.rb +4 -2
  71. data/lib/puppet/version.rb +1 -1
  72. data/locales/puppet.pot +166 -146
  73. data/man/man5/puppet.conf.5 +14 -6
  74. data/man/man8/puppet-agent.8 +2 -2
  75. data/man/man8/puppet-apply.8 +2 -2
  76. data/man/man8/puppet-catalog.8 +1 -1
  77. data/man/man8/puppet-config.8 +1 -1
  78. data/man/man8/puppet-describe.8 +1 -1
  79. data/man/man8/puppet-device.8 +2 -2
  80. data/man/man8/puppet-doc.8 +1 -1
  81. data/man/man8/puppet-epp.8 +1 -1
  82. data/man/man8/puppet-facts.8 +8 -2
  83. data/man/man8/puppet-filebucket.8 +1 -1
  84. data/man/man8/puppet-generate.8 +1 -1
  85. data/man/man8/puppet-help.8 +1 -1
  86. data/man/man8/puppet-lookup.8 +1 -1
  87. data/man/man8/puppet-module.8 +1 -1
  88. data/man/man8/puppet-node.8 +1 -1
  89. data/man/man8/puppet-parser.8 +1 -1
  90. data/man/man8/puppet-plugin.8 +1 -1
  91. data/man/man8/puppet-report.8 +1 -1
  92. data/man/man8/puppet-resource.8 +1 -1
  93. data/man/man8/puppet-script.8 +2 -2
  94. data/man/man8/puppet-ssl.8 +5 -1
  95. data/man/man8/puppet.8 +2 -2
  96. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  97. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  98. data/spec/integration/application/agent_spec.rb +160 -3
  99. data/spec/integration/application/apply_spec.rb +19 -0
  100. data/spec/integration/application/plugin_spec.rb +1 -1
  101. data/spec/integration/defaults_spec.rb +0 -7
  102. data/spec/integration/http/client_spec.rb +12 -0
  103. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  104. data/spec/integration/indirector/file_content/file_server_spec.rb +0 -2
  105. data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -2
  106. data/spec/integration/parser/collection_spec.rb +10 -0
  107. data/spec/integration/resource/type_collection_spec.rb +2 -6
  108. data/spec/integration/transaction_spec.rb +4 -9
  109. data/spec/integration/util/windows/adsi_spec.rb +21 -1
  110. data/spec/integration/util/windows/principal_spec.rb +21 -0
  111. data/spec/integration/util/windows/registry_spec.rb +6 -10
  112. data/spec/spec_helper.rb +12 -5
  113. data/spec/unit/agent_spec.rb +8 -6
  114. data/spec/unit/application/agent_spec.rb +0 -1
  115. data/spec/unit/application/facts_spec.rb +58 -7
  116. data/spec/unit/application/filebucket_spec.rb +0 -2
  117. data/spec/unit/application/ssl_spec.rb +23 -0
  118. data/spec/unit/application_spec.rb +17 -9
  119. data/spec/unit/confine/feature_spec.rb +1 -1
  120. data/spec/unit/confine_spec.rb +8 -2
  121. data/spec/unit/environments_spec.rb +164 -88
  122. data/spec/unit/face/node_spec.rb +0 -11
  123. data/spec/unit/file_serving/configuration/parser_spec.rb +8 -1
  124. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  125. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  126. data/spec/unit/file_system_spec.rb +9 -0
  127. data/spec/unit/forge/module_release_spec.rb +2 -7
  128. data/spec/unit/http/factory_spec.rb +19 -0
  129. data/spec/unit/indirector/face_spec.rb +0 -1
  130. data/spec/unit/indirector/facts/facter_spec.rb +20 -5
  131. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  132. data/spec/unit/indirector/indirection_spec.rb +8 -12
  133. data/spec/unit/indirector_spec.rb +2 -2
  134. data/spec/unit/module_spec.rb +1 -1
  135. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  136. data/spec/unit/network/formats_spec.rb +41 -0
  137. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -4
  138. data/spec/unit/network/http/api/master_spec.rb +38 -0
  139. data/spec/unit/network/http/api/{master → server}/v3/environments_spec.rb +2 -2
  140. data/spec/unit/network/http/api/{master → server}/v3_spec.rb +19 -19
  141. data/spec/unit/network/http/api_spec.rb +11 -11
  142. data/spec/unit/parser/compiler_spec.rb +3 -19
  143. data/spec/unit/parser/resource_spec.rb +14 -8
  144. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  145. data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
  146. data/spec/unit/pops/parser/lexer2_spec.rb +0 -4
  147. data/spec/unit/pops/types/type_parser_spec.rb +2 -1
  148. data/spec/unit/pops/validator/validator_spec.rb +20 -43
  149. data/spec/unit/property_spec.rb +1 -0
  150. data/spec/unit/provider/group/groupadd_spec.rb +5 -2
  151. data/spec/unit/provider/nameservice_spec.rb +66 -65
  152. data/spec/unit/provider/package/apt_spec.rb +28 -23
  153. data/spec/unit/provider/package/aptitude_spec.rb +1 -1
  154. data/spec/unit/provider/package/base_spec.rb +6 -5
  155. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  156. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  157. data/spec/unit/provider/package/pip_spec.rb +6 -11
  158. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  159. data/spec/unit/provider/package/puppet_gem_spec.rb +28 -0
  160. data/spec/unit/provider/service/systemd_spec.rb +11 -0
  161. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  162. data/spec/unit/provider/user/useradd_spec.rb +70 -3
  163. data/spec/unit/provider_spec.rb +6 -8
  164. data/spec/unit/resource/type_spec.rb +1 -1
  165. data/spec/unit/resource_spec.rb +11 -10
  166. data/spec/unit/settings_spec.rb +13 -6
  167. data/spec/unit/ssl/base_spec.rb +0 -1
  168. data/spec/unit/ssl/certificate_request_spec.rb +4 -10
  169. data/spec/unit/ssl/ssl_provider_spec.rb +5 -2
  170. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  171. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  172. data/spec/unit/transaction_spec.rb +13 -4
  173. data/spec/unit/type/file/content_spec.rb +0 -1
  174. data/spec/unit/type/file/selinux_spec.rb +0 -2
  175. data/spec/unit/type/file_spec.rb +0 -6
  176. data/spec/unit/type/group_spec.rb +13 -6
  177. data/spec/unit/type/resources_spec.rb +7 -7
  178. data/spec/unit/type/service_spec.rb +1 -1
  179. data/spec/unit/type/tidy_spec.rb +0 -1
  180. data/spec/unit/type_spec.rb +2 -2
  181. data/spec/unit/util/at_fork_spec.rb +2 -2
  182. data/spec/unit/util/autoload_spec.rb +5 -1
  183. data/spec/unit/util/backups_spec.rb +1 -2
  184. data/spec/unit/util/execution_spec.rb +15 -11
  185. data/spec/unit/util/inifile_spec.rb +6 -14
  186. data/spec/unit/util/log_spec.rb +8 -7
  187. data/spec/unit/util/logging_spec.rb +3 -3
  188. data/spec/unit/util/posix_spec.rb +16 -10
  189. data/spec/unit/util/selinux_spec.rb +76 -52
  190. data/spec/unit/util/suidmanager_spec.rb +44 -41
  191. data/spec/unit/util/windows/sid_spec.rb +6 -0
  192. data/spec/unit/util_spec.rb +13 -6
  193. metadata +18 -16
  194. data/spec/lib/matchers/include.rb +0 -27
  195. data/spec/lib/matchers/include_spec.rb +0 -32
  196. data/spec/unit/pops/parser/parse_application_spec.rb +0 -13
  197. data/spec/unit/pops/parser/parse_capabilities_spec.rb +0 -23
  198. data/spec/unit/pops/parser/parse_site_spec.rb +0 -43
@@ -0,0 +1,48 @@
1
+ require 'puppet/util/json'
2
+
3
+ module Puppet
4
+ module Network
5
+ module HTTP
6
+ class API
7
+ module Server
8
+ class V3
9
+ class Environments
10
+
11
+ def initialize(env_loader)
12
+ @env_loader = env_loader
13
+ end
14
+
15
+ def call(request, response)
16
+ response.respond_with(200, "application/json", Puppet::Util::Json.dump({
17
+ "search_paths" => @env_loader.search_paths,
18
+ "environments" => Hash[@env_loader.list.collect do |env|
19
+ [env.name, {
20
+ "settings" => {
21
+ "modulepath" => env.full_modulepath,
22
+ "manifest" => env.manifest,
23
+ "environment_timeout" => timeout(env),
24
+ "config_version" => env.config_version || '',
25
+ }
26
+ }]
27
+ end]
28
+ }))
29
+ end
30
+
31
+ private
32
+
33
+ def timeout(env)
34
+ ttl = @env_loader.get_conf(env.name).environment_timeout
35
+ if ttl == Float::INFINITY
36
+ "unlimited"
37
+ else
38
+ ttl
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
@@ -214,15 +214,22 @@ class Puppet::Node::Environment
214
214
  errors
215
215
  end
216
216
 
217
+ def rich_data_from_env_conf
218
+ unless @checked_conf_for_rich_data
219
+ environment_conf = Puppet.lookup(:environments).get_conf(name)
220
+ @rich_data_from_conf = environment_conf&.rich_data
221
+ @checked_conf_for_rich_data = true
222
+ end
223
+ @rich_data_from_conf
224
+ end
225
+
217
226
  # Checks if this environment permits use of rich data types in the catalog
227
+ # Checks the environment conf for an override on first query, then going forward
228
+ # either uses that, or if unset, uses the current value of the `rich_data` setting.
218
229
  # @return [Boolean] `true` if rich data is permitted.
219
230
  # @api private
220
231
  def rich_data?
221
- if @rich_data.nil?
222
- environment_conf = Puppet.lookup(:environments).get_conf(name)
223
- @rich_data = (environment_conf.nil? ? Puppet[:rich_data] : environment_conf.rich_data)
224
- end
225
- @rich_data
232
+ @rich_data = rich_data_from_env_conf.nil? ? Puppet[:rich_data] : rich_data_from_env_conf
226
233
  end
227
234
 
228
235
  # Return an environment-specific Puppet setting.
@@ -50,8 +50,9 @@ class Puppet::Parser::AST::HostName < Puppet::Parser::AST::Leaf
50
50
  end
51
51
 
52
52
  class Puppet::Parser::AST::Regex < Puppet::Parser::AST::Leaf
53
- def initialize(hash)
54
- super(**hash)
53
+ def initialize(value: nil, file: nil, line: nil, pos: nil)
54
+ super(value: value, file: file, line: line, pos: pos)
55
+
55
56
  # transform value from hash options unless it is already a regular expression
56
57
  @value = Regexp.new(@value) unless @value.is_a?(Regexp)
57
58
  end
@@ -16,10 +16,12 @@ class DeferredResolver
16
16
  #
17
17
  # @param facts [Puppet::Node::Facts] the facts object for the node
18
18
  # @param catalog [Puppet::Resource::Catalog] the catalog where all deferred values should be replaced
19
+ # @param environment [Puppet::Node::Environment] the environment whose anonymous module methods
20
+ # are to be mixed into the scope
19
21
  # @return [nil] does not return anything - the catalog is modified as a side effect
20
22
  #
21
- def self.resolve_and_replace(facts, catalog)
22
- compiler = Puppet::Parser::ScriptCompiler.new(catalog.environment_instance, catalog.name, true)
23
+ def self.resolve_and_replace(facts, catalog, environment = catalog.environment_instance)
24
+ compiler = Puppet::Parser::ScriptCompiler.new(environment, catalog.name, true)
23
25
  resolver = new(compiler)
24
26
  resolver.set_facts_variable(facts)
25
27
  # TODO:
@@ -108,7 +110,7 @@ class DeferredResolver
108
110
  # If any of the arguments to a future is a future it needs to be resolved first
109
111
  func_name = f.name
110
112
  mapped_arguments = map_arguments(f.arguments)
111
- # if name starts with $ then this is a call to dig
113
+ # if name starts with $ then this is a call to dig
112
114
  if func_name[0] == DOLLAR
113
115
  var_name = func_name[1..-1]
114
116
  func_name = DIG
@@ -13,8 +13,8 @@ class BaseLoader < Loader
13
13
  # The parent loader
14
14
  attr_reader :parent
15
15
 
16
- def initialize(parent_loader, loader_name)
17
- super(loader_name)
16
+ def initialize(parent_loader, loader_name, environment)
17
+ super(loader_name, environment)
18
18
  @parent = parent_loader # the higher priority loader to consult
19
19
  @named_values = {} # hash name => NamedEntry
20
20
  @last_result = nil # the value of the last name (optimization)
@@ -38,22 +38,26 @@ class BaseLoader < Loader
38
38
  # These modules are typically parented by the same
39
39
  # loader as the one initiating the search. It is inefficient to again try to search the same loader for
40
40
  # the same name.
41
- if @last_result.nil? || typed_name != @last_result.typed_name
42
- @last_result = internal_load(typed_name)
43
- else
44
- @last_result
41
+ synchronize do
42
+ if @last_result.nil? || typed_name != @last_result.typed_name
43
+ @last_result = internal_load(typed_name)
44
+ else
45
+ @last_result
46
+ end
45
47
  end
46
48
  end
47
49
 
48
50
  # @api public
49
51
  #
50
52
  def loaded_entry(typed_name, check_dependencies = false)
51
- if @named_values.has_key?(typed_name)
52
- @named_values[typed_name]
53
- elsif parent
54
- parent.loaded_entry(typed_name, check_dependencies)
55
- else
56
- nil
53
+ synchronize do
54
+ if @named_values.has_key?(typed_name)
55
+ @named_values[typed_name]
56
+ elsif parent
57
+ parent.loaded_entry(typed_name, check_dependencies)
58
+ else
59
+ nil
60
+ end
57
61
  end
58
62
  end
59
63
 
@@ -68,23 +72,25 @@ class BaseLoader < Loader
68
72
  # @api private
69
73
  #
70
74
  def set_entry(typed_name, value, origin = nil)
71
- # It is never ok to redefine in the very same loader unless redefining a 'not found'
72
- entry = @named_values[typed_name]
73
- if entry
74
- fail_redefine(entry) unless entry.value.nil?
75
- end
76
-
77
- # Check if new entry shadows existing entry and fail
78
- # (unless special loader allows shadowing)
79
- if typed_name.type == :type && !allow_shadowing?
80
- entry = loaded_entry(typed_name)
75
+ synchronize do
76
+ # It is never ok to redefine in the very same loader unless redefining a 'not found'
77
+ entry = @named_values[typed_name]
81
78
  if entry
82
- fail_redefine(entry) unless entry.value.nil? #|| entry.value == value
79
+ fail_redefine(entry) unless entry.value.nil?
80
+ end
81
+
82
+ # Check if new entry shadows existing entry and fail
83
+ # (unless special loader allows shadowing)
84
+ if typed_name.type == :type && !allow_shadowing?
85
+ entry = loaded_entry(typed_name)
86
+ if entry
87
+ fail_redefine(entry) unless entry.value.nil? #|| entry.value == value
88
+ end
83
89
  end
84
- end
85
90
 
86
- @last_result = Loader::NamedEntry.new(typed_name, value, origin)
87
- @named_values[typed_name] = @last_result
91
+ @last_result = Loader::NamedEntry.new(typed_name, value, origin)
92
+ @named_values[typed_name] = @last_result
93
+ end
88
94
  end
89
95
 
90
96
  # @api private
@@ -96,8 +102,10 @@ class BaseLoader < Loader
96
102
  # @api private
97
103
  #
98
104
  def remove_entry(typed_name)
99
- unless @named_values.delete(typed_name).nil?
100
- @last_result = nil unless @last_result.nil? || typed_name != @last_result.typed_name
105
+ synchronize do
106
+ unless @named_values.delete(typed_name).nil?
107
+ @last_result = nil unless @last_result.nil? || typed_name != @last_result.typed_name
108
+ end
101
109
  end
102
110
  end
103
111
 
@@ -106,10 +114,12 @@ class BaseLoader < Loader
106
114
  # @api private
107
115
  #
108
116
  def promote_entry(named_entry)
109
- typed_name = named_entry.typed_name
110
- entry = @named_values[typed_name]
111
- if entry then fail_redefine(entry); end
112
- @named_values[typed_name] = named_entry
117
+ synchronize do
118
+ typed_name = named_entry.typed_name
119
+ entry = @named_values[typed_name]
120
+ if entry then fail_redefine(entry); end
121
+ @named_values[typed_name] = named_entry
122
+ end
113
123
  end
114
124
 
115
125
  protected
@@ -18,8 +18,8 @@ class Puppet::Pops::Loader::DependencyLoader < Puppet::Pops::Loader::BaseLoader
18
18
  # @param name [String] the name of the dependency-loader (used for debugging and tracing only)
19
19
  # @param dependency_loaders [Array<Puppet::Pops::Loader>] array of loaders for modules this module depends on
20
20
  #
21
- def initialize(parent_loader, name, dependency_loaders)
22
- super parent_loader, name
21
+ def initialize(parent_loader, name, dependency_loaders, environment)
22
+ super(parent_loader, name, environment)
23
23
  @dependency_loaders = dependency_loaders
24
24
  end
25
25
 
@@ -26,14 +26,15 @@ ENVIRONMENT = 'environment'.freeze
26
26
  ENVIRONMENT_PRIVATE = 'environment private'.freeze
27
27
 
28
28
  class Loader
29
- attr_reader :loader_name
29
+ attr_reader :environment, :loader_name
30
30
 
31
31
  # Describes the kinds of things that loaders can load
32
32
  LOADABLE_KINDS = [:func_4x, :func_4xpp, :func_3x, :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
- def initialize(loader_name)
35
+ def initialize(loader_name, environment)
36
36
  @loader_name = loader_name.freeze
37
+ @environment = environment
37
38
  end
38
39
 
39
40
  # Search all places where this loader would find values of a given type and return a list the
@@ -69,9 +70,11 @@ class Loader
69
70
  # @api public
70
71
  #
71
72
  def load(type, name)
72
- result = load_typed(TypedName.new(type, name.to_s))
73
- if result
74
- result.value
73
+ synchronize do
74
+ result = load_typed(TypedName.new(type, name.to_s))
75
+ if result
76
+ result.value
77
+ end
75
78
  end
76
79
  end
77
80
 
@@ -143,6 +146,13 @@ class Loader
143
146
  self
144
147
  end
145
148
 
149
+ # Lock around a block
150
+ # This exists so some subclasses that are set up statically and don't actually
151
+ # load can override it
152
+ def synchronize(&block)
153
+ @environment.lock.synchronize(&block)
154
+ end
155
+
146
156
  # Binds a value to a name. The name should not start with '::', but may contain multiple segments.
147
157
  #
148
158
  # @param type [:Symbol] the type of the entity being set
@@ -45,17 +45,17 @@ module ModuleLoaders
45
45
  #
46
46
  puppet_lib = File.realpath(File.join(File.dirname(__FILE__), '../../..'))
47
47
  LibRootedFileBased.new(parent_loader,
48
- loaders,
49
- nil,
50
- puppet_lib, # may or may not have a 'lib' above 'puppet'
51
- 'puppet_system',
52
- [:func_4x, :func_3x, :datatype] # only load ruby functions and types from "puppet"
53
- )
48
+ loaders,
49
+ nil,
50
+ puppet_lib, # may or may not have a 'lib' above 'puppet'
51
+ 'puppet_system',
52
+ [:func_4x, :func_3x, :datatype] # only load ruby functions and types from "puppet"
53
+ )
54
54
  end
55
55
 
56
56
  def self.environment_loader_from(parent_loader, loaders, env_path)
57
57
  if env_path.nil? || env_path.empty?
58
- EmptyLoader.new(parent_loader, ENVIRONMENT)
58
+ EmptyLoader.new(parent_loader, ENVIRONMENT, loaders.environment)
59
59
  else
60
60
  FileBased.new(parent_loader,
61
61
  loaders,
@@ -125,7 +125,7 @@ module ModuleLoaders
125
125
  # @param loader_name [String] a name that is used for human identification (useful when module_name is nil)
126
126
  #
127
127
  def initialize(parent_loader, loaders, module_name, path, loader_name, loadables)
128
- super parent_loader, loader_name
128
+ super(parent_loader, loader_name, loaders.environment)
129
129
 
130
130
  raise ArgumentError, 'path based loader cannot be instantiated without a path' if path.nil? || path.empty?
131
131
 
@@ -19,6 +19,10 @@ class PredefinedLoader < BaseLoader
19
19
  def allow_shadowing?
20
20
  true
21
21
  end
22
+
23
+ def synchronize(&block)
24
+ yield
25
+ end
22
26
  end
23
27
 
24
28
  end
@@ -10,7 +10,7 @@ class Runtime3TypeLoader < BaseLoader
10
10
  attr_reader :resource_3x_loader
11
11
 
12
12
  def initialize(parent_loader, loaders, environment, resource_3x_loader)
13
- super(parent_loader, environment.name)
13
+ super(parent_loader, environment.name, environment)
14
14
  @environment = environment
15
15
  @resource_3x_loader = resource_3x_loader
16
16
  end
@@ -122,6 +122,10 @@ class StaticLoader < Loader
122
122
  def create_resource_type_reference(name)
123
123
  add_type(name, Types::TypeFactory.resource(name))
124
124
  end
125
+
126
+ def synchronize(&block)
127
+ yield
128
+ end
125
129
  end
126
130
  end
127
131
  end
@@ -398,7 +398,7 @@ class Loaders
398
398
 
399
399
  if env_path.nil?
400
400
  # Not a real directory environment, cannot work as a module TODO: Drop when legacy env are dropped?
401
- loader = add_loader_by_name(Loader::SimpleEnvironmentLoader.new(@runtime3_type_loader, Loader::ENVIRONMENT))
401
+ loader = add_loader_by_name(Loader::SimpleEnvironmentLoader.new(@runtime3_type_loader, Loader::ENVIRONMENT, environment))
402
402
  else
403
403
  # View the environment as a module to allow loading from it - this module is always called 'environment'
404
404
  loader = Loader::ModuleLoaders.environment_loader_from(@runtime3_type_loader, self, env_path)
@@ -413,7 +413,7 @@ class Loaders
413
413
  # Code in the environment gets to see all modules (since there is no metadata for the environment)
414
414
  # but since this is not given to the module loaders, they can not load global code (since they can not
415
415
  # have prior knowledge about this
416
- loader = add_loader_by_name(Loader::DependencyLoader.new(loader, Loader::ENVIRONMENT_PRIVATE, @module_resolver.all_module_loaders()))
416
+ loader = add_loader_by_name(Loader::DependencyLoader.new(loader, Loader::ENVIRONMENT_PRIVATE, @module_resolver.all_module_loaders(), environment))
417
417
 
418
418
  # The module loader gets the private loader via a lazy operation to look up the module's private loader.
419
419
  # This does not work for an environment since it is not resolved the same way.
@@ -529,13 +529,13 @@ class Loaders
529
529
  private
530
530
 
531
531
  def create_loader_with_all_modules_visible(from_module_data)
532
- @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", all_module_loaders()))
532
+ @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", all_module_loaders(), @loaders.environment))
533
533
  end
534
534
 
535
535
  def create_loader_with_dependencies_first(from_module_data)
536
536
  dependency_loaders = from_module_data.dependency_names.collect { |name| @index[name].public_loader }
537
537
  visible_loaders = dependency_loaders + (all_module_loaders() - dependency_loaders)
538
- @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", visible_loaders))
538
+ @loaders.add_loader_by_name(Loader::DependencyLoader.new(from_module_data.public_loader, "#{from_module_data.name} private", visible_loaders, @loaders.environment))
539
539
  end
540
540
  end
541
541
  end
@@ -31,7 +31,7 @@ class Puppet::Pops::Model::AstTransformer
31
31
  def ast(o, klass, hash={})
32
32
  # create and pass hash with file and line information
33
33
  # PUP-3274 - still needed since hostname transformation requires AST::HostName, and AST::Regexp
34
- klass.new(merge_location(hash, o))
34
+ klass.new(**merge_location(hash, o))
35
35
  end
36
36
 
37
37
  # THIS IS AN EXPENSIVE OPERATION
@@ -134,10 +134,6 @@ class Lexer2
134
134
  'type' => [:TYPE, 'type', 4],
135
135
  'attr' => [:ATTR, 'attr', 4],
136
136
  'private' => [:PRIVATE, 'private', 7],
137
- 'application' => [:APPLICATION, 'application', 11], # reserved
138
- 'consumes' => [:CONSUMES, 'consumes', 8], # reserved
139
- 'produces' => [:PRODUCES, 'produces', 8], # reserved
140
- 'site' => [:SITE, 'site', 4], # reserved
141
137
  }
142
138
 
143
139
  KEYWORDS.each {|k,v| v[1].freeze; v.freeze }
@@ -15,7 +15,7 @@ class PTypeSetType < PMetaType
15
15
  # @api private
16
16
  class TypeSetLoader < Loader::BaseLoader
17
17
  def initialize(type_set, parent)
18
- super(parent, "(TypeSetFirstLoader '#{type_set.name}')")
18
+ super(parent, "(TypeSetFirstLoader '#{type_set.name}')", parent.environment)
19
19
  @type_set = type_set
20
20
  end
21
21
 
@@ -236,7 +236,6 @@ class Checker4_0 < Evaluator::LiteralEvaluator
236
236
  case p
237
237
  when Model::AbstractResource
238
238
  when Model::CollectExpression
239
- acceptor.accept(Issues::UNSUPPORTED_OPERATOR_IN_CONTEXT, p, :operator=>'* =>')
240
239
  else
241
240
  # protect against just testing a snippet that has no parent, error message will be a bit strange
242
241
  # but it is not for a real program.
@@ -47,7 +47,7 @@ module Puppet
47
47
  #ok, some 'convention' if the list property is named groups, provider should implement a groups method
48
48
  tmp = provider.send(name) if provider
49
49
  if tmp && tmp != :absent
50
- return tmp.split(delimiter)
50
+ return tmp.instance_of?(Array) ? tmp : tmp.split(delimiter)
51
51
  else
52
52
  return :absent
53
53
  end
@@ -130,16 +130,21 @@ Puppet::Type.type(:group).provide :groupadd, :parent => Puppet::Provider::NameSe
130
130
  private
131
131
 
132
132
  def findgroup(key, value)
133
- group_file = "/etc/group"
133
+ group_file = '/etc/group'
134
134
  group_keys = [:group_name, :password, :gid, :user_list]
135
- index = group_keys.index(key)
136
- @group_content ||= File.read(group_file)
137
- @group_content.each_line do |line|
138
- group = line.split(":")
139
- if group[index] == value
140
- return Hash[group_keys.zip(group)]
135
+
136
+ unless @groups
137
+ unless Puppet::FileSystem.exist?(group_file)
138
+ raise Puppet::Error.new("Forcelocal set for group resource '#{resource[:name]}', but #{group_file} does not exist")
139
+ end
140
+
141
+ @groups = []
142
+ Puppet::FileSystem.each_line(group_file) do |line|
143
+ group = line.chomp.split(':')
144
+ @groups << Hash[group_keys.zip(group)]
141
145
  end
142
146
  end
143
- false
147
+
148
+ @groups.find { |param| param[key] == value } || false
144
149
  end
145
150
  end