I've modified public_nonldap_groups.rb to reuse the existing authorization parsing in whimsy/asf.
Since this merits discussion before merging, I put it into a pull request: https://github.com/apache/whimsy/pull/5 There also are 'pit-' groups that can be handled the same way. Feel free to merge or delete the branch. Or to make improvements to the underlying ASF::Authorization class: https://github.com/apache/whimsy/blob/master/lib/whimsy/asf/auth.rb - Sam Ruby On Sat, Jan 23, 2016 at 7:34 PM, Sebastian Bazley <s...@apache.org> wrote: > Commit 9abe73d558a1a5fffe38759797e4a57845e35b12: > Extract podling groups etc from asf-authorization-template > > > Branch: refs/heads/master > Author: Sebb <s...@apache.org> > Committer: Sebb <s...@apache.org> > Pusher: sebb <s...@apache.org> > > ------------------------------------------------------------ > www/roster/public_nonldap_groups.rb | +++++++++ > ------------------------------------------------------------ > 65 changes: 65 additions, 0 deletions. > ------------------------------------------------------------ > > > diff --git a/www/roster/public_nonldap_groups.rb > b/www/roster/public_nonldap_groups.rb > new file mode 100644 > index 0000000..28e4f5d > --- /dev/null > +++ b/www/roster/public_nonldap_groups.rb > @@ -0,0 +1,65 @@ > +# Not all authorization groups are defined in LDAP, for example podlings > +# Extract these from asf-authorization-template > +# > +# We use the Git copy rather than the SVN version: > +# - it is available without needing auth > +# - the groups don't take effect unless the Git copy is updated > +# - the SVN copy is due to be retired (one day) > +# Unfortunately the Git HTTP server does not support If-Modified-Since or > ETag > +# > +# Output looks like: > +# { > +# "git_info": "5623ad5 2016-01-23 16:26:01 -0500", > +# "groups": { > +# "batchee": [ > +# "uid", > +# ... > +# ] > +# }, > +# > + > +require 'bundler/setup' > + > +require 'whimsy/asf' > + > +require 'net/http' > +require 'json' > +require 'open3' > + > +GITINFO = ASF.library_gitinfo rescue '?' > + > +file = > '/apache/infrastructure-puppet/deployment/modules/subversion_server/files/authorization/asf-authorization-template' > +http = Net::HTTP.new('raw.githubusercontent.com', 443) > +http.use_ssl = true > +body = http.request(Net::HTTP::Get.new(file)).body > + .sub(/^.*\[groups\]\s*$/m,'') > + .sub(/^\[\/\].*/m,'') > + > +groups = {} > + > +# find the locally defined groups > +body.scan(/^(\w[^=\s]*)[ \t]*=[ \t]*(\w.*)$/) do |grp, mem| > + groups[grp] = mem.gsub(/\s/,'').split(/,/).sort.uniq > +end > + > +info = { > + # There does not seem to be a useful timestamp here > + git_info: GITINFO, > + groups: groups, > +} > + > +# format as JSON > +results = JSON.pretty_generate(info) > + > +# parse arguments for output file name > +if ARGV.length == 0 or ARGV.first == '-' > + # write to STDOUT > + puts results > +elsif not File.exist?(ARGV.first) or File.read(ARGV.first) != results > + > + out, err, rc = Open3.capture3('diff', '-u', ARGV.first, '-', stdin_data: > results) > + puts out if err.empty? and rc.exitstatus == 1 > + > + # replace file as contents have changed > + File.write(ARGV.first, results) > +end