-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Authenticator to remove const manipulations #16869
Refactor Authenticator to remove const manipulations #16869
Conversation
app/models/authenticator.rb
Outdated
if authenticator | ||
[:mode, "authentication type, #{config[:mode].inspect}, invalid. Should be one of: #{valid_modes.join(", ")}"] | ||
else | ||
authenticator.validate_config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be the other way around? Otherwise you'll get undefined method 'validate_config' for 'nil'
, right?
app/models/authenticator.rb
Outdated
hash[name] = authenticator_class_for(name) || force_load_authenticator_for(name) | ||
authenticator = self.for(config) | ||
if authenticator | ||
[:mode, "authentication type, #{config[:mode].inspect}, invalid. Should be one of: #{valid_modes.join(", ")}"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this can return [...] unless authenticator
ced98f2
to
9d83e12
Compare
After ManageIQ#16867, the DescendantLoader now works properly with non-AR models such as the Authenticator. Much of the code in the Authenticator, such as require_nested and force_load_authenticator_for is just workarounds over the issues from DescendantLoader, so these can be removed. Additionally, the only caller of the authenticator_class was the validator, so this commit moves the validation code into the Authenticator class directly, allow us to make all of those authenticator_class methods private. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1537299
9d83e12
to
dad746d
Compare
Checked commit Fryguy@dad746d with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…e_require_nested Refactor Authenticator to remove const manipulations (cherry picked from commit 61e7ea9) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1537788
Gaprindashvili backport details:
|
After #16867, the
DescendantLoader now works properly with non-AR models such as the
Authenticator. Much of the code in the Authenticator, such as
require_nested and force_load_authenticator_for is just workarounds
over the issues from DescendantLoader, so these can be removed.
Additionally, the only caller of the authenticator_class was the
validator, so this commit moves the validation code into the
Authenticator class directly, allow us to make all of those
authenticator_class methods private.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1537299
@jrafanie Please review
cc @jvlcek @bdunne