hybrid_platforms_conductor 33.7.4 → 33.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8966575d336257c3b6aa9371ac750a69dcdff5e1817a84847cf9895348bddf4
4
- data.tar.gz: 065a1a3ff659e3d0a7c129884208a8299d378df383c57d67c0a6f2447464cefa
3
+ metadata.gz: 80a9228f00ac63d2ddf325f1fd4faeab83af8d7bbf73c43ff46d4632883462a4
4
+ data.tar.gz: 225b174fb0107a743e4daeda8a65148b8ce7d0ea81fb0862066a3626e60b7571
5
5
  SHA512:
6
- metadata.gz: 6f838436afdc89e284a0c6071b6fd06ef754361b615be00a8489f9d8991cdbb35546c19823035e677cfaaeff8cb3aac347cc005932dc3515a4578fdfccc7989d
7
- data.tar.gz: 1b544cf67be8b647cd07e8a37a59f448cde59f36a6711353b3b6c6b1264f4d5ec5bd6db0b77b409166e5062b4ffb613cf3ef54067c8c051513f3b7995c2c05aa
6
+ metadata.gz: cc3c6a8c0a245a1929481f2e5482fdc3b9100dc24dab7a98bfbc026a294a8ef88b359060608cafb5c9937197ad89fc39630e3b56265888f5c913be9435960a3b
7
+ data.tar.gz: c82665286ed8c6783b02640e4122eb08d555c0d04fecbc49a688194caf828144f63f243824e28be8a120f41a331cd5194497b9ede07630d9347e8888383187b9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,45 @@
1
+ # [v33.8.3](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.8.2...v33.8.3) (2021-08-16 14:18:52)
2
+
3
+ ## Global changes
4
+ ### Patches
5
+
6
+ * [[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)
7
+
8
+ ## Changes for platform_handler_serverless_chef
9
+ ### Patches
10
+
11
+ * [[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)
12
+
13
+ # [v33.8.2](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.8.1...v33.8.2) (2021-08-14 21:12:19)
14
+
15
+ ## Global changes
16
+ ### Patches
17
+
18
+ * [[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)
19
+
20
+ ## Changes for test_github_ci
21
+ ### Patches
22
+
23
+ * [[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)
24
+
25
+ # [v33.8.1](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.8.0...v33.8.1) (2021-08-05 17:11:39)
26
+
27
+ ### Patches
28
+
29
+ * [[Hotfix] Added test checking that test keys are not deployed in production for security](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/f2e5bcc59b595592bf0a2b4f63c92966f10902ef)
30
+
31
+ # [v33.8.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.7.4...v33.8.0) (2021-08-04 15:55:54)
32
+
33
+ ## Global changes
34
+ ### Patches
35
+
36
+ * [[Feature(platform_handler_serverless_chef)] Integrate testadmin public key while deploying in local mode](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/6083463bf3bc760c393b786515db59af89315333)
37
+
38
+ ## Changes for platform_handler_serverless_chef
39
+ ### Features
40
+
41
+ * [[Feature(platform_handler_serverless_chef)] Integrate testadmin public key while deploying in local mode](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/6083463bf3bc760c393b786515db59af89315333)
42
+
1
43
  # [v33.7.4](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.7.3...v33.7.4) (2021-08-04 14:21:08)
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
@@ -190,6 +190,15 @@ module HybridPlatformsConductor
190
190
  secrets_file = "#{@repository_path}/#{package_dir}/data_bags/hpc_secrets/hpc_secrets.json"
191
191
  FileUtils.mkdir_p(File.dirname(secrets_file))
192
192
  File.write(secrets_file, secrets.merge(id: 'hpc_secrets').to_json)
193
+ # Make the testadmin public key available for deployment for hpc_test cookbook
194
+ testadmin_pub_key = "#{@config.hybrid_platforms_dir}/testadmin.key.pub"
195
+ if local_environment && File.exist?(testadmin_pub_key)
196
+ Dir.glob("#{@repository_path}/#{package_dir}/cookbook_artifacts/hpc_test-*") do |hpc_test_cookbook_path|
197
+ hpc_test_files_dir = "#{hpc_test_cookbook_path}/files/default"
198
+ FileUtils.mkdir_p hpc_test_files_dir
199
+ FileUtils.cp(testadmin_pub_key, "#{hpc_test_files_dir}/testadmin.key.pub")
200
+ end
201
+ end
193
202
  # Remember the package info
194
203
  File.write(package_info_file, package_info.to_json)
195
204
  end
@@ -419,14 +428,16 @@ module HybridPlatformsConductor
419
428
  end
420
429
  when %r{libraries/(.+)}
421
430
  # Find any recipe using methods from this library
422
- 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|$)/ }
423
- known_cookbook_paths.each do |cookbooks_path|
424
- Dir.glob("#{@repository_path}/#{cookbooks_path}/**/recipes/*.rb") do |recipe_path|
425
- file_content = File.read(recipe_path)
426
- found_lib_regexp = lib_methods_regexps.find { |regexp| file_content =~ regexp }
427
- unless found_lib_regexp.nil?
428
- cookbook_name, recipe_name = recipe_path.match(%r{#{cookbooks_path}/(\w+)/recipes/(\w+)\.rb})[1..2]
429
- 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
430
441
  end
431
442
  end
432
443
  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.7.4'
3
+ VERSION = '33.8.3'
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)
@@ -51,6 +51,7 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
51
51
  [
52
52
  %r{^cd #{Regexp.escape(repository)} &&\s+sudo rm -rf dist/#{Regexp.escape(env)}/#{Regexp.escape(policy)} &&\s+/opt/chef-workstation/bin/chef export #{Regexp.escape(policy_file)} dist/#{Regexp.escape(env)}/#{Regexp.escape(policy)} --chef-license accept#{data_bags ? " && cp -ar data_bags/ dist/#{Regexp.escape(env)}/#{Regexp.escape(policy)}/" : ''}$},
53
53
  proc do
54
+ # Mock the packaging in the dist directory
54
55
  package_dir = "#{repository}/dist/#{env}/#{policy}"
55
56
  FileUtils.mkdir_p package_dir
56
57
  FileUtils.cp_r("#{repository}/data_bags", "#{package_dir}/") if data_bags
@@ -329,6 +330,40 @@ describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef d
329
330
  end
330
331
  end
331
332
 
333
+ it 'packages the repository with a testadmin public key in local mode' do
334
+ with_serverless_chef_platforms('hpc_test') do |platform, repository|
335
+ File.write("#{ENV['hpc_platforms']}/testadmin.key.pub", 'ssh-rsa 12345 testadmin@test.com')
336
+ with_packaging_mocked(
337
+ repository,
338
+ policy_file: 'policyfiles/test_policy.local.rb',
339
+ env: 'local',
340
+ cookbook_metadata: {
341
+ 'hpc_test-1234' => {}
342
+ }
343
+ ) do
344
+ platform.package(services: { 'node' => %w[test_policy] }, secrets: {}, local_environment: true)
345
+ testadmin_key_pub = Dir.glob("#{repository}/dist/local/test_policy/cookbook_artifacts/hpc_test-*/files/default/testadmin.key.pub").first
346
+ expect(testadmin_key_pub).not_to eq nil
347
+ expect(File.read(testadmin_key_pub)).to eq 'ssh-rsa 12345 testadmin@test.com'
348
+ end
349
+ end
350
+ end
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
+
332
367
  end
333
368
 
334
369
  end
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.7.4
4
+ version: 33.8.3
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-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: range_operators