Skip to content
Snippets Groups Projects
Verified Commit 8f1bcd1e authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Make rubocop happier

parent d4c67785
No related branches found
No related tags found
No related merge requests found
Pipeline #156388 failed
# frozen_string_literal: true
module ForemanPasswordstate module ForemanPasswordstate
module PasswordlistEnsurance module PasswordlistEnsurance
extend ActiveSupport::Concern extend ActiveSupport::Concern
......
...@@ -10,7 +10,7 @@ module Orchestration ...@@ -10,7 +10,7 @@ module Orchestration
# before_provision :remove_passwordstate_host, if: :passwordstate? # before_provision :remove_passwordstate_host, if: :passwordstate?
before_destroy :remove_passwordstate_passwords!, 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? # before_update :remove_outdated_passwords, if: :passwordstate?
after_update :ensure_passwordstate_passwords, if: :saved_change_to_name? after_update :ensure_passwordstate_passwords, if: :saved_change_to_name?
end end
...@@ -71,12 +71,12 @@ module Orchestration ...@@ -71,12 +71,12 @@ module Orchestration
pw_desc = "Foreman managed password for #{username} on #{fqdn} | #{stable_pw_desc.strip}" pw_desc = "Foreman managed password for #{username} on #{fqdn} | #{stable_pw_desc.strip}"
begin 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.search(**params, 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.create(**params, title: "#{username}@#{fqdn}", description: pw_desc, user_name: username, generate_password: true) if create
pw pw
rescue ::Passwordstate::NotFoundError 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 raise
end end
......
...@@ -28,9 +28,7 @@ module ForemanPasswordstate ...@@ -28,9 +28,7 @@ module ForemanPasswordstate
HostsController.prepend ForemanPasswordstate::HostsControllerExtensions HostsController.prepend ForemanPasswordstate::HostsControllerExtensions
HostgroupsController.prepend ForemanPasswordstate::HostgroupsControllerExtensions HostgroupsController.prepend ForemanPasswordstate::HostgroupsControllerExtensions
Operatingsystem.prepend ForemanPasswordstate::OperatingsystemExtensions Operatingsystem.prepend ForemanPasswordstate::OperatingsystemExtensions
if Foreman::Plugin.installed?('foreman_discovery') DiscoveredHostsController.prepend ForemanPasswordstate::HostsControllerExtensions if Foreman::Plugin.installed?('foreman_discovery')
DiscoveredHostsController.prepend ForemanPasswordstate::HostsControllerExtensions
end
rescue StandardError => e rescue StandardError => e
Rails.logger.fatal "foreman_passwordstate: skipping engine hook (#{e})" Rails.logger.fatal "foreman_passwordstate: skipping engine hook (#{e})"
end end
......
...@@ -71,7 +71,7 @@ Foreman::Plugin.register :foreman_passwordstate do ...@@ -71,7 +71,7 @@ Foreman::Plugin.register :foreman_passwordstate do
:main_tabs, :main_tabs,
name: 'Passwords', name: 'Passwords',
partial: 'foreman_passwordstate/passwords_tab_pane_content', 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 end
%i[host hostgroup].each do |res| %i[host hostgroup].each do |res|
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment