hybrid_platforms_conductor 33.8.0 → 33.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -0
  3. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +17 -16
  4. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +10 -8
  5. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +1 -1
  6. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +94 -2
  7. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +8 -3
  8. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  9. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +63 -0
  10. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +16 -1
  11. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/metadata.rb +13 -0
  12. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/31_unknown_recipe_include.rb +2 -0
  13. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/32_unknown_cookbook_include.rb +2 -0
  14. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/33_unknown_include.rb +3 -0
  15. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/34_known_include.rb +1 -0
  16. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/35_unparsable_include.rb +7 -0
  17. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_1.rb +1 -0
  18. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_2.rb +1 -0
  19. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_3.rb +1 -0
  20. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_4.rb +1 -0
  21. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_5/recipes/recipe_1.rb +1 -0
  22. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_5/recipes/recipe_2.rb +1 -0
  23. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node31.json +10 -0
  24. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node32.json +10 -0
  25. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node33.json +10 -0
  26. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node34.json +10 -0
  27. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node35.json +10 -0
  28. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_31.rb +4 -0
  29. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_32.rb +4 -0
  30. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_33.rb +4 -0
  31. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_34.rb +4 -0
  32. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_35.rb +4 -0
  33. metadata +24 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cd97aeaa58547169eee76dd4605b3ee08b9188c718bbef6d3757186d7a6dfdc
4
- data.tar.gz: e054326d38480c3480578b44e78c10f481e82b750486f5c1c8007ee2491731da
3
+ metadata.gz: b18c3901744a84b3c1c820a8bc8af074cecdc78d56b7802186d9d6751c5b78ed
4
+ data.tar.gz: ef312bf22ddcdd7473d3c606d665e3eec5760a842822b0fb36dedf7ce840fa6b
5
5
  SHA512:
6
- metadata.gz: d63c0cf64b6c5163ed7c1f6cb0c927c325d18c21dbf286b5dce91578f4fa5b4a1e6119b41ac877be20812b475306b3f7ab444474e482ebe36c0735b90c7ae9b7
7
- data.tar.gz: 23cdf3242c78e993c3df565f1123eea67c5aca527218122e22a0ed1fcacfbf33adf3396aaebbdeb82666cbdf3e7ace44ecfd4a1c453e0fe8d38fc7d4064c7b89
6
+ metadata.gz: 543a74c57e08edde95103dff97af8c90360908e87e2d7be1c1c79a53dc85cb314f26b23b8591dabaeb88efb6415c2b3a5909ed8ca392a2dc0e3a61dabfb3b781
7
+ data.tar.gz: 87f5bb43a345cb9373d43211ffbea8e47c08de26a7256f0f2b51ff2660b6021bc251a448ba51006c34ca02c88d442d88c2d027d1b15638a7e2fb396c2336423f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,45 @@
1
+ # [v33.8.4](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.8.3...v33.8.4) (2021-08-20 15:45:41)
2
+
3
+ ## Global changes
4
+ ### Patches
5
+
6
+ * [[Fix(platform_handler_serverless_chef)] [#99] Make sure dynamic or unparsable cookbook/recipe names are considered using metadata for recipes dependencies](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/1d7feb24881f04cd3f31bc1e41712dfc4cfe715f)
7
+
8
+ ## Changes for platform_handler_serverless_chef
9
+ ### Patches
10
+
11
+ * [[Fix(platform_handler_serverless_chef)] [#99] Make sure dynamic or unparsable cookbook/recipe names are considered using metadata for recipes dependencies](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/1d7feb24881f04cd3f31bc1e41712dfc4cfe715f)
12
+
13
+ # [v33.8.3](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.8.2...v33.8.3) (2021-08-16 14:18:52)
14
+
15
+ ## Global changes
16
+ ### Patches
17
+
18
+ * [[Fix(platform_handler_serverless_chef)] [#97] Fix git_diff_impacts when a library file is removed](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/da60609dbd395b9a78c5df8089b39255db1fed9f)
19
+
20
+ ## Changes for platform_handler_serverless_chef
21
+ ### Patches
22
+
23
+ * [[Fix(platform_handler_serverless_chef)] [#97] Fix git_diff_impacts when a library file is removed](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/da60609dbd395b9a78c5df8089b39255db1fed9f)
24
+
25
+ # [v33.8.2](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.8.1...v33.8.2) (2021-08-14 21:12:19)
26
+
27
+ ## Global changes
28
+ ### Patches
29
+
30
+ * [[Fix(test_github_ci)] [#95] Make sure the github_ci test does not fail when a repository has no workflow run](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/e805c5b2d7e391c3c5205996fd56dadc14ddec7f)
31
+
32
+ ## Changes for test_github_ci
33
+ ### Patches
34
+
35
+ * [[Fix(test_github_ci)] [#95] Make sure the github_ci test does not fail when a repository has no workflow run](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/e805c5b2d7e391c3c5205996fd56dadc14ddec7f)
36
+
37
+ # [v33.8.1](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.8.0...v33.8.1) (2021-08-05 17:11:39)
38
+
39
+ ### Patches
40
+
41
+ * [[Hotfix] Added test checking that test keys are not deployed in production for security](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/f2e5bcc59b595592bf0a2b4f63c92966f10902ef)
42
+
1
43
  # [v33.8.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.7.4...v33.8.0) (2021-08-04 15:55:54)
2
44
 
3
45
  ## Global changes
@@ -138,22 +138,23 @@ module HybridPlatformsConductor
138
138
  value = Regexp.last_match(2)
139
139
  key = key_str.to_sym
140
140
  # Type-cast some values
141
- case key_str
142
- when 'date'
143
- # Date and time values
144
- # Thu Nov 23 18:43:01 UTC 2017
145
- deploy_info[key] = Time.parse("#{value} UTC")
146
- when 'debug'
147
- # Boolean values
148
- # Yes
149
- deploy_info[key] = (value == 'Yes')
150
- when /^diff_files_.+$/, 'services'
151
- # Array of strings
152
- # my_file.txt, other_file.txt
153
- deploy_info[key] = value.split(', ')
154
- else
155
- deploy_info[key] = value
156
- end
141
+ deploy_info[key] =
142
+ case key_str
143
+ when 'date'
144
+ # Date and time values
145
+ # Thu Nov 23 18:43:01 UTC 2017
146
+ Time.parse("#{value} UTC")
147
+ when 'debug'
148
+ # Boolean values
149
+ # Yes
150
+ value == 'Yes'
151
+ when /^diff_files_.+$/, 'services'
152
+ # Array of strings
153
+ # my_file.txt, other_file.txt
154
+ value.split(', ')
155
+ else
156
+ value
157
+ end
157
158
  else
158
159
  deploy_info[:unknown_lines] = [] unless deploy_info.key?(:unknown_lines)
159
160
  deploy_info[:unknown_lines] << line
@@ -428,14 +428,16 @@ module HybridPlatformsConductor
428
428
  end
429
429
  when %r{libraries/(.+)}
430
430
  # Find any recipe using methods from this library
431
- lib_methods_regexps = File.read("#{@repository_path}/#{impacted_file}").scan(/(\W|^)def\s+(\w+)(\W|$)/).map { |_grp_1, method_name, _grp_2| /(\W|^)#{Regexp.escape(method_name)}(\W|$)/ }
432
- known_cookbook_paths.each do |cookbooks_path|
433
- Dir.glob("#{@repository_path}/#{cookbooks_path}/**/recipes/*.rb") do |recipe_path|
434
- file_content = File.read(recipe_path)
435
- found_lib_regexp = lib_methods_regexps.find { |regexp| file_content =~ regexp }
436
- unless found_lib_regexp.nil?
437
- cookbook_name, recipe_name = recipe_path.match(%r{#{cookbooks_path}/(\w+)/recipes/(\w+)\.rb})[1..2]
438
- register.call("included library helper #{found_lib_regexp.source[6..-7]}", recipe_name, cookbook_name: cookbook_name)
431
+ if File.exist?("#{@repository_path}/#{impacted_file}")
432
+ lib_methods_regexps = File.read("#{@repository_path}/#{impacted_file}").scan(/(\W|^)def\s+(\w+)(\W|$)/).map { |_grp_1, method_name, _grp_2| /(\W|^)#{Regexp.escape(method_name)}(\W|$)/ }
433
+ known_cookbook_paths.each do |cookbooks_path|
434
+ Dir.glob("#{@repository_path}/#{cookbooks_path}/**/recipes/*.rb") do |recipe_path|
435
+ file_content = File.read(recipe_path)
436
+ found_lib_regexp = lib_methods_regexps.find { |regexp| file_content =~ regexp }
437
+ unless found_lib_regexp.nil?
438
+ cookbook_name, recipe_name = recipe_path.match(%r{#{cookbooks_path}/(\w+)/recipes/(\w+)\.rb})[1..2]
439
+ register.call("included library helper #{found_lib_regexp.source[6..-7]}", recipe_name, cookbook_name: cookbook_name)
440
+ end
439
441
  end
440
442
  end
441
443
  end
@@ -26,7 +26,7 @@ module HybridPlatformsConductor
26
26
  # Parameters::
27
27
  # * *source* (String): File to parse
28
28
  def parse(source)
29
- instance_eval(File.read(source))
29
+ instance_eval(File.read(source), source)
30
30
  end
31
31
 
32
32
  # Intercept all missing methods
@@ -105,8 +105,59 @@ module HybridPlatformsConductor
105
105
  recipe_content = File.read("#{@platform.repository_path}/#{cookbook_dir}/#{cookbook}/recipes/#{recipe}.rb")
106
106
  # Check for include_recipe
107
107
  used_recipes = recipe_content.
108
- scan(/include_recipe\s+["'](\w+(::\w+)?)["']/).
109
- map { |(recipe_def, _sub_grp)| @platform.decode_recipe(recipe_def) }
108
+ scan(/include_recipe(\((.+)\)|\s+(.+)|\((.*))$/).
109
+ map do |(_match, match_1, match_2, match_3)|
110
+ case match_1 || match_2 || match_3
111
+ when /^["']([^:'"]+(::[^'"]+)?)["']$/
112
+ # The recipe definition is given in a String
113
+ used_cookbook, used_recipe = Regexp.last_match(1).split('::')
114
+ used_recipe = 'default' if used_recipe.nil?
115
+ if used_cookbook =~ /^\w+$/
116
+ # Find the cookbook it belongs to
117
+ used_cookbook_dir = @platform.known_cookbook_paths.find { |cookbook_path| File.exist?("#{@platform.repository_path}/#{cookbook_path}/#{used_cookbook}") }
118
+ if used_recipe =~ /^\w+$/
119
+ # Check that the recipe exists if we know the cookbook dir
120
+ raise "Unknown recipe #{used_cookbook}::#{used_recipe} from cookbook #{@platform.repository_path}/#{used_cookbook_dir}/#{used_cookbook}." if !used_cookbook_dir.nil? && !File.exist?("#{@platform.repository_path}/#{used_cookbook_dir}/#{used_cookbook}/recipes/#{used_recipe}.rb")
121
+
122
+ [
123
+ [used_cookbook_dir, used_cookbook.to_sym, used_recipe.to_sym]
124
+ ]
125
+ elsif used_cookbook_dir
126
+ # We are dealing with a dynamically named recipe.
127
+ # Return all recipes of the cookbook if we know the cookbook dir
128
+ Dir.glob("#{@platform.repository_path}/#{used_cookbook_dir}/#{used_cookbook}/recipes/*.rb").map do |used_recipe_file_path|
129
+ [
130
+ used_cookbook_dir,
131
+ used_cookbook.to_sym,
132
+ File.basename(used_recipe_file_path, '.rb').to_sym
133
+ ]
134
+ end
135
+ else
136
+ # We are dealing with a dynamically named recipe.
137
+ # We have no cookbook dir - certainly comes from the supermarket.
138
+ []
139
+ end
140
+ elsif used_recipe =~ /^\w+$/
141
+ # We are dealing with a dynamically named cookbook, but the recipe name is known.
142
+ # Look for this recipe in all cookbooks that are part of the metadata.
143
+ dependent_cookbooks(cookbook_dir, cookbook).map do |dependent_cookbook|
144
+ dependent_cookbook_dir = @platform.known_cookbook_paths.find { |cookbook_path| File.exist?("#{@platform.repository_path}/#{cookbook_path}/#{dependent_cookbook}") }
145
+ if !dependent_cookbook_dir.nil? && File.exist?("#{@platform.repository_path}/#{dependent_cookbook_dir}/#{dependent_cookbook}/recipes/#{used_recipe}.rb")
146
+ # Found a matching recipe name
147
+ [dependent_cookbook_dir, dependent_cookbook, used_recipe.to_sym]
148
+ end
149
+ end.compact
150
+ else
151
+ # We are dealing with cynamically named cookbooks and recipes.
152
+ # Consider we depend on all recipes of our dependent cookbooks.
153
+ all_dependent_recipes(cookbook_dir, cookbook)
154
+ end
155
+ else
156
+ # The recipe definition is much more complex, so treat it as unparsable and consider we depnd on all recipes of our dependent cookbooks from metadata.
157
+ all_dependent_recipes(cookbook_dir, cookbook)
158
+ end
159
+ end.
160
+ flatten(1)
110
161
  # Check for some helpers we know include some recipes
111
162
  @config.known_helpers_including_recipes.each do |helper_name, used_recipes_by_helper|
112
163
  if recipe_content =~ Regexp.new(/(\W|^)#{Regexp.escape(helper_name)}(\W|$)/)
@@ -222,6 +273,47 @@ module HybridPlatformsConductor
222
273
  end
223
274
  end
224
275
 
276
+ # Get the list of dependent cookbooks from a cookbook's metadata
277
+ #
278
+ # Parameters::
279
+ # * *cookbook_dir* (String): The cookbook directory
280
+ # * *cookbook* (Symbol): The cookbook name
281
+ # Result::
282
+ # * Array<Symbol>: List of dependent cookbooks
283
+ def dependent_cookbooks(cookbook_dir, cookbook)
284
+ # Read the metadata file
285
+ dsl_parser = DslParser.new
286
+ dsl_parser.parse("#{@platform.repository_path}/#{cookbook_dir}/#{cookbook}/metadata.rb")
287
+ dsl_parser.
288
+ calls.
289
+ map { |call_info| call_info[:method] == :depends ? call_info[:args].first.to_sym : nil }.
290
+ compact
291
+ end
292
+
293
+ # Get all recipes from all cookbooks that are a metadata dependency from a given cookbook.
294
+ #
295
+ # Parameters::
296
+ # * *cookbook_dir* (String): The cookbook directory
297
+ # * *cookbook* (Symbol): The cookbook name
298
+ # Result::
299
+ # * Array< [String, Symbol, Symbol] >: List of tuples [cookbook_dir, cookbook, recipe] used by this recipe
300
+ def all_dependent_recipes(cookbook_dir, cookbook)
301
+ dependent_cookbooks(cookbook_dir, cookbook).map do |dependent_cookbook|
302
+ dependent_cookbook_dir = @platform.known_cookbook_paths.find { |cookbook_path| File.exist?("#{@platform.repository_path}/#{cookbook_path}/#{dependent_cookbook}") }
303
+ if dependent_cookbook_dir.nil?
304
+ nil
305
+ else
306
+ Dir.glob("#{@platform.repository_path}/#{dependent_cookbook_dir}/#{dependent_cookbook}/recipes/*.rb").map do |used_recipe_file_path|
307
+ [
308
+ dependent_cookbook_dir,
309
+ dependent_cookbook,
310
+ File.basename(used_recipe_file_path, '.rb').to_sym
311
+ ]
312
+ end
313
+ end
314
+ end.compact.flatten(1)
315
+ end
316
+
225
317
  end
226
318
 
227
319
  end
@@ -18,10 +18,15 @@ module HybridPlatformsConductor
18
18
  def test
19
19
  for_each_github_repo do |client, repo_info|
20
20
  log_debug "Checking CI for Github repository #{repo_info[:slug]}"
21
- last_status = client.repository_workflow_runs(repo_info[:slug])[:workflow_runs].
21
+ last_run = client.repository_workflow_runs(repo_info[:slug])[:workflow_runs].
22
22
  select { |run| run[:head_branch] == 'master' }.
23
- max_by { |run| run[:created_at] }[:conclusion]
24
- error "Last workflow status for repository #{repo_info[:slug]} is #{last_status}" unless last_status == 'success'
23
+ max_by { |run| run[:created_at] }
24
+ if last_run.nil?
25
+ error "No workflow run found for repository #{repo_info[:slug]}"
26
+ else
27
+ last_status = last_run[:conclusion]
28
+ error "Last workflow status for repository #{repo_info[:slug]} is #{last_status}" unless last_status == 'success'
29
+ end
25
30
  end
26
31
  end
27
32
 
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '33.8.0'
3
+ VERSION = '33.8.4'
4
4
 
5
5
  end
@@ -158,6 +158,16 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
158
158
  end
159
159
  end
160
160
 
161
+ it 'returns no impacted service due to a library helper being removed' do
162
+ with_serverless_chef_platforms('recipes') do |platform|
163
+ expect(platform.impacts_from('cookbooks/test_cookbook_2/libraries/removed.rb' => {})).to eq [
164
+ [],
165
+ [],
166
+ false
167
+ ]
168
+ end
169
+ end
170
+
161
171
  it 'ignored impacted service from an unknown helper' do
162
172
  with_serverless_chef_platforms('recipes') do |platform, repository|
163
173
  File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EO_RECIPE)
@@ -225,6 +235,59 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
225
235
  end
226
236
  end
227
237
 
238
+ it 'returns impacted service due to a usage of another cookbook\'s recipe using parenthesis' do
239
+ with_serverless_chef_platforms('recipes') do |platform, repository|
240
+ File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EO_RECIPE)
241
+ include_recipe('test_cookbook_2::other_recipe')
242
+ EO_RECIPE
243
+ expect(platform.impacts_from('cookbooks/test_cookbook_2/recipes/other_recipe.rb' => {})).to eq [
244
+ [],
245
+ %w[test_policy_1],
246
+ false
247
+ ]
248
+ end
249
+ end
250
+
251
+ it 'returns impacted service due to a usage of another cookbook\'s recipe using dynamic recipe name' do
252
+ with_serverless_chef_platforms('recipes') do |platform|
253
+ expect(platform.impacts_from('cookbooks/test_cookbook_4/recipes/recipe_1.rb' => {})).to eq [
254
+ [],
255
+ %w[test_policy_31 test_policy_33 test_policy_35],
256
+ false
257
+ ]
258
+ end
259
+ end
260
+
261
+ it 'returns impacted service due to a usage of another cookbook\'s recipe using dynamic cookbook name' do
262
+ with_serverless_chef_platforms('recipes') do |platform|
263
+ expect(platform.impacts_from('cookbooks/test_cookbook_4/recipes/recipe_2.rb' => {})).to eq [
264
+ [],
265
+ %w[test_policy_31 test_policy_32 test_policy_33 test_policy_35],
266
+ false
267
+ ]
268
+ end
269
+ end
270
+
271
+ it 'returns impacted service due to a usage of another cookbook\'s recipe using dynamic cookbook and recipe names' do
272
+ with_serverless_chef_platforms('recipes') do |platform|
273
+ expect(platform.impacts_from('cookbooks/test_cookbook_4/recipes/recipe_3.rb' => {})).to eq [
274
+ [],
275
+ %w[test_policy_31 test_policy_33 test_policy_35],
276
+ false
277
+ ]
278
+ end
279
+ end
280
+
281
+ it 'returns impacted service due to a usage of another cookbook\'s recipe using dynamic or unparsable cookbook and recipe names, using metadata' do
282
+ with_serverless_chef_platforms('recipes') do |platform|
283
+ expect(platform.impacts_from('cookbooks/test_cookbook_5/recipes/recipe_1.rb' => {})).to eq [
284
+ [],
285
+ %w[test_policy_33 test_policy_35],
286
+ false
287
+ ]
288
+ end
289
+ end
290
+
228
291
  it 'ignores cookbooks from cookbook paths that are not configured' do
229
292
  with_serverless_chef_platforms('several_cookbooks') do |platform, repository|
230
293
  File.write("#{repository}/cookbooks/test_cookbook_1/recipes/default.rb", <<~EO_RECIPE)
@@ -330,7 +330,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
330
330
  end
331
331
  end
332
332
 
333
- it 'packages the repository with a testadmin public key' do
333
+ it 'packages the repository with a testadmin public key in local mode' do
334
334
  with_serverless_chef_platforms('hpc_test') do |platform, repository|
335
335
  File.write("#{ENV['hpc_platforms']}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
336
336
  with_packaging_mocked(
@@ -349,6 +349,21 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
349
349
  end
350
350
  end
351
351
 
352
+ it 'does not package the repository with a testadmin public key in prod mode' do
353
+ with_serverless_chef_platforms('hpc_test') do |platform, repository|
354
+ File.write("#{ENV['hpc_platforms']}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
355
+ with_packaging_mocked(
356
+ repository,
357
+ cookbook_metadata: {
358
+ 'hpc_test-1234' => {}
359
+ }
360
+ ) do
361
+ platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: false)
362
+ expect(Dir.glob("#{repository}/dist/prod/test_policy/cookbook_artifacts/hpc_test-*/files/default/testadmin.key.pub")).to eq []
363
+ end
364
+ end
365
+ end
366
+
352
367
  end
353
368
 
354
369
  end
@@ -0,0 +1,13 @@
1
+ name 'test_cookbook_3'
2
+ maintainer 'Muriel Salvan'
3
+ maintainer_email 'muriel@x-aeon.com'
4
+ supports 'debian'
5
+ chef_version '>= 14.8'
6
+ source_url 'https://x-aeon.com'
7
+ issues_url 'https://x-aeon.com'
8
+ license 'BSD'
9
+ description 'Installs/Configures test_cookbook_3'
10
+ long_description ''
11
+ version '0.1.0'
12
+ depends 'test_cookbook_4'
13
+ depends 'test_cookbook_5'
@@ -0,0 +1,2 @@
1
+ recipe_name = 'recipe_1'
2
+ include_recipe "test_cookbook_4::#{recipe_name}"
@@ -0,0 +1,2 @@
1
+ cookbook_name = 'test_cookbook_4'
2
+ include_recipe "#{cookbook_name}::recipe_2"
@@ -0,0 +1,3 @@
1
+ cookbook_name = 'test_cookbook_4'
2
+ recipe_name = 'recipe_3'
3
+ include_recipe "#{cookbook_name}::#{recipe_name}"
@@ -0,0 +1,7 @@
1
+ cookbook_name = ENV['cookbook_name']
2
+ recipe_name = ENV['recipe_name']
3
+ # rubocop:disable Style/StringConcatenation
4
+ include_recipe(
5
+ cookbook_name + '::' + recipe_name
6
+ )
7
+ # rubocop:enable Style/StringConcatenation
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "node31",
3
+ "normal": {
4
+ "description": "Node 31",
5
+ "image": "debian_9",
6
+ "private_ips": ["172.16.0.31"]
7
+ },
8
+ "policy_name": "test_policy_31",
9
+ "policy_group": "test_group"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "node32",
3
+ "normal": {
4
+ "description": "Node 32",
5
+ "image": "debian_9",
6
+ "private_ips": ["172.16.0.32"]
7
+ },
8
+ "policy_name": "test_policy_32",
9
+ "policy_group": "test_group"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "node33",
3
+ "normal": {
4
+ "description": "Node 33",
5
+ "image": "debian_9",
6
+ "private_ips": ["172.16.0.33"]
7
+ },
8
+ "policy_name": "test_policy_33",
9
+ "policy_group": "test_group"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "node34",
3
+ "normal": {
4
+ "description": "Node 34",
5
+ "image": "debian_9",
6
+ "private_ips": ["172.16.0.34"]
7
+ },
8
+ "policy_name": "test_policy_34",
9
+ "policy_group": "test_group"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "node35",
3
+ "normal": {
4
+ "description": "Node 35",
5
+ "image": "debian_9",
6
+ "private_ips": ["172.16.0.35"]
7
+ },
8
+ "policy_name": "test_policy_35",
9
+ "policy_group": "test_group"
10
+ }
@@ -0,0 +1,4 @@
1
+ name File.basename(__FILE__, '.rb')
2
+ default_source :supermarket
3
+ default_source :chef_repo, '..'
4
+ run_list 'recipe[test_cookbook_3::31_unknown_recipe_include]'
@@ -0,0 +1,4 @@
1
+ name File.basename(__FILE__, '.rb')
2
+ default_source :supermarket
3
+ default_source :chef_repo, '..'
4
+ run_list 'recipe[test_cookbook_3::32_unknown_cookbook_include]'
@@ -0,0 +1,4 @@
1
+ name File.basename(__FILE__, '.rb')
2
+ default_source :supermarket
3
+ default_source :chef_repo, '..'
4
+ run_list 'recipe[test_cookbook_3::33_unknown_include]'
@@ -0,0 +1,4 @@
1
+ name File.basename(__FILE__, '.rb')
2
+ default_source :supermarket
3
+ default_source :chef_repo, '..'
4
+ run_list 'recipe[test_cookbook_3::34_known_include]'
@@ -0,0 +1,4 @@
1
+ name File.basename(__FILE__, '.rb')
2
+ default_source :supermarket
3
+ default_source :chef_repo, '..'
4
+ run_list 'recipe[test_cookbook_3::35_unparsable_include]'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybrid_platforms_conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 33.8.0
4
+ version: 33.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-04 00:00:00.000000000 Z
11
+ date: 2021-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: range_operators
@@ -1003,10 +1003,32 @@ files:
1003
1003
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/recipes/default.rb
1004
1004
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/recipes/other_recipe.rb
1005
1005
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/resources/my_resource.rb
1006
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/metadata.rb
1007
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/31_unknown_recipe_include.rb
1008
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/32_unknown_cookbook_include.rb
1009
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/33_unknown_include.rb
1010
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/34_known_include.rb
1011
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/35_unparsable_include.rb
1012
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_1.rb
1013
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_2.rb
1014
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_3.rb
1015
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_4/recipes/recipe_4.rb
1016
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_5/recipes/recipe_1.rb
1017
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_5/recipes/recipe_2.rb
1006
1018
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node1.json
1007
1019
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node2.json
1020
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node31.json
1021
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node32.json
1022
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node33.json
1023
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node34.json
1024
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node35.json
1008
1025
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_1.rb
1009
1026
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_2.rb
1027
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_31.rb
1028
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_32.rb
1029
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_33.rb
1030
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_34.rb
1031
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_35.rb
1010
1032
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/config.rb
1011
1033
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/cookbooks/test_cookbook_1/recipes/default.rb
1012
1034
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/nodes/node1.json