You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2025/05/31 16:51:59 UTC

(whimsy) branch master updated: Revert "Allow for removal of committers role group"

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 902e3da7 Revert "Allow for removal of committers role group"
902e3da7 is described below

commit 902e3da7587ab8283d32467c9651105f9edd5dba
Author: Sebb <se...@apache.org>
AuthorDate: Sat May 31 17:51:13 2025 +0100

    Revert "Allow for removal of committers role group"
    
    This reverts commit 1c11d62f4ee234f893f7e63a3d142217fed2823d.
    
    GHA Unit test fails for some as yet unknown reason.
---
 lib/whimsy/asf/ldap.rb | 56 +++++++++++++++++++++++---------------------------
 1 file changed, 26 insertions(+), 30 deletions(-)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 242958c1..44b136bc 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -426,20 +426,21 @@ module ASF
   end
 
   # Obtain a list of committers from LDAP
-  # <tt>cn=committers,ou=groups,dc=apache,dc=org</tt>
+  # <tt>cn=committers,ou=role,ou=groups,dc=apache,dc=org</tt>
   def self.committers
-    weakref(:committers) {ASF::Group['committers'].members}
+    weakref(:committers) {RoleGroup.find('committers').members}
   end
 
   # Obtain a list of committerids from LDAP
-  # <tt>cn=committers,ou=groups,dc=apache,dc=org</tt>
+  # <tt>cn=committers,ou=role,ou=groups,dc=apache,dc=org</tt>
   def self.committerids
-    weakref(:committerids) {ASF::Group['committers'].memberids}
+    weakref(:committerids) {RoleGroup.find('committers').memberids}
   end
 
   # Obtain a list of members from LDAP
   # <tt>cn=member,ou=groups,dc=apache,dc=org</tt>
   # Note: includes some non-ASF member infrastructure contractors
+  # TODO: convert to RoleGroup at some point?
   def self.members
     weakref(:members) {Group.find('member').members}
   end
@@ -447,6 +448,7 @@ module ASF
   # Obtain a list of memberids from LDAP
   # <tt>cn=member,ou=groups,dc=apache,dc=org</tt>
   # Note: includes some non-ASF member infrastructure contractors
+  # TODO: convert to RoleGroup at some point?
   def self.memberids
     weakref(:memberids) {Group.find('member').memberids}
   end
@@ -593,18 +595,18 @@ module ASF
   # Manage committers: list, add, and remove people not only from the list
   # of people, but from the list of committers.
   class Committer < Base
-    @role_base = 'ou=role,ou=groups,dc=apache,dc=org' # Keep for now
-    # Does the role group still exist?
-    @has_role_group = ASF.search_one(@role_base, 'cn=committers', 'dn').size > 0
+    @base = 'ou=role,ou=groups,dc=apache,dc=org'
 
     # get a list of committers
     def self.list
-      self.listids.map {|uid| Person.find uid}
+      ASF.search_one(base, 'cn=committers', 'member').flatten.
+        map {|uid| Person.find uid[/uid=(.*?),/, 1]}
     end
 
     # get a list of committers (ids only)
     def self.listids
-      ASF::Group['committers'].memberids
+      ASF.search_one(base, 'cn=committers', 'member').flatten.
+        map {|uid| uid[/uid=(.*?),/, 1]}
     end
 
     # create a new person and add as a new committer to LDAP.
@@ -665,14 +667,12 @@ module ASF
       # if person is a string, find the person object
       person = ASF::Person.find(person) if person.instance_of? String
 
-      # remove person from canonical committers list, ignoring exceptions
+      # remove person from 'legacy' committers list, ignoring exceptions
       ASF::Group['committers'].remove(person) rescue nil
 
-      # remove person from deprecated committers list, ignoring exceptions
-      if @has_role_group
-        ASF::LDAP.modify("cn=committers,#{@role_base}",
-          [ASF::Base.mod_delete('member', [person.dn])]) rescue nil
-      end
+      # remove person from 'new' committers list, ignoring exceptions
+      ASF::LDAP.modify("cn=committers,#{@base}",
+        [ASF::Base.mod_delete('member', [person.dn])]) rescue nil
 
       # remove person from LDAP (should almost never be done)
       ASF::Person.remove(person.id)
@@ -686,14 +686,12 @@ module ASF
         person = ASF::Person[person] or raise ArgumentError.new("Cannot find person: '#{id}'")
       end
 
-      # add person to canonical committers list
-      ASF::Group['committers'].add(person)
+      # add person to 'new' committers list
+      ASF::LDAP.modify("cn=committers,#{@base}",
+        [ASF::Base.mod_add('member', [person.dn])])
 
-      # add person to deprecated committers list
-      if @has_role_group
-        ASF::LDAP.modify("cn=committers,#{@role_base}",
-          [ASF::Base.mod_add('member', [person.dn])])
-      end
+      # add person to 'legacy' committers list
+      ASF::Group['committers'].add(person)
     end
 
     # deregister an existing person as a committer
@@ -704,14 +702,12 @@ module ASF
         person = ASF::Person[person] or raise ArgumentError.new("Cannot find person: '#{id}'")
       end
 
-      # remove person from canonical committers list
+      # remove person from 'legacy' committers list
       ASF::Group['committers'].remove(person)
 
-      # remove person from deprecated committers list
-      if @has_role_group
-        ASF::LDAP.modify("cn=committers,#{@role_base}",
-          [ASF::Base.mod_delete('member', [person.dn])])
-      end
+      # remove person from 'new' committers list
+      ASF::LDAP.modify("cn=committers,#{@base}",
+        [ASF::Base.mod_delete('member', [person.dn])])
     end
 
   end
@@ -1569,8 +1565,7 @@ module ASF
   end
 
   # <tt>ou=role</tt> subtree of <tt>ou=groups,dc=apache,dc=org</tt>, used for
-  # committers (new) group only currently.
-  # Also used in public_ldap_roles.rb JSON generator
+  # committers (new) group only currently
   class RoleGroup < Service
     @base = 'ou=role,ou=groups,dc=apache,dc=org'
   end
@@ -1589,4 +1584,5 @@ if __FILE__ == $0
   newids = ASF.committerids()
   puts newids.length
   puts newids.first
+  ASF::RoleGroup.listcns.map {|g| puts ASF::RoleGroup.find(g).dn}
 end