puppet 4.3.1-x86-mingw32 → 4.3.2-x86-mingw32

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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +1 -1
  3. data/lib/hiera/scope.rb +1 -1
  4. data/lib/puppet/application/lookup.rb +41 -43
  5. data/lib/puppet/data_providers/lookup_adapter.rb +73 -26
  6. data/lib/puppet/functions/lookup.rb +126 -150
  7. data/lib/puppet/functions/match.rb +1 -0
  8. data/lib/puppet/indirector/hiera.rb +3 -1
  9. data/lib/puppet/indirector/indirection.rb +6 -2
  10. data/lib/puppet/indirector/json.rb +2 -2
  11. data/lib/puppet/module.rb +3 -2
  12. data/lib/puppet/node.rb +11 -2
  13. data/lib/puppet/parser/compiler.rb +1 -8
  14. data/lib/puppet/parser/functions/lookup.rb +128 -149
  15. data/lib/puppet/parser/functions/match.rb +1 -0
  16. data/lib/puppet/plugins/data_providers/data_provider.rb +3 -2
  17. data/lib/puppet/pops/adapters.rb +43 -0
  18. data/lib/puppet/pops/evaluator/access_operator.rb +3 -3
  19. data/lib/puppet/pops/evaluator/closure.rb +51 -51
  20. data/lib/puppet/pops/evaluator/collector_transformer.rb +16 -0
  21. data/lib/puppet/pops/evaluator/runtime3_support.rb +11 -2
  22. data/lib/puppet/pops/functions/function.rb +6 -2
  23. data/lib/puppet/pops/issues.rb +16 -0
  24. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +3 -2
  25. data/lib/puppet/pops/lookup.rb +3 -0
  26. data/lib/puppet/pops/lookup/explainer.rb +73 -3
  27. data/lib/puppet/pops/lookup/invocation.rb +21 -19
  28. data/lib/puppet/pops/model/factory.rb +153 -155
  29. data/lib/puppet/pops/model/model.rb +9 -0
  30. data/lib/puppet/pops/model/model_label_provider.rb +1 -0
  31. data/lib/puppet/pops/parser/evaluating_parser.rb +3 -3
  32. data/lib/puppet/pops/parser/lexer2.rb +411 -393
  33. data/lib/puppet/pops/parser/slurp_support.rb +5 -1
  34. data/lib/puppet/pops/types/type_calculator.rb +2 -6
  35. data/lib/puppet/pops/types/types.rb +3 -9
  36. data/lib/puppet/pops/validation/checker4_0.rb +36 -12
  37. data/lib/puppet/provider/group/windows_adsi.rb +2 -2
  38. data/lib/puppet/provider/package/pip.rb +11 -1
  39. data/lib/puppet/provider/package/rpm.rb +0 -1
  40. data/lib/puppet/provider/package/yum.rb +1 -1
  41. data/lib/puppet/provider/service/debian.rb +5 -18
  42. data/lib/puppet/provider/service/init.rb +7 -0
  43. data/lib/puppet/provider/service/launchd.rb +6 -0
  44. data/lib/puppet/provider/service/systemd.rb +1 -1
  45. data/lib/puppet/provider/user/windows_adsi.rb +2 -2
  46. data/lib/puppet/provider/yumrepo/inifile.rb +6 -3
  47. data/lib/puppet/resource/type.rb +2 -1
  48. data/lib/puppet/transaction/additional_resource_generator.rb +17 -3
  49. data/lib/puppet/type/group.rb +6 -2
  50. data/lib/puppet/util/windows.rb +4 -0
  51. data/lib/puppet/util/windows/adsi.rb +61 -24
  52. data/lib/puppet/util/windows/principal.rb +181 -0
  53. data/lib/puppet/util/windows/registry.rb +21 -15
  54. data/lib/puppet/util/windows/sid.rb +42 -11
  55. data/lib/puppet/version.rb +1 -1
  56. data/spec/fixtures/unit/application/environments/production/data/common.yaml +4 -0
  57. data/spec/fixtures/unit/application/environments/production/manifests/site.pp +1 -0
  58. data/spec/fixtures/unit/application/environments/puppet_func_provider/environment.conf +1 -0
  59. data/spec/fixtures/unit/application/environments/puppet_func_provider/functions/data.pp +10 -0
  60. data/spec/fixtures/unit/application/environments/puppet_func_provider/manifests/site.pp +1 -0
  61. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/common.yaml +4 -0
  62. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/specific.yaml +4 -0
  63. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/hiera.yaml +7 -0
  64. data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/common.yaml +4 -0
  65. data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/specific.yaml +4 -0
  66. data/spec/fixtures/unit/data_providers/environments/hiera_modules/environment.conf +2 -0
  67. data/spec/fixtures/unit/data_providers/environments/hiera_modules/hiera.yaml +7 -0
  68. data/spec/fixtures/unit/data_providers/environments/hiera_modules/manifests/site.pp +1 -0
  69. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/data/common.yaml +6 -0
  70. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/hiera.yaml +5 -0
  71. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/manifests/init.pp +2 -0
  72. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/metadata.json +9 -0
  73. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/data/common.yaml +4 -0
  74. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/hiera.yaml +5 -0
  75. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/manifests/init.pp +3 -0
  76. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/metadata.json +9 -0
  77. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/functions/usee_puppet.pp +3 -0
  78. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{usee → modules/usee}/lib/puppet/functions/usee/callee.rb +0 -0
  79. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/functions/usee/usee_ruby.rb +6 -0
  80. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/manifests/init.pp +6 -0
  81. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee2/lib/puppet/functions/usee2/callee.rb +5 -0
  82. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet.pp +5 -0
  83. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet_init.pp +5 -0
  84. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_ruby.pp +5 -0
  85. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/lib/puppet/functions/user/caller.rb +0 -0
  86. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/caller2.rb +5 -0
  87. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet.rb +5 -0
  88. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet_init.rb +5 -0
  89. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_ruby.rb +5 -0
  90. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +81 -0
  91. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/metadata.json +2 -1
  92. data/spec/integration/parser/collection_spec.rb +8 -0
  93. data/spec/integration/util/windows/principal_spec.rb +115 -0
  94. data/spec/{unit → integration}/util/windows/registry_spec.rb +91 -1
  95. data/spec/integration/util/windows/security_spec.rb +2 -2
  96. data/spec/unit/application/lookup_spec.rb +138 -28
  97. data/spec/unit/data_providers/hiera_data_provider_spec.rb +182 -5
  98. data/spec/unit/face/epp_face_spec.rb +2 -2
  99. data/spec/unit/functions/epp_spec.rb +6 -6
  100. data/spec/unit/functions/inline_epp_spec.rb +4 -4
  101. data/spec/unit/functions/lookup_spec.rb +30 -3
  102. data/spec/unit/functions4_spec.rb +1 -1
  103. data/spec/unit/hiera/scope_spec.rb +5 -2
  104. data/spec/unit/indirector/json_spec.rb +1 -1
  105. data/spec/unit/node_spec.rb +8 -0
  106. data/spec/unit/parser/compiler_spec.rb +0 -18
  107. data/spec/unit/pops/evaluator/access_ops_spec.rb +4 -4
  108. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +1 -1
  109. data/spec/unit/pops/loaders/loaders_spec.rb +84 -2
  110. data/spec/unit/pops/parser/lexer2_spec.rb +6 -0
  111. data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
  112. data/spec/unit/pops/types/type_calculator_spec.rb +0 -17
  113. data/spec/unit/pops/validator/validator_spec.rb +87 -0
  114. data/spec/unit/provider/group/windows_adsi_spec.rb +8 -8
  115. data/spec/unit/provider/package/pip_spec.rb +41 -13
  116. data/spec/unit/provider/package/rpm_spec.rb +2 -25
  117. data/spec/unit/provider/package/yum_spec.rb +1 -1
  118. data/spec/unit/provider/service/debian_spec.rb +6 -24
  119. data/spec/unit/provider/service/init_spec.rb +11 -1
  120. data/spec/unit/provider/service/launchd_spec.rb +11 -0
  121. data/spec/unit/provider/service/systemd_spec.rb +18 -12
  122. data/spec/unit/provider/service/upstart_spec.rb +57 -0
  123. data/spec/unit/provider/user/windows_adsi_spec.rb +5 -5
  124. data/spec/unit/provider/yumrepo/inifile_spec.rb +16 -0
  125. data/spec/unit/resource_spec.rb +12 -2
  126. data/spec/unit/util/windows/adsi_spec.rb +44 -36
  127. data/spec/unit/util/windows/sid_spec.rb +47 -10
  128. metadata +77 -10
@@ -14,6 +14,16 @@ describe Puppet::Application::Lookup do
14
14
  expect { lookup.run_command }.to raise_error(RuntimeError, expected_error)
15
15
  end
16
16
 
17
+ it "does not allow invalid arguments for '--merge'" do
18
+ lookup.options[:node] = 'dantooine.local'
19
+ lookup.options[:merge] = 'something_bad'
20
+ lookup.command_line.stubs(:args).returns(['atton', 'kreia'])
21
+
22
+ expected_error = "The --merge option only accepts 'first', 'hash', 'unique', or 'deep'\nRun 'puppet lookup --help' for more details"
23
+
24
+ expect { lookup.run_command }.to raise_error(RuntimeError, expected_error)
25
+ end
26
+
17
27
  it "does not allow deep merge options if '--merge' was not set to deep" do
18
28
  lookup.options[:node] = 'dantooine.local'
19
29
  lookup.options[:merge_hash_arrays] = true
@@ -44,6 +54,18 @@ describe Puppet::Application::Lookup do
44
54
  expect { lookup.run_command }.to output("rand\n").to_stdout
45
55
  end
46
56
 
57
+ %w(first unique hash deep).each do |opt|
58
+
59
+ it "accepts --merge #{opt}" do
60
+ lookup.options[:node] = 'dantooine.local'
61
+ lookup.options[:merge] = opt
62
+ lookup.command_line.stubs(:args).returns(['atton', 'kreia'])
63
+ lookup.stubs(:generate_scope).yields('scope')
64
+ Puppet::Pops::Lookup.stubs(:lookup).returns('rand')
65
+ expect { lookup.run_command }.to output("--- rand\n...\n").to_stdout
66
+ end
67
+ end
68
+
47
69
  it "prints the value found by lookup" do
48
70
  lookup.options[:node] = 'dantooine.local'
49
71
  lookup.command_line.stubs(:args).returns(['atton', 'kreia'])
@@ -56,7 +78,7 @@ describe Puppet::Application::Lookup do
56
78
  end
57
79
 
58
80
 
59
- context 'when asked to explain' do
81
+ context 'when given a valid configuration' do
60
82
  let (:lookup) { Puppet::Application[:lookup] }
61
83
 
62
84
  # There is a fully configured 'sample' environment in fixtures at this location
@@ -64,7 +86,7 @@ describe Puppet::Application::Lookup do
64
86
 
65
87
  let(:facts) { Puppet::Node::Facts.new("facts", {}) }
66
88
 
67
- let(:node) { Puppet::Node.new("testnode", :facts => facts, :environment => environment) }
89
+ let(:node) { Puppet::Node.new("testnode", :facts => facts, :environment => 'production') }
68
90
 
69
91
  let(:expected_json_hash) { {
70
92
  'type' => 'merge',
@@ -104,30 +126,30 @@ describe Puppet::Application::Lookup do
104
126
  :event => :result,
105
127
  :value => 'This is A',
106
128
  :branches => [
107
- { :key => 'a',
108
- :event => :not_found,
109
- :type => :global,
110
- :name => :hiera
111
- },
112
- {
113
- :type => :data_provider,
114
- :name => 'Hiera Data Provider, version 4',
115
- :configuration_path => "#{environmentpath}/production/hiera.yaml",
116
- :branches => [
129
+ { :key => 'a',
130
+ :event => :not_found,
131
+ :type => :global,
132
+ :name => :hiera
133
+ },
117
134
  {
118
135
  :type => :data_provider,
119
- :name => 'common',
136
+ :name => 'Hiera Data Provider, version 4',
137
+ :configuration_path => "#{environmentpath}/production/hiera.yaml",
120
138
  :branches => [
121
- {
122
- :key => 'a',
123
- :value => 'This is A',
124
- :event => :found,
125
- :type => :path,
126
- :original_path => 'common',
127
- :path => "#{environmentpath}/production/data/common.yaml",
128
- }]
129
- }]
130
- }]
139
+ {
140
+ :type => :data_provider,
141
+ :name => 'common',
142
+ :branches => [
143
+ {
144
+ :key => 'a',
145
+ :value => 'This is A',
146
+ :event => :found,
147
+ :type => :path,
148
+ :original_path => 'common',
149
+ :path => "#{environmentpath}/production/data/common.yaml",
150
+ }]
151
+ }]
152
+ }]
131
153
  } }
132
154
 
133
155
  around(:each) do |example|
@@ -140,8 +162,8 @@ describe Puppet::Application::Lookup do
140
162
  end
141
163
  end
142
164
 
143
- it 'produces human readable text by default' do
144
- lookup.options[:node] = Puppet::Node.new("testnode", :facts => facts, :environment => 'production')
165
+ it '--explain produces human readable text by default' do
166
+ lookup.options[:node] = node
145
167
  lookup.options[:explain] = true
146
168
  lookup.command_line.stubs(:args).returns(['a'])
147
169
  expect { lookup.run_command }.to output(<<-EXPLANATION).to_stdout
@@ -152,14 +174,70 @@ Merge strategy first
152
174
  ConfigurationPath "#{environmentpath}/production/hiera.yaml"
153
175
  Data Provider "common"
154
176
  Path "#{environmentpath}/production/data/common.yaml"
155
- Original path: common
177
+ Original path: "common"
156
178
  Found key: "a" value: "This is A"
157
179
  Merged result: "This is A"
158
180
  EXPLANATION
159
181
  end
160
182
 
183
+ it '--explain produces human readable text of a hash merge when using --explain-options' do
184
+ lookup.options[:node] = node
185
+ lookup.options[:explain_options] = true
186
+ expect { lookup.run_command }.to output(<<-EXPLANATION).to_stdout
187
+ Merge strategy hash
188
+ Data Binding "hiera"
189
+ No such key: "lookup_options"
190
+ Data Provider "Hiera Data Provider, version 4"
191
+ ConfigurationPath "#{environmentpath}/production/hiera.yaml"
192
+ Data Provider "common"
193
+ Path "#{environmentpath}/production/data/common.yaml"
194
+ Original path: "common"
195
+ Found key: "lookup_options" value: {
196
+ "a" => "first"
197
+ }
198
+ Merged result: {
199
+ "a" => "first"
200
+ }
201
+ EXPLANATION
202
+ end
203
+
204
+ it '--explain produces human readable text of a hash merge when using both --explain and --explain-options' do
205
+ lookup.options[:node] = node
206
+ lookup.options[:explain] = true
207
+ lookup.options[:explain_options] = true
208
+ lookup.command_line.stubs(:args).returns(['a'])
209
+ expect { lookup.run_command }.to output(<<-EXPLANATION).to_stdout
210
+ Searching for "lookup_options"
211
+ Merge strategy hash
212
+ Data Binding "hiera"
213
+ No such key: "lookup_options"
214
+ Data Provider "Hiera Data Provider, version 4"
215
+ ConfigurationPath "#{environmentpath}/production/hiera.yaml"
216
+ Data Provider "common"
217
+ Path "#{environmentpath}/production/data/common.yaml"
218
+ Original path: "common"
219
+ Found key: "lookup_options" value: {
220
+ "a" => "first"
221
+ }
222
+ Merged result: {
223
+ "a" => "first"
224
+ }
225
+ Searching for "a"
226
+ Merge strategy first
227
+ Data Binding "hiera"
228
+ No such key: "a"
229
+ Data Provider "Hiera Data Provider, version 4"
230
+ ConfigurationPath "#{environmentpath}/production/hiera.yaml"
231
+ Data Provider "common"
232
+ Path "#{environmentpath}/production/data/common.yaml"
233
+ Original path: "common"
234
+ Found key: "a" value: "This is A"
235
+ Merged result: "This is A"
236
+ EXPLANATION
237
+ end
238
+
161
239
  it 'can produce a yaml explanation' do
162
- lookup.options[:node] = Puppet::Node.new("testnode", :facts => facts, :environment => 'production')
240
+ lookup.options[:node] = node
163
241
  lookup.options[:explain] = true
164
242
  lookup.options[:render_as] = :yaml
165
243
  lookup.command_line.stubs(:args).returns(['a'])
@@ -176,7 +254,7 @@ Merge strategy first
176
254
  end
177
255
 
178
256
  it 'can produce a json explanation' do
179
- lookup.options[:node] = Puppet::Node.new("testnode", :facts => facts, :environment => 'production')
257
+ lookup.options[:node] = node
180
258
  lookup.options[:explain] = true
181
259
  lookup.options[:render_as] = :json
182
260
  lookup.command_line.stubs(:args).returns(['a'])
@@ -191,5 +269,37 @@ Merge strategy first
191
269
  end
192
270
  expect(JSON.parse(output)).to eq(expected_json_hash)
193
271
  end
272
+
273
+ context 'the global scope' do
274
+ it "is unaffected by global variables unless '--compile' is used" do
275
+ lookup.options[:node] = node
276
+ lookup.command_line.stubs(:args).returns(['c'])
277
+ expect { lookup.run_command }.to output("--- This is\n...\n").to_stdout
278
+ end
279
+
280
+ it "is affected by global variables when '--compile' is used" do
281
+ lookup.options[:node] = node
282
+ lookup.options[:compile] = true
283
+ lookup.command_line.stubs(:args).returns(['c'])
284
+ expect { lookup.run_command }.to output("--- This is C from site.pp\n...\n").to_stdout
285
+ end
286
+ end
287
+
288
+ context 'using a puppet function as data provider' do
289
+ let(:node) { Puppet::Node.new("testnode", :facts => facts, :environment => 'puppet_func_provider') }
290
+
291
+ it "works OK in the absense of '--compile'" do
292
+ lookup.options[:node] = node
293
+ lookup.command_line.stubs(:args).returns(['c'])
294
+ expect { lookup.run_command }.to output("--- This is C from data.pp\n...\n").to_stdout
295
+ end
296
+
297
+ it "global scope is affected by global variables when '--compile' is used" do
298
+ lookup.options[:node] = node
299
+ lookup.options[:compile] = true
300
+ lookup.command_line.stubs(:args).returns(['c'])
301
+ expect { lookup.run_command }.to output("--- This is C from site.pp\n...\n").to_stdout
302
+ end
303
+ end
194
304
  end
195
305
  end
@@ -53,6 +53,12 @@ describe "when using a hiera data provider" do
53
53
  expect(resources).to include('module data param_a is 100, module data param_b is 200, module data param_c is 300, module data param_d is 400, module data param_e is 500')
54
54
  end
55
55
 
56
+ it 'keeps lookup_options in one module separate from lookup_options in another' do
57
+ resources1 = compile('hiera_modules', 'include one').resources.select {|r| r.ref.start_with?('Class[One]')}
58
+ resources2 = compile('hiera_modules', 'include two').resources.select {|r| r.ref.start_with?('Class[One]')}
59
+ expect(resources1).to eq(resources2)
60
+ end
61
+
56
62
  it 'does not perform merge of values declared in environment and module when resolving parameters' do
57
63
  resources = compile_and_get_notifications('hiera_misc')
58
64
  expect(resources).to include('env 1, ')
@@ -81,10 +87,8 @@ describe "when using a hiera data provider" do
81
87
  expect(resources[0]).to eq('A, B, C, MA, MB, MC')
82
88
  end
83
89
 
84
- it "can lookup the 'lookup_options' hash as a regular value" do
85
- resources = compile_and_get_notifications('hiera_misc', '$r = lookup(lookup_options, Hash[String,Hash[String,String]], hash) notify{"${r[one::lopts_test::hash][merge]}":}')
86
- expect(resources.size).to eq(1)
87
- expect(resources[0]).to eq('deep')
90
+ it "will not find 'lookup_options' as a regular value" do
91
+ expect { compile_and_get_notifications('hiera_misc', '$r = lookup("lookup_options")') }.to raise_error(Puppet::DataBinding::LookupError, /did not find a value/)
88
92
  end
89
93
 
90
94
  it 'does find unqualified keys in the environment' do
@@ -180,16 +184,189 @@ Merge strategy first
180
184
  ConfigurationPath "#{environmentpath}/hiera_misc/hiera.yaml"
181
185
  Data Provider "common"
182
186
  Path "#{environmentpath}/hiera_misc/data/common.yaml"
183
- Original path: common
187
+ Original path: "common"
184
188
  Interpolation on "Value from interpolation %{scope("target_scope")}"
185
189
  Global Scope"
186
190
  Found key: "target_scope" value: "with scope"
187
191
  Found key: "km_scope" value: "Value from interpolation with scope"
188
192
  Merged result: "Value from interpolation with scope"
