hybrid_platforms_conductor 33.9.4 → 34.0.0

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +3 -1
  4. data/bin/free_veids +1 -1
  5. data/bin/last_deploys +1 -1
  6. data/bin/nodes_to_deploy +3 -3
  7. data/docs/gen/mermaid/README.md-0.png +0 -0
  8. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  9. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  10. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  11. data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
  12. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  13. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  14. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  15. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  16. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  17. data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
  18. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  19. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  20. data/lib/hybrid_platforms_conductor/core_extensions/bundler/without_bundled_env.rb +1 -1
  21. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +1 -0
  22. data/lib/hybrid_platforms_conductor/credentials.rb +1 -1
  23. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +3 -3
  24. data/lib/hybrid_platforms_conductor/deployer.rb +1 -1
  25. data/lib/hybrid_platforms_conductor/executable.rb +1 -1
  26. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +2 -0
  27. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -0
  28. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +9 -7
  29. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +2 -1
  30. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +1 -1
  31. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +1 -0
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +2 -2
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +1 -0
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +1 -0
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +3 -2
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +5 -5
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +5 -5
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +1 -1
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +1 -0
  40. data/lib/hybrid_platforms_conductor/json_dumper.rb +1 -1
  41. data/lib/hybrid_platforms_conductor/logger_helpers.rb +6 -6
  42. data/lib/hybrid_platforms_conductor/nodes_handler.rb +4 -6
  43. data/lib/hybrid_platforms_conductor/parallel_threads.rb +1 -1
  44. data/lib/hybrid_platforms_conductor/platform_handler.rb +1 -1
  45. data/lib/hybrid_platforms_conductor/platforms_handler.rb +1 -1
  46. data/lib/hybrid_platforms_conductor/services_handler.rb +6 -6
  47. data/lib/hybrid_platforms_conductor/test_report.rb +4 -4
  48. data/lib/hybrid_platforms_conductor/tests_runner.rb +3 -0
  49. data/lib/hybrid_platforms_conductor/thycotic.rb +2 -2
  50. data/lib/hybrid_platforms_conductor/topographer.rb +2 -2
  51. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  52. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +3 -10
  53. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +1 -6
  54. data/spec/hybrid_platforms_conductor_test/api/credentials_spec.rb +13 -13
  55. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile +1 -1
  56. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +3 -3
  57. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +1 -1
  58. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +1 -1
  59. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +3 -3
  60. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +1 -1
  61. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +2 -2
  62. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +2 -2
  63. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +3 -3
  64. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +1 -3
  65. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +9 -9
  66. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +5 -5
  67. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +2 -2
  68. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +1 -1
  69. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/linear_strategy_spec.rb +69 -0
  70. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +1 -1
  71. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +4 -6
  72. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +3 -3
  73. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +1 -1
  74. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +4 -4
  75. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/35_unparsable_include.rb +2 -2
  76. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +1 -1
  77. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +1 -1
  78. data/spec/hybrid_platforms_conductor_test.rb +3 -2
  79. metadata +171 -244
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 433e01481e26d03667cde79b93697f0f14e949a6201931c6e570ebb84670e79a
4
- data.tar.gz: 61c1eb5c9b9ec3df221528e8ae1c08a7a6bdf3628c2a6a83b1756e11a84a2e88
3
+ metadata.gz: 4105038cdad3d70849816004ec2d909053e0e792900fc03e514d7b1ddc95d9c4
4
+ data.tar.gz: 5bda67856370632895782f6271c4044c50c22b0f340d8fc36ec6e11d8ca8fd8f
5
5
  SHA512:
