@@ -30,6 +30,20 @@ def initialize(config:)
3030 @github_team_cache = { }
3131 end
3232
33+ # Populate the provider cache for a collection of desired teams.
34+ #
35+ # entitlement_groups - Array of Entitlements::Models::Group objects.
36+ #
37+ # Returns nothing.
38+ Contract C ::ArrayOf [ Entitlements ::Models ::Group ] => nil
39+ def prefetch ( entitlement_groups )
40+ github . read_teams ( entitlement_groups ) . each do |team_name , github_team |
41+ log_loaded_team ( github_team ) if github_team
42+ @github_team_cache [ team_name ] = github_team
43+ end
44+ nil
45+ end
46+
3347 # Read in a specific GitHub.com Team and enumerate its members. Results are cached
3448 # for future runs.
3549 #
@@ -39,15 +53,12 @@ def initialize(config:)
3953 Contract Entitlements ::Models ::Group => C ::Maybe [ Entitlements ::Models ::Group ]
4054 def read ( entitlement_group )
4155 slug = Entitlements ::Util ::Util . any_to_cn ( entitlement_group . cn . downcase )
42- return @github_team_cache [ slug ] if @github_team_cache [ slug ]
56+ return @github_team_cache [ slug ] if @github_team_cache . key? ( slug )
4357
4458 github_team = github . read_team ( entitlement_group )
4559
46- # We should not cache a team which does not exist
47- return nil if github_team . nil?
48-
49- Entitlements . logger . debug "Loaded #{ github_team . team_dn } (id=#{ github_team . team_id } ) with #{ github_team . member_strings . count } member(s)"
50- @github_team_cache [ github_team . team_name ] = github_team
60+ log_loaded_team ( github_team ) if github_team
61+ @github_team_cache [ slug ] = github_team
5162 end
5263
5364 # Dry run of committing changes. Returns a list of users added or removed.
@@ -151,6 +162,12 @@ def auto_generate_ignored_users(entitlement_group)
151162
152163 private
153164
165+ Contract Entitlements ::Backend ::GitHubTeam ::Models ::Team => nil
166+ def log_loaded_team ( github_team )
167+ Entitlements . logger . debug "Loaded #{ github_team . team_dn } (id=#{ github_team . team_id } ) with #{ github_team . member_strings . count } member(s)"
168+ nil
169+ end
170+
154171 # Construct an Entitlements::Models::Group for a new group and team
155172 #
156173 # group - An Entitlements::Models::Group object representing the defined group
0 commit comments