193
+ EOS
194
+ end
195
+ end
196
+
197
+ it 'will report that merge options was found in the lookup_options hash' do
198
+ compile('hiera_misc', '$target_scope = "with scope"') do |compiler|
199
+ lookup_invocation = Puppet::Pops::Lookup::Invocation.new(compiler.topscope, {}, {}, true)
200
+ value = Puppet::Pops::Lookup.lookup('one::loptsm_test::hash', nil, nil, nil, nil, lookup_invocation)
201
+ expect(lookup_invocation.explainer.to_s).to eq(<<EOS)
202
+ Using merge options from "lookup_options" hash
203
+ Merge strategy deep
204
+ Data Binding "hiera"
205
+ No such key: "one::loptsm_test::hash"
206
+ Data Provider "Hiera Data Provider, version 4"
207
+ ConfigurationPath "#{environmentpath}/hiera_misc/hiera.yaml"
208
+ Data Provider "common"
209
+ Path "#{environmentpath}/hiera_misc/data/common.yaml"
210
+ Original path: "common"
211
+ Found key: "one::loptsm_test::hash" value: {
212
+ "a" => "A",
213
+ "b" => "B",
214
+ "m" => {
215
+ "ma" => "MA",
216
+ "mb" => "MB"
217
+ }
218
+ }
219
+ Module "one" using Data Provider "Hiera Data Provider, version 4"
220
+ ConfigurationPath "#{environmentpath}/hiera_misc/modules/one/hiera.yaml"
221
+ Data Provider "common"
222
+ Path "#{environmentpath}/hiera_misc/modules/one/data/common.yaml"
223
+ Original path: "common"
224
+ Found key: "one::loptsm_test::hash" value: {
225
+ "a" => "A",
226
+ "c" => "C",
227
+ "m" => {
228
+ "ma" => "MA",
229
+ "mc" => "MC",
230
+ "mb" => "MB"
231
+ }
232
+ }
233
+ Merged result: {
234
+ "a" => "A",
235
+ "c" => "C",
236
+ "m" => {
237
+ "ma" => "MA",
238
+ "mc" => "MC",
239
+ "mb" => "MB"
240
+ },
241
+ "b" => "B"
242
+ }
243
+ EOS
244
+ end
245
+ end
246
+
247
+ it 'will report lookup_options details in combination with details of found value' do
248
+ compile('hiera_misc', '$target_scope = "with scope"') do |compiler|
249
+ lookup_invocation = Puppet::Pops::Lookup::Invocation.new(compiler.topscope, {}, {}, Puppet::Pops::Lookup::Explainer.new(true))
250
+ value = Puppet::Pops::Lookup.lookup('one::loptsm_test::hash', nil, nil, nil, nil, lookup_invocation)
251
+ expect(lookup_invocation.explainer.to_s).to eq(<<EOS)
252
+ Searching for "lookup_options"
253
+ Merge strategy hash
254
+ Data Binding "hiera"
255
+ No such key: "lookup_options"
256
+ Data Provider "Hiera Data Provider, version 4"
257
+ ConfigurationPath "#{environmentpath}/hiera_misc/hiera.yaml"
258
+ Data Provider "common"
259
+ Path "#{environmentpath}/hiera_misc/data/common.yaml"
260
+ Original path: "common"
261
+ Found key: "lookup_options" value: {
262
+ "one::lopts_test::hash" => {
263
+ "merge" => "deep"
264
+ }
265
+ }
266
+ Module "one" using Data Provider "Hiera Data Provider, version 4"
267
+ ConfigurationPath "#{environmentpath}/hiera_misc/modules/one/hiera.yaml"
268
+ Data Provider "common"
269
+ Path "#{environmentpath}/hiera_misc/modules/one/data/common.yaml"
270
+ Original path: "common"
271
+ Found key: "lookup_options" value: {
272
+ "one::loptsm_test::hash" => {
273
+ "merge" => "deep"
274
+ }
275
+ }
276
+ Merged result: {
277
+ "one::loptsm_test::hash" => {
278
+ "merge" => "deep"
279
+ },
280
+ "one::lopts_test::hash" => {
281
+ "merge" => "deep"
282
+ }
283
+ }
284
+ Searching for "one::loptsm_test::hash"
285
+ Merge strategy deep
286
+ Data Binding "hiera"
287
+ No such key: "one::loptsm_test::hash"
288
+ Data Provider "Hiera Data Provider, version 4"
289
+ ConfigurationPath "#{environmentpath}/hiera_misc/hiera.yaml"
290
+ Data Provider "common"
291
+ Path "#{environmentpath}/hiera_misc/data/common.yaml"
292
+ Original path: "common"
293
+ Found key: "one::loptsm_test::hash" value: {
294
+ "a" => "A",
295
+ "b" => "B",
296
+ "m" => {
297
+ "ma" => "MA",
298
+ "mb" => "MB"
299
+ }
300
+ }
301
+ Module "one" using Data Provider "Hiera Data Provider, version 4"
302
+ ConfigurationPath "#{environmentpath}/hiera_misc/modules/one/hiera.yaml"
303
+ Data Provider "common"
304
+ Path "#{environmentpath}/hiera_misc/modules/one/data/common.yaml"
305
+ Original path: "common"
306
+ Found key: "one::loptsm_test::hash" value: {
307
+ "a" => "A",
308
+ "c" => "C",
309
+ "m" => {
310
+ "ma" => "MA",
311
+ "mc" => "MC",
312
+ "mb" => "MB"
313
+ }
314
+ }
315
+ Merged result: {
316
+ "a" => "A",
317
+ "c" => "C",
318
+ "m" => {
319
+ "ma" => "MA",
320
+ "mc" => "MC",
321
+ "mb" => "MB"
322
+ },
323
+ "b" => "B"
324
+ }
325
+ EOS
326
+ end
327
+ end
328
+
329
+ it 'will report config path (original and resolved), data path (original and resolved), and interpolation (before and after)' do
330
+ compile('hiera_misc', '$target_scope = "with scope"') do |compiler|
331
+ lookup_invocation = Puppet::Pops::Lookup::Invocation.new(compiler.topscope, {}, {}, Puppet::Pops::Lookup::Explainer.new(true, true))
332
+ value = Puppet::Pops::Lookup.lookup('one::loptsm_test::hash', nil, nil, nil, nil, lookup_invocation)
333
+ expect(lookup_invocation.explainer.to_s).to eq(<<EOS)
334
+ Merge strategy hash
335
+ Data Binding "hiera"
336
+ No such key: "lookup_options"
337
+ Data Provider "Hiera Data Provider, version 4"
338
+ ConfigurationPath "#{environmentpath}/hiera_misc/hiera.yaml"
339
+ Data Provider "common"
340
+ Path "#{environmentpath}/hiera_misc/data/common.yaml"
341
+ Original path: "common"
342
+ Found key: "lookup_options" value: {
343
+ "one::lopts_test::hash" => {
344
+ "merge" => "deep"
345
+ }
346
+ }
347
+ Module "one" using Data Provider "Hiera Data Provider, version 4"
348
+ ConfigurationPath "#{environmentpath}/hiera_misc/modules/one/hiera.yaml"
349
+ Data Provider "common"
350
+ Path "#{environmentpath}/hiera_misc/modules/one/data/common.yaml"
351
+ Original path: "common"
352
+ Found key: "lookup_options" value: {
353
+ "one::loptsm_test::hash" => {
354
+ "merge" => "deep"
355
+ }
356
+ }
357
+ Merged result: {
358
+ "one::loptsm_test::hash" => {
359
+ "merge" => "deep"
360
+ },
361
+ "one::lopts_test::hash" => {
362
+ "merge" => "deep"
363
+ }
364
+ }
189
365
  EOS
190
366
  end
191
367
  end
192
368
  end
369
+
193
370
  def parent_fixture(dir_name)
194
371
  File.absolute_path(File.join(my_fixture_dir(), "../#{dir_name}"))
195
372
  end
@@ -150,7 +150,7 @@ describe Puppet::Face[:epp, :current] do
150
150
  dir = dir_containing('templates', { template_name => "<% 1 2 3 %>" })
151
151
  template = File.join(dir, template_name)
152
152
  expect(eppface.dump(template, :validate => true)).to eq("")
153
- expect(@logs.join).to match(/This Literal Integer has no effect.* line 1:4/)
153
+ expect(@logs.join).to match(/This Literal Integer has no effect.*\/template1.epp:1:4/)
154
154
  end
155
155
 
156
156
  it "validated content by default" do
@@ -158,7 +158,7 @@ describe Puppet::Face[:epp, :current] do
158
158
  dir = dir_containing('templates', { template_name => "<% 1 2 3 %>" })
159
159
  template = File.join(dir, template_name)
160
160
  expect(eppface.dump(template)).to eq("")
161
- expect(@logs.join).to match(/This Literal Integer has no effect.* line 1:4/)
161
+ expect(@logs.join).to match(/This Literal Integer has no effect.*\/template1.epp:1:4/)
162
162
  end
163
163
 
164
164
  it "informs the user of files that don't exist" do