Skip to content
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

Merged

Conversation

Fryguy
Copy link
Member

@Fryguy Fryguy commented Jan 23, 2018

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

if authenticator
[:mode, "authentication type, #{config[:mode].inspect}, invalid. Should be one of: #{valid_modes.join(", ")}"]
else
authenticator.validate_config
Copy link
Member

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?

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(", ")}"]
Copy link
Member

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

@Fryguy Fryguy force-pushed the refactor_authenticator_to_remove_require_nested branch from ced98f2 to 9d83e12 Compare January 23, 2018 19:17
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
@Fryguy Fryguy force-pushed the refactor_authenticator_to_remove_require_nested branch from 9d83e12 to dad746d Compare January 23, 2018 19:20
@miq-bot
Copy link
Member

miq-bot commented Jan 23, 2018

Checked commit Fryguy@dad746d with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. 🍪

Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bdunne bdunne merged commit 61e7ea9 into ManageIQ:master Jan 23, 2018
@bdunne bdunne added this to the Sprint 78 Ending Jan 29, 2018 milestone Jan 23, 2018
@bdunne bdunne self-assigned this Jan 23, 2018
simaishi pushed a commit that referenced this pull request Jan 23, 2018
…e_require_nested

Refactor Authenticator to remove const manipulations
(cherry picked from commit 61e7ea9)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1537788
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 58d6bd28bd5b857cb1b9551fdeff46e414d58eac
Author: Brandon Dunne <brandondunne@hotmail.com>
Date:   Tue Jan 23 14:46:41 2018 -0500

    Merge pull request #16869 from Fryguy/refactor_authenticator_to_remove_require_nested
    
    Refactor Authenticator to remove const manipulations
    (cherry picked from commit 61e7ea95d8f1b508720a64c3d045aa98790fb836)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1537788

@Fryguy Fryguy deleted the refactor_authenticator_to_remove_require_nested branch January 23, 2018 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants