Skip to content

Accept depth as option for Recursive membership validator strategy constructor #73

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

Merged

Conversation

mtodd
Copy link
Member

@mtodd mtodd commented Dec 10, 2014

This makes the GitHub::Ldap::MembershipValidators::Recursive#perform method signature identical to the other strategies, moving the options to the constructor to match the GitHub::Ldap::MemberSearch strategies too.

Technically this is a backwards incompatible API breakage but I don't think it's a significant enough change as to cause a major version bump since it's really fixing a bug with the API. Thoughts?

cc @jch

mtodd added 2 commits December 9, 2014 17:25
This makes the perform method signature identical for all strategies.
@mtodd
Copy link
Member Author

mtodd commented Dec 10, 2014

Could make these minor changes to prevent the API breakage:

diff --git a/lib/github/ldap/membership_validators/recursive.rb b/lib/github/ldap/membership_validators/recursive.rb
index 8544f30..dfffdf4 100644
--- a/lib/github/ldap/membership_validators/recursive.rb
+++ b/lib/github/ldap/membership_validators/recursive.rb
@@ -36,7 +36,7 @@ module GitHub
           @depth = options[:depth] || DEFAULT_MAX_DEPTH
         end

-        def perform(entry)
+        def perform(entry, depth_override = nil)
           # short circuit validation if there are no groups to check against
           return true if groups.empty?

@@ -51,7 +51,7 @@ module GitHub
             next if membership.empty?

             # recurse to at most `depth`
-            depth.times do |n|
+            (depth_override || depth).times do |n|
               # find groups whose members include membership groups
               membership = domain.search(filter: membership_filter(membership), attributes: ATTRS)

But I think that's being pedantic and the practical side of me just wants to merge this and cut 1.7.0.

@mtodd mtodd changed the title Accept depth as option for Recursive strategy constructor Accept depth as option for Recursive membership validator strategy constructor Dec 11, 2014
@mtodd mtodd self-assigned this Dec 11, 2014
# Public: Instantiate new search strategy.
#
# - ldap: GitHub::Ldap object
# - options: Hash of options
Copy link
Contributor

Choose a reason for hiding this comment

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

I would document the depth attribute here.

@jch
Copy link
Contributor

jch commented Dec 11, 2014

@mtodd since we are at a > 1.0, I'd like to maintain semver. Even though we're likely the primary users of this library, it'll make it easier on ourselves if we ever need to downgrade our own library for an important fix. I would also output to stderr with a deprecation notice if someone calls the old interface.

# - ldap: GitHub::Ldap object
# - groups: Array of Net::LDAP::Entry group objects
# - options: Hash of options
# depth: Integer limit of recursion
Copy link
Member Author

Choose a reason for hiding this comment

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

@jch documented depth option.

@mtodd
Copy link
Member Author

mtodd commented Dec 11, 2014

it'll make it easier on ourselves if we ever need to downgrade our own library for an important fix

Generally I agree with you. But this part is more theoretical than actual since we never used the now-deprecated API at any time, so at the very least, assuming we're the only user of this component, we've solved zero problems going out of our way to follow a spec.

In any case, I've kept the current API, added deprecation warning, and will release this as 1.7.0. I'll remove the relevant bits for 2.0.

mtodd added a commit that referenced this pull request Dec 11, 2014
…pth-as-constructor-option

Accept depth as option for Recursive membership validator strategy constructor
@mtodd mtodd merged commit 4105b9e into master Dec 11, 2014
@mtodd mtodd deleted the recursive-membership-validation-depth-as-constructor-option branch December 11, 2014 08:28
@mtodd mtodd mentioned this pull request Dec 11, 2014
@jch
Copy link
Contributor

jch commented Dec 11, 2014

Generally I agree with you. But this part is more theoretical than actual since we never used the now-deprecated API at any time, so at the very least, assuming we're the only user of this component, we've solved zero problems going out of our way to follow a spec.

I hear your frustration that it feels like extra work for no gain in this instance. But I think we ended up having to change the public interface so quickly because we hadn't used it enough ourselves to understand what the correct public interface should look like. To avoid this extra work maintaining semver in the future, we can experiment with changes in our own project first before pushing the changes upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants