@@ -32,6 +32,7 @@ type orgResourceType struct {
3232 resourceType * v2.ResourceType
3333 client * github.Client
3434 orgs map [string ]struct {}
35+ orgCache * orgNameCache
3536}
3637
3738func (o * orgResourceType ) ResourceType (_ context.Context ) * v2.ResourceType {
@@ -161,7 +162,7 @@ func (o *orgResourceType) Grants(
161162 },
162163 }
163164
164- orgName , err := getOrgName ( ctx , o . client , resource .Id )
165+ orgName , err := o . orgCache . GetOrgName ( ctx , resource .Id )
165166 if err != nil {
166167 return nil , "" , nil , err
167168 }
@@ -232,7 +233,7 @@ func (o *orgResourceType) Grant(ctx context.Context, principal *v2.Resource, en
232233 return nil , fmt .Errorf ("github-connectorv2: invalid entitlement id: %s" , en .Id )
233234 }
234235
235- orgName , err := getOrgName ( ctx , o . client , en .Resource .Id )
236+ orgName , err := o . orgCache . GetOrgName ( ctx , en .Resource .Id )
236237 if err != nil {
237238 return nil , err
238239 }
@@ -288,7 +289,7 @@ func (o *orgResourceType) Revoke(ctx context.Context, grant *v2.Grant) (annotati
288289 return nil , fmt .Errorf ("github-connectorv2: invalid entitlement id: %s" , en .Id )
289290 }
290291
291- orgName , err := getOrgName ( ctx , o . client , en .Resource .Id )
292+ orgName , err := o . orgCache . GetOrgName ( ctx , en .Resource .Id )
292293 if err != nil {
293294 return nil , err
294295 }
@@ -325,7 +326,7 @@ func (o *orgResourceType) Revoke(ctx context.Context, grant *v2.Grant) (annotati
325326 return nil , nil
326327}
327328
328- func orgBuilder (client * github.Client , orgs []string ) * orgResourceType {
329+ func orgBuilder (client * github.Client , orgCache * orgNameCache , orgs []string ) * orgResourceType {
329330 orgMap := make (map [string ]struct {})
330331
331332 for _ , o := range orgs {
@@ -336,5 +337,6 @@ func orgBuilder(client *github.Client, orgs []string) *orgResourceType {
336337 resourceType : resourceTypeOrg ,
337338 orgs : orgMap ,
338339 client : client ,
340+ orgCache : orgCache ,
339341 }
340342}
0 commit comments