diff --git a/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb b/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb index 521043803cdce45bf96a6c9856727a4542c99bf2..143ce93ef80280b1e058a639be0c2d6bcdbad16d 100644 --- a/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb +++ b/app/models/concerns/foreman_passwordstate/passwordlist_ensurance.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ForemanPasswordstate module PasswordlistEnsurance extend ActiveSupport::Concern diff --git a/app/models/orchestration/passwordstate.rb b/app/models/orchestration/passwordstate.rb index 03aaf62ea09981a001c69415f4df847f12f94a51..3a8c97df5fe818f9f59ce53b15374aab45cfed15 100644 --- a/app/models/orchestration/passwordstate.rb +++ b/app/models/orchestration/passwordstate.rb @@ -10,7 +10,7 @@ module Orchestration # before_provision :remove_passwordstate_host, if: :passwordstate? before_destroy :remove_passwordstate_passwords!, if: :passwordstate? - # TODO - Remove passwords from old list if list ID is changing + # TODO: Remove passwords from old list if list ID is changing # before_update :remove_outdated_passwords, if: :passwordstate? after_update :ensure_passwordstate_passwords, if: :saved_change_to_name? end @@ -71,12 +71,12 @@ module Orchestration pw_desc = "Foreman managed password for #{username} on #{fqdn} | #{stable_pw_desc.strip}" begin - pw = list.passwords.search(**params.merge(description: stable_pw_desc, user_name: username)).select { |e| e.description.ends_with? stable_pw_desc }.first - pw ||= list.passwords.create(**params.merge(title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true)) if create + pw = list.passwords.search(**params, description: stable_pw_desc, user_name: username).select { |e| e.description.ends_with? stable_pw_desc }.first + pw ||= list.passwords.create(**params, title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true) if create pw rescue ::Passwordstate::NotFoundError - return list.passwords.create(**params.merge(title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true)) if create + return list.passwords.create(**params, title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true) if create raise end diff --git a/lib/foreman_passwordstate/engine.rb b/lib/foreman_passwordstate/engine.rb index e45a03674c5f18f0d1c1c72e1d76ef9855bcb091..5e5d2bd201f1ddd9be4f65e64d4cd19a3d8bdcee 100644 --- a/lib/foreman_passwordstate/engine.rb +++ b/lib/foreman_passwordstate/engine.rb @@ -28,9 +28,7 @@ module ForemanPasswordstate HostsController.prepend ForemanPasswordstate::HostsControllerExtensions HostgroupsController.prepend ForemanPasswordstate::HostgroupsControllerExtensions Operatingsystem.prepend ForemanPasswordstate::OperatingsystemExtensions - if Foreman::Plugin.installed?('foreman_discovery') - DiscoveredHostsController.prepend ForemanPasswordstate::HostsControllerExtensions - end + DiscoveredHostsController.prepend ForemanPasswordstate::HostsControllerExtensions if Foreman::Plugin.installed?('foreman_discovery') rescue StandardError => e Rails.logger.fatal "foreman_passwordstate: skipping engine hook (#{e})" end diff --git a/lib/foreman_passwordstate/register.rb b/lib/foreman_passwordstate/register.rb index 65eb65ffa1f9336d4f86b9584b1d351930f73fcf..74ac9addce7111f22274835ac38ce96c9ec6a749 100644 --- a/lib/foreman_passwordstate/register.rb +++ b/lib/foreman_passwordstate/register.rb @@ -71,7 +71,7 @@ Foreman::Plugin.register :foreman_passwordstate do :main_tabs, name: 'Passwords', partial: 'foreman_passwordstate/passwords_tab_pane_content', - onlyif: proc { |host| host.passwordstate_facet } # rubocop:disable Style/SymbolProc - Does not work with caller + onlyif: proc { |host| host.passwordstate_facet } # rubocop:disable Style/SymbolProc -- Does not work with caller ) end %i[host hostgroup].each do |res|