6
- metadata.gz: 31ff562ab7108537b8ba57b8c657ef516ef5665fb40fc81d4afe4f14a54400f62324597136845af8c39bd8788318d3d12c54362562cb73dff9d769c60cf8bce1
7
- data.tar.gz: cb7dfea944204a89f9522703fb588ec8085dcd9a92816abe0cc012f0e7440432ee4a3831825517ae9b74f59e1ac1ff7d4995b6fa75220c28096de1a8e95f31b6
6
+ metadata.gz: e5a2dee126aecde247f6143f0d047e23280778755cb01cfb8c94d3f74bb128259bdba6044b25213a3e06f91e25fce53d71a31d6afa9dd95b01b797a4906e6745
7
+ data.tar.gz: f170805ef694bed86c8c673a3947b6c68755a27fba4ba79abebdf210dbf0ee39acb598466960f0eb3b387bb352dcc2b07094cca2e1f0d63b182eaa212d081926
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ # [v34.0.0](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.9.5...v34.0.0) (2025-04-25 22:44:39)
2
+
3
+ ### Patches
4
+
5
+ * [Fix NPM packages installation in Github workflows](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/5d18119b49ad7d0975d2c003139a394b9dd1116b)
6
+
7
+ ### Breaking changes
8
+
9
+ * [Migrate to Ruby 3](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/6e1b93a37b68b01b3144fe03ccc280e1275dd493)
10
+
11
+ # [v33.9.5](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.9.4...v33.9.5) (2022-03-20 17:46:29)
12
+
13
+ ### Patches
14
+
15
+ * [[#118] Fix linear strategy checks when merge commits are found](https://github.com/sweet-delights/hybrid-platforms-conductor/commit/01464ae5bb5c39e95be6216fceed0e9ac00ae83e)
16
+
1
17
  # [v33.9.4](https://github.com/sweet-delights/hybrid-platforms-conductor/compare/v33.9.3...v33.9.4) (2022-03-20 16:20:04)
2
18
 
3
19
  ### Patches
data/README.md CHANGED
@@ -96,7 +96,7 @@ Here are the various plugin categories:
96
96
  # Installation
97
97
 
98
98
  Installing Hybrid Platforms Conductor requires 2 steps:
99
- 1. Have **Ruby >= 2.5 and < 3.0** installed.
99
+ 1. Have **Ruby >= 3.0** installed.
100
100
  2. Install the `hybrid_platforms_conductor` Rubygem.
101
101
 
102
102
  See [installation details](docs/install.md) for more details on how to install those.
@@ -429,6 +429,8 @@ A subset of tests (or even a single test) can be run by using a part of their na
429
429
 
430
430
  To enable debugging logs during tests run, set the environment variable `TEST_DEBUG` to `1`: `TEST_DEBUG=1 bundle exec rspec -e "HybridPlatformsConductor::Deployer checking the docker images provisioning"`
431
431
 
432
+ Some tests depend on Docker and sshpass which should be installed separately if those tests are required to pass.
433
+
432
434
  ## License
433
435
 
434
436
  BSD license (details in the [LICENSE.md file](LICENSE.md)).
data/bin/free_veids CHANGED
@@ -11,7 +11,7 @@ executable.parse_options!
11
11
  nodes_handler.prefetch_metadata_of nodes_handler.known_nodes, :veid
12
12
  veids = nodes_handler.
13
13
  known_nodes.
14
- map { |node| nodes_handler.get_veid_of(node) ? nodes_handler.get_veid_of(node).to_i : nil }.
14
+ map { |node| nodes_handler.get_veid_of(node)&.to_i }.
15
15
  compact
16
16
 
17
17
  executable.out "Free VEIDs: #{([10_000] + veids).missing.rangify}"
data/bin/last_deploys CHANGED
@@ -53,7 +53,7 @@ info_displayed = {
53
53
  error: 'Error'
54
54
  }
55
55
  executable.out(Terminal::Table.new(headings: info_displayed.values) do |table|
56
- sorted_deploy_info.each do |_node, deploy_info|
56
+ sorted_deploy_info.each do |(_node, deploy_info)|
57
57
  table << info_displayed.keys.map { |key| deploy_info[key] }
58
58
  end
59
59
  end)
data/bin/nodes_to_deploy CHANGED
@@ -68,9 +68,9 @@ unless ignore_deploy_info
68
68
  node_impacted = false
69
69
  # Loop over all possible repositories concerned by this deployment
70
70
  repo_idx = 0
71
- while node_deploy_info[:deployment_info].key?("repo_name_#{repo_idx}".to_sym)
72
- repo_name = node_deploy_info[:deployment_info]["repo_name_#{repo_idx}".to_sym]
73
- commit_id = node_deploy_info[:deployment_info]["commit_id_#{repo_idx}".to_sym]
71
+ while node_deploy_info[:deployment_info].key?(:"repo_name_#{repo_idx}")
72
+ repo_name = node_deploy_info[:deployment_info][:"repo_name_#{repo_idx}"]
73
+ commit_id = node_deploy_info[:deployment_info][:"commit_id_#{repo_idx}"]
74
74
  impacted_nodes = cache_impacted_nodes.dig(repo_name, commit_id)
75
75
  if impacted_nodes.nil?
76
76
  if platforms_handler.platform(repo_name)
Binary file
@@ -10,7 +10,7 @@ module Bundler
10
10
 
11
11
  # @return [Hash] Environment with all bundler-related variables removed
12
12
  def current_unbundled_env
13
- env = ENV.clone.to_hash
13
+ env = ENV.to_h
14
14
  %w[
15
15
  PATH
16
16
  RUBYLIB
@@ -46,6 +46,7 @@ module Cleanroom
46
46
  # []
47
47
  # {:string=>"With to_hash"}
48
48
  KWARGS_TYPES = %i[key keyreq]
49
+ private_constant :KWARGS_TYPES
49
50
 
50
51
  #
51
52
  # The list of exposed methods with kwargs.
@@ -82,7 +82,7 @@ module HybridPlatformsConductor
82
82
 
83
83
  provider ||= proc do |requested_resource, requester|
84
84
  # Check environment variables
85
- user = ENV["hpc_user_for_#{id}"]
85
+ user = ENV.fetch("hpc_user_for_#{id}", nil)
86
86
  # Clone the password as we are going to treat it as a secret string that will be wiped out
87
87
  password = ENV["hpc_password_for_#{id}"].dup
88
88
  if user.nil? || user.empty? || password.nil? || password.empty?
@@ -21,13 +21,13 @@ module HybridPlatformsConductor
21
21
  # * *module_to_decorate* (Module): The module including the method to decorate
22
22
  # * *method_name* (Symbol): The method name to be decorated
23
23
  def self.decorate_method(module_to_decorate, method_name)
24
- original_method_name = "__hpc__#{method_name}__undecorated__".to_sym
24
+ original_method_name = :"__hpc__#{method_name}__undecorated__"
25
25
  module_to_decorate.alias_method original_method_name, method_name
26
- module_to_decorate.define_method(method_name) do |*args, &block|
26
+ module_to_decorate.define_method(method_name) do |*args, **kwargs, &block|
27
27
  result = nil
28
28
  CurrentDirMonitor.monitor.synchronize do
29
29
  # puts "TID #{Thread.current.object_id} from #{caller[2]} - Current dir monitor taken from #{Dir.pwd}"
30
- result = send(original_method_name, *args, &block)
30
+ result = send(original_method_name, *args, **kwargs, &block)
31
31
  # puts "TID #{Thread.current.object_id} from #{caller[2]} - Current dir monitor released back to #{Dir.pwd}"
32
32
  end
33
33
  result
@@ -288,7 +288,7 @@ module HybridPlatformsConductor
288
288
 
289
289
  # Check that we are allowed to deploy
290
290
  unless @use_why_run
291
- reason_for_interdiction = @services_handler.deploy_allowed?(
291
+ reason_for_interdiction = @services_handler.barrier_to_deploy(
292
292
  services: services_to_deploy,
293
293
  local_environment: @local_environment
294
294
  )
@@ -86,7 +86,7 @@ module HybridPlatformsConductor
86
86
  #
87
87
  # Result::
88
88
  # * Boolean: Has a singleton been instantiated for this component?
89
- define_method("#{component}_instantiated?".to_sym) do
89
+ define_method(:"#{component}_instantiated?") do
90
90
  @instantiated_components.key?(component)
91
91
  end
92
92
 
@@ -64,6 +64,8 @@ module HybridPlatformsConductor
64
64
  # Number of threads max to use for getent calls
65
65
  MAX_THREADS_GETENT = 32
66
66
 
67
+ private_constant :TIMEOUT_GETENT, :MAX_THREADS_GETENT
68
+
67
69
  # Discover the real IPs associated to a list of hosts.
68
70
  #
69
71
  # Parameters::
@@ -69,6 +69,8 @@ module HybridPlatformsConductor
69
69
  # Number of threads max to use for ssh-keyscan calls
70
70
  MAX_THREADS_SSH_KEY_SCAN = 32
71
71
 
72
+ private_constant :TIMEOUT_SSH_KEYSCAN, :MAX_THREADS_SSH_KEY_SCAN
73
+
72
74
  # Discover the host keys associated to a list of hosts.
73
75
  #
74
76
  # Parameters::
@@ -85,7 +85,7 @@ module HybridPlatformsConductor
85
85
  binding
86
86
  end
87
87
  variables.each do |var_name, var_value|
88
- erb_context.instance_variable_set("@#{var_name}".to_sym, var_value)
88
+ erb_context.instance_variable_set(:"@#{var_name}", var_value)
89
89
  end
90
90
  ERB.new(@gateways[gateway_conf]).result(erb_context.private_binding)
91
91
  end
@@ -131,8 +131,8 @@ module HybridPlatformsConductor
131
131
  # [API] - @nodes_handler can be used
132
132
  def init
133
133
  # Default values
134
- @ssh_user = ENV['hpc_ssh_user']
135
- @ssh_user = ENV['USER'] if @ssh_user.nil? || @ssh_user.empty?
134
+ @ssh_user = ENV.fetch('hpc_ssh_user', nil)
135
+ @ssh_user = ENV.fetch('USER', nil) if @ssh_user.nil? || @ssh_user.empty?
136
136
  if @ssh_user.nil? || @ssh_user.empty?
137
137
  _exit_status, stdout = @cmd_runner.run_cmd 'whoami', log_to_stdout: log_debug?
138
138
  @ssh_user = stdout.strip
@@ -141,7 +141,7 @@ module HybridPlatformsConductor
141
141
  @ssh_strict_host_key_checking = true
142
142
  @passwords = {}
143
143
  @auth_password = false
144
- @ssh_gateways_conf = ENV['hpc_ssh_gateways_conf'].nil? ? nil : ENV['hpc_ssh_gateways_conf'].to_sym
144
+ @ssh_gateways_conf = ENV['hpc_ssh_gateways_conf']&.to_sym
145
145
  @ssh_gateway_user = ENV['hpc_ssh_gateway_user'].nil? ? 'ubradm' : ENV['hpc_ssh_gateway_user']
146
146
  # The map of existing ssh directories that have been created, per node that can access them
147
147
  # Array< String, Array<String> >
@@ -333,13 +333,13 @@ module HybridPlatformsConductor
333
333
  #{File.basename(from)} | \
334
334
  #{ssh_exec} \
335
335
  #{ssh_url} \
336
- \"#{need_sudo ? @actions_executor.sudo_prefix(@node) : ''}tar \
336
+ "#{need_sudo ? @actions_executor.sudo_prefix(@node) : ''}tar \
337
337
  --extract \
338
338
  --gunzip \
339
339
  --file - \
340
340
  --directory #{to} \
341
341
  --owner root \
342
- \"
342
+ "
343
343
  EO_BASH
344
344
  end
345
345
  end
@@ -415,7 +415,7 @@ module HybridPlatformsConductor
415
415
  User #{@ssh_user}
416
416
  # Default control socket path to be used when multiplexing SSH connections
417
417
  ControlPath #{control_master_file('%h', '%p', '%r')}
418
- #{open_ssh_major_version >= 7 ? 'PubkeyAcceptedKeyTypes +ssh-dss' : ''}
418
+ #{open_ssh_major_version >= 7 && open_ssh_major_version < 9 ? 'PubkeyAcceptedKeyTypes +ssh-dss' : ''}
419
419
  #{known_hosts_file.nil? ? '' : "UserKnownHostsFile #{known_hosts_file}"}
420
420
  #{@ssh_strict_host_key_checking ? '' : 'StrictHostKeyChecking no'}
421
421
 
@@ -492,6 +492,8 @@ module HybridPlatformsConductor
492
492
  # Time in seconds to wait between different retries because system is booting up
493
493
  WAIT_TIME_FOR_BOOT = 10
494
494
 
495
+ private_constant :MAX_THREADS_CONTROL_MASTER, :MAX_RETRIES_FOR_BOOT, :WAIT_TIME_FOR_BOOT
496
+
495
497
  # Open an SSH control master to multiplex connections to a given list of nodes.
496
498
  # This method is re-entrant and reuses the same control masters.
497
499
  # It is multi-processes:
@@ -160,7 +160,7 @@ module HybridPlatformsConductor
160
160
  flatten(1)
161
161
  # Check for some helpers we know include some recipes
162
162
  @config.known_helpers_including_recipes.each do |helper_name, used_recipes_by_helper|
163
- if recipe_content =~ Regexp.new(/(\W|^)#{Regexp.escape(helper_name)}(\W|$)/)
163
+ if recipe_content =~ /(\W|^)#{Regexp.escape(helper_name)}(\W|$)/
164
164
  used_recipes.concat(used_recipes_by_helper.map { |recipe_def| @platform.decode_recipe(recipe_def) })
165
165
  used_recipes.uniq!
166
166
  end
@@ -214,6 +214,7 @@ module HybridPlatformsConductor
214
214
  INVALID_LIBRARY_METHODS = [
215
215
  'initialize'
216
216
  ]
217
+ private_constant :INVALID_LIBRARY_METHODS
217
218
 
218
219
  # Get the user defined library methods, per cookbook.
219
220
  # Keep a memory cache of it.
@@ -16,7 +16,7 @@ module HybridPlatformsConductor
16
16
  def init
17
17
  # This method is called when initializing a new instance of this platform handler, for a given repository.
18
18
  inv_file = "#{@repository_path}/inventory.yaml"
19
- @inventory = File.exist?(inv_file) ? YAML.safe_load(File.read(inv_file)) : {}
19
+ @inventory = File.exist?(inv_file) ? YAML.safe_load_file(inv_file) : {}
20
20
  end
21
21
 
22
22
  # Get the list of known nodes.
@@ -696,6 +696,7 @@ class ProxmoxWaiter
696
696
 
697
697
  # Timeout in seconds before giving up on a lock
698
698
  LOCK_TIMEOUT = 30
699
+ private_constant :LOCK_TIMEOUT
699
700
 
700
701
  # Get the IP address of a given LXC container
701
702
  #
@@ -85,8 +85,8 @@ begin
85
85
 
86
86
  proxmox_waiter = ProxmoxWaiter.new(
87
87
  config_file,
88
- ENV['hpc_user_for_proxmox'],
89
- ENV['hpc_password_for_proxmox'],
88
+ ENV.fetch('hpc_user_for_proxmox', nil),
89
+ ENV.fetch('hpc_password_for_proxmox', nil),
90
90
  ENV['hpc_realm_for_proxmox'] || 'pam'
91
91
  )
92
92
 
@@ -518,6 +518,7 @@ module HybridPlatformsConductor
518
518
  # Consider that it is to be used on the following patterns: (config|create|destroy)_<ID>.json
519
519
  # So remaining length is 255 - 13 = 242 characters.
520
520
  MAX_FILE_ID_SIZE = 242
521
+ private_constant :MAX_FILE_ID_SIZE
521
522
 
522
523
  # Get an ID unique for this node/environment and that can be used in file names.
523
524
  #
@@ -51,6 +51,7 @@ module HybridPlatformsConductor
51
51
  private
52
52
 
53
53
  TEMPLATES_PATH = File.expand_path("#{File.dirname(__FILE__)}/templates")
54
+ private_constant :TEMPLATES_PATH
54
55
 
55
56
  # Render a given ERB template into a String
56
57
  #
@@ -87,8 +87,8 @@ module HybridPlatformsConductor
87
87
 
88
88
  with_credentials_for(:keepass, resource: keepass_secrets_info[:database]) do |_user, password|
89
89
  Tempfile.create('hpc_keepass') do |xml_file|
90
- key_file = ENV['hpc_key_file_for_keepass']
91
- password_enc = ENV['hpc_password_enc_for_keepass']
90
+ key_file = ENV.fetch('hpc_key_file_for_keepass', nil)
91
+ password_enc = ENV.fetch('hpc_password_enc_for_keepass', nil)
92
92
  keepass_credentials = {}
93
93
  keepass_credentials[:password] = password.to_unprotected if password
94
94
  keepass_credentials[:password_enc] = password_enc if password_enc
@@ -116,6 +116,7 @@ module HybridPlatformsConductor
116
116
  url: 'URL',
117
117
  user_name: 'UserName'
118
118
  }
119
+ private_constant :FIELDS
119
120
 
120
121
  # Parse XML secrets from a Nokogiri XML group node
121
122
  #
@@ -26,12 +26,12 @@ module HybridPlatformsConductor
26
26
  cmd_runner: @cmd_runner
27
27
  ).known_platforms.first
28
28
  unless example_platform.nil?
29
- tests.concat [
29
+ tests.push(
30
30
  "#{CmdRunner.executables_prefix}get_impacted_nodes --platform #{example_platform.name} --show-commands"
31
- ]
31
+ )
32
32
  example_node = example_platform.known_nodes.first
33
33
  unless example_node.nil?
34
- tests.concat [
34
+ tests.push(
35
35
  "#{CmdRunner.executables_prefix}check-node --node #{example_node} --show-commands",
36
36
  "#{CmdRunner.executables_prefix}deploy --node #{example_node} --show-commands --why-run",
37
37
  "#{CmdRunner.executables_prefix}last_deploys --node #{example_node} --show-commands",
@@ -39,7 +39,7 @@ module HybridPlatformsConductor
39
39
  "#{CmdRunner.executables_prefix}report --node #{example_node} --format stdout",
40
40
  "#{CmdRunner.executables_prefix}run --node #{example_node} --show-commands --interactive",
41
41
  "#{CmdRunner.executables_prefix}topograph --from \"--node #{example_node}\" --to \"--node #{example_node}\" --skip-run --output graphviz:graph.gv"
42
- ]
42
+ )
43
43
  end
44
44
  end
45
45
  tests.sort.each do |cmd|
@@ -48,7 +48,7 @@ module HybridPlatformsConductor
48
48
  assert_equal(exit_status, 0, "Command #{cmd} returned code #{exit_status}:\n#{stdout}")
49
49
  end
50
50
  # Remove the file created by Topograph if it exists
51
- File.unlink('graph.gv') if File.exist?('graph.gv')
51
+ FileUtils.rm_f('graph.gv')
52
52
  end
53
53
 
54
54
  end
@@ -20,18 +20,18 @@ module HybridPlatformsConductor
20
20
  _exit_status, stdout, _stderr = @cmd_runner.run_cmd(<<~EO_BASH, log_to_stdout: log_debug?, no_exception: true, expected_code: [0, 1])
21
21
  cd #{@platform.repository_path} && \
22
22
  git --no-pager log \
23
+ --pretty=format:"%H" \
24
+ --graph \
23
25
  $(git merge-base \
24
26
  --octopus \
25
- $(git --no-pager log #{merge_commit_id} --max-count 1 --pretty=format:\"%P\") \
26
- )..#{merge_commit_id} \
27
- --pretty=format:\"%H\" \
28
- --graph \
27
+ $(git --no-pager log #{merge_commit_id} --max-count 1 --pretty=format:"%P") \
28
+ )..#{merge_commit_id}
29
29
  | grep '|'
30
30
  EO_BASH
31
31
  next if stdout.empty?
32
32
 
33
33
  _exit_status, stdout, _stderr = @cmd_runner.run_cmd(
34
- "cd #{@platform.repository_path} && git --no-pager log #{merge_commit_id} --max-count 1 --pretty=format:%aI",
34
+ "cd #{@platform.repository_path} && git show --no-patch --format=%ci #{merge_commit_id}",
35
35
  log_to_stdout: log_debug?
36
36
  )
37
37
  error "Git history is not linear because of Merge commit #{merge_commit_id}" if Time.now - Time.parse(stdout.strip) < LOOKING_PERIOD
@@ -13,7 +13,7 @@ module HybridPlatformsConductor
13
13
  @nodes_handler.prefetch_metadata_of @nodes_handler.known_nodes, :veid
14
14
  veids = @nodes_handler.
15
15
  known_nodes.
16
- to_h { |node| [node, @nodes_handler.get_veid_of(node) ? @nodes_handler.get_veid_of(node).to_i : nil] }
16
+ to_h { |node| [node, @nodes_handler.get_veid_of(node)&.to_i] }
17
17
 
18
18
  # Check there are no duplicates
19
19
  veids.group_by { |_node, veid| veid }.each do |veid, nodes|
@@ -56,6 +56,7 @@ module HybridPlatformsConductor
56
56
  private
57
57
 
58
58
  TEMPLATES_PATH = File.expand_path("#{__dir__}/templates")
59
+ private_constant :TEMPLATES_PATH
59
60
 
60
61
  # Render a given ERB template into a String
61
62
  #
@@ -55,7 +55,7 @@ module HybridPlatformsConductor
55
55
  def dump_json_for(nodes_selectors)
56
56
  nodes = @nodes_handler.select_nodes(nodes_selectors)
57
57
  unless @skip_run
58
- nodes.map { |node| @nodes_handler.platform_for(node) }.uniq.each.each do |platform_handler|
58
+ nodes.map { |node| @nodes_handler.platform_for(node) }.uniq.each do |platform_handler|
59
59
  platform_handler.prepare_why_run_deploy_for_json_dump if platform_handler.respond_to?(:prepare_why_run_deploy_for_json_dump)
60
60
  end
61
61
  @deployer.concurrent_execution = true
@@ -221,7 +221,7 @@ module HybridPlatformsConductor
221
221
  # * Object: The stdout log device
222
222
  def stdout_device
223
223
  # TODO: Find a more elegant way to access the internal log device
224
- @logger.instance_variable_get(:@logdev).dev
224
+ @logger.instance_variable_get(:@logdev)&.dev
225
225
  end
226
226
 
227
227
  # Set the stdout device
@@ -230,7 +230,7 @@ module HybridPlatformsConductor
230
230
  # * *log_device* (Object): The stdout log device to set
231
231
  def stdout_device=(log_device)
232
232
  # TODO: Find a more elegant way to access the internal log device
233
- @logger.instance_variable_get(:@logdev).send(:set_dev, log_device)
233
+ @logger.instance_variable_get(:@logdev)&.send(:set_dev, log_device)
234
234
  end
235
235
 
236
236
  # Get the stderr device
@@ -239,7 +239,7 @@ module HybridPlatformsConductor
239
239
  # * IO or String: The stdout IO or file name
240
240
  def stderr_device
241
241
  # TODO: Find a more elegant way to access the internal log device
242
- @logger_stderr.instance_variable_get(:@logdev).dev
242
+ @logger_stderr.instance_variable_get(:@logdev)&.dev
243
243
  end
244
244
 
245
245
  # Set the stderr device
@@ -248,7 +248,7 @@ module HybridPlatformsConductor
248
248
  # * *log_device* (Object): The stdout log device to set
249
249
  def stderr_device=(log_device)
250
250
  # TODO: Find a more elegant way to access the internal log device
251
- @logger_stderr.instance_variable_get(:@logdev).send(:set_dev, log_device)
251
+ @logger_stderr.instance_variable_get(:@logdev)&.send(:set_dev, log_device)
252
252
  end
253
253
 
254
254
  # Is stdout really getting to the terminal display?
@@ -307,8 +307,8 @@ module HybridPlatformsConductor
307
307
  yield progress_bar
308
308
  ensure
309
309
  LoggerHelpers.progress_bar_semaphore.synchronize do
310
- stdout_device.flush
311
- stderr_device.flush
310
+ stdout_device&.flush
311
+ stderr_device&.flush
312
312
  self.stdout_device = previous_stdout_device unless previous_stdout_device.nil?
313
313
  self.stderr_device = previous_stderr_device unless previous_stderr_device.nil?
314
314
  end
@@ -323,7 +323,7 @@ module HybridPlatformsConductor
323
323
  # Parameters::
324
324
  # * *property* (Symbol): The property name
325
325
  def define_property_method_for(property)
326
- define_singleton_method("get_#{property}_of".to_sym) { |node| metadata_of(node, property) }
326
+ define_singleton_method(:"get_#{property}_of") { |node| metadata_of(node, property) }
327
327
  end
328
328
 
329
329
  # Accept any method of name get_<property>_of to get the metadata property of a given node.
@@ -331,15 +331,13 @@ module HybridPlatformsConductor
331
331
  #
332
332
  # Parameters::
333
333
  # * *method* (Symbol): The missing method name
334
- # * *args* (Array<Object>): Arguments given to the call
335
- # * *block* (Proc): Code block given to the call
336
- def method_missing(method, *args, &block)
334
+ def method_missing(method, ...)
337
335
  if method.to_s =~ /^get_(.*)_of$/
338
336
  property = Regexp.last_match(1).to_sym
339
337
  # Define the method so that we don't go trough method_missing next time (more efficient).
340
338
  define_property_method_for(property)
341
339
  # Then call it
342
- send("get_#{property}_of".to_sym, *args, &block)
340
+ send(:"get_#{property}_of", ...)
343
341
  else
344
342
  # We really don't know this method.
345
343
  # Call original implementation of method_missing that will raise an exception.
@@ -391,7 +389,7 @@ module HybridPlatformsConductor
391
389
  end
392
390
  # Property values, per node name
393
391
  # Hash< String, Object >
394
- metadata_from_cmdb = cmdb.send("get_#{cmdb_property}".to_sym, nodes_to_query, @metadata.slice(*nodes_to_query)).transform_values do |cmdb_result|
392
+ metadata_from_cmdb = cmdb.send(:"get_#{cmdb_property}", nodes_to_query, @metadata.slice(*nodes_to_query)).transform_values do |cmdb_result|
395
393
  cmdb_property == :others ? cmdb_result[property] : cmdb_result
396
394
  end.compact
397
395
  cmdb_log_header = "[CMDB #{cmdb.class.name.split('::').last}.#{cmdb_property}] -"
@@ -72,7 +72,7 @@ module HybridPlatformsConductor
72
72
  nbr_processing = pools[:processing].size
73
73
  nbr_processed = pools[:processed].size
74
74
  end
75
- progress_bar.title = "Queue: #{nbr_to_process} - Processing: #{nbr_processing} - Done: #{nbr_processed} - Total: #{nbr_total}"
75
+ progress_bar.title = "Queue: #{nbr_to_process} - Processing: #{nbr_processing} - Done: #{nbr_processed} - Total: #{nbr_total}" if stdout_displayed?
76
76
  progress_bar.progress = nbr_processed
77
77
  break if nbr_processed == nbr_total
78
78
 
@@ -17,7 +17,7 @@ module HybridPlatformsConductor
17
17
  # Make sure we define automatically a helper for such a platform
18
18
  mixin = Module.new
19
19
  platform_type = subclass.name.split('::').last.gsub(/([a-z\d])([A-Z\d])/, '\1_\2').downcase.to_sym
20
- mixin.define_method("#{platform_type}_platform".to_sym) do |path: nil, git: nil, branch: 'master', name: nil, &platform_config_code|
20
+ mixin.define_method(:"#{platform_type}_platform") do |path: nil, git: nil, branch: 'master', name: nil, &platform_config_code|
21
21
  repository_path =
22
22
  if !path.nil?
23
23
  path
@@ -82,7 +82,7 @@ module HybridPlatformsConductor
82
82
  # Result::
83
83
  # * Array<PlatformHandler>: List of platform handlers
84
84
  def known_platforms(platform_type: nil)
85
- (platform_type.nil? ? @platform_handlers.keys : [platform_type]).map { |search_platform_type| (@platform_handlers[search_platform_type] || []) }.flatten
85
+ (platform_type.nil? ? @platform_handlers.keys : [platform_type]).map { |search_platform_type| @platform_handlers[search_platform_type] || [] }.flatten
86
86
  end
87
87
 
88
88
  # Return the platform handler for a given platform name
@@ -52,7 +52,7 @@ module HybridPlatformsConductor
52
52
  @platforms_handler.inject_dependencies(nodes_handler: @nodes_handler, actions_executor: @actions_executor)
53
53
  end
54
54
 
55
- # Are we allowed to deploy?
55
+ # Get a potential reason that would prevent deployment.
56
56
  # This checks eventual restrictions on deployments, considering environments, options, secrets...
57
57
  #
58
58
  # Parameters::
@@ -60,7 +60,7 @@ module HybridPlatformsConductor
60
60
  # * *local_environment* (Boolean): Are we deploying to a local environment?
61
61
  # Result::
62
62
  # * String or nil: Reason for which we are not allowed to deploy, or nil if deployment is authorized
63
- def deploy_allowed?(
63
+ def barrier_to_deploy(
64
64
  services:,
65
65
  local_environment:
66
66
  )
@@ -198,13 +198,13 @@ module HybridPlatformsConductor
198
198
  # Get all platforms involved in the deployment of those services on this node
199
199
  platforms_for(node => services).keys.each.with_index do |platform, platform_idx|
200
200
  log_info.merge!(
201
- "repo_name_#{platform_idx}".to_sym => platform.name
201
+ "repo_name_#{platform_idx}": platform.name
202
202
  )
203
203
  if platform.info.key?(:commit)
204
204
  log_info.merge!(
205
- "commit_id_#{platform_idx}".to_sym => platform.info[:commit][:id],
206
- "commit_message_#{platform_idx}".to_sym => platform.info[:commit][:message].split("\n").first,
207
- "diff_files_#{platform_idx}".to_sym => (platform.info[:status][:changed_files] + platform.info[:status][:added_files] + platform.info[:status][:deleted_files] + platform.info[:status][:untracked_files]).join(', ')
205
+ "commit_id_#{platform_idx}": platform.info[:commit][:id],
206
+ "commit_message_#{platform_idx}": platform.info[:commit][:message].split("\n").first,
207
+ "diff_files_#{platform_idx}": (platform.info[:status][:changed_files] + platform.info[:status][:added_files] + platform.info[:status][:deleted_files] + platform.info[:status][:untracked_files]).join(', ')
208
208
  )
209
209
  end
210
210
  end
@@ -155,11 +155,11 @@ module HybridPlatformsConductor
155
155
  first_criteria =
156
156
  case first_criteria
157
157
  when :test_name
158
- proc { |test| test.name }
158
+ proc(&:name)
159
159
  when :platform
160
- proc { |test| test.platform }
160
+ proc(&:platform)
161
161
  when :node
162
- proc { |test| test.node }
162
+ proc(&:node)
163
163
  else
164
164
  raise "Unknown group criteria name: #{first_criteria}"
165
165
  end
@@ -232,7 +232,7 @@ module HybridPlatformsConductor
232
232
  def flatten_hash(hash)
233
233
  hash.each_with_object({}) do |(k, v), h|
234
234
  if v.is_a? Hash
235
- flatten_hash(v).map { |h_k, h_v| h["#{k}.#{h_k}".to_sym] = h_v }
235
+ flatten_hash(v).map { |h_k, h_v| h[:"#{k}.#{h_k}"] = h_v }
236
236
  else
237
237
  h[k] = v
238
238
  end