/
public_ldap_projects.rb
96 lines (84 loc) · 2.56 KB
/
public_ldap_projects.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Creates JSON output with the following format:
#
# {
# "lastTimestamp": "20160119171152Z", // most recent modifyTimestamp
# "projects": {
# "airflow": {
# "createTimestamp": "20170118154251Z",
# "modifyTimestamp": "20170118154251Z",
# "members": [
# "abcd",
# ],
# "owners": [
# "abcd",
# ],
# "pmc": true|false, (may be absent)
# "podling": "current|graduated|retired" (may be absent)
# },
# ...
# },
# }
#
# ##################################################################################################
# TODO this is a preliminary version. Subject to change/removal.
# The output format may change or may be dropped entirely - e.g. if it is merged into existing files
# ##################################################################################################
require_relative 'public_json_common'
# gather project group info
entries = {}
projects = ASF::Project.preload # for performance
if projects.empty?
Wunderbar.error "No results retrieved, output not created"
exit 0
end
# committee status
committees = Hash[ASF::Committee.load_committee_info.map {|committee|
[ committee.name.gsub(/[^-\w]/,'') , !committee.nonpmc? ]
}]
# podling status
pods = Hash[ASF::Podling.list.map {|podling| [podling.name, podling.status]}]
lastStamp = ''
projects.keys.sort_by {|a| a.name}.each do |entry|
next if entry.name == 'apldap' # infra team would prefer this not be publicized
m = []
entry.members.sort_by {|a| a.name}.each do |e|
m << e.name
end
o = []
entry.owners.sort_by {|a| a.name}.each do |e|
o << e.name
end
lastStamp = entry.modifyTimestamp if entry.modifyTimestamp > lastStamp
entries[entry.name] = {
createTimestamp: entry.createTimestamp,
modifyTimestamp: entry.modifyTimestamp,
members: m,
owners: o
}
pmc = committees[entry.name]
if pmc
entries[entry.name][:pmc]=pmc
end
pod = pods[entry.name]
if pod
entries[entry.name][:podling]=pod
end
end
info = {
# Is there a use case for the last createTimestamp ?
lastTimestamp: lastStamp,
projects: entries,
}
public_json_output(info)
if changed? and @old_file
# for validating UIDs
uids = ASF::Person.list().map(&:id)
entries.each do |name, entry|
entry[:members].each do |id|
Wunderbar.warn "#{name}: unknown member uid #{id}" unless uids.include?(id)
end
entry[:owners].each do |id|
Wunderbar.warn "#{name}: unknown owner uid #{id}" unless uids.include?(id)
end
end
end