Skip to content

Commit 3499ae5

Browse files
committed
Remove memoized initialization from RequestDeps.
1 parent f8d349a commit 3499ae5

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

pkg/github/dependencies.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,6 @@ func NewToolFromHandler(
237237
}
238238

239239
type RequestDeps struct {
240-
Client *gogithub.Client
241-
GQLClient *githubv4.Client
242-
RawClient *raw.Client
243-
RepoAccessCache *lockdown.RepoAccessCache
244-
245240
// Static dependencies
246241
apiHosts utils.APIHostResolver
247242
version string
@@ -277,10 +272,6 @@ func NewRequestDeps(
277272

278273
// GetClient implements ToolDependencies.
279274
func (d *RequestDeps) GetClient(ctx context.Context) (*gogithub.Client, error) {
280-
if d.Client != nil {
281-
return d.Client, nil
282-
}
283-
284275
// extract the token from the context
285276
tokenInfo, ok := ghcontext.GetTokenInfo(ctx)
286277
if !ok {
@@ -307,10 +298,6 @@ func (d *RequestDeps) GetClient(ctx context.Context) (*gogithub.Client, error) {
307298

308299
// GetGQLClient implements ToolDependencies.
309300
func (d *RequestDeps) GetGQLClient(ctx context.Context) (*githubv4.Client, error) {
310-
if d.GQLClient != nil {
311-
return d.GQLClient, nil
312-
}
313-
314301
// extract the token from the context
315302
tokenInfo, ok := ghcontext.GetTokenInfo(ctx)
316303
if !ok {
@@ -337,16 +324,11 @@ func (d *RequestDeps) GetGQLClient(ctx context.Context) (*githubv4.Client, error
337324
}
338325

339326
gqlClient := githubv4.NewEnterpriseClient(graphqlURL.String(), gqlHTTPClient)
340-
d.GQLClient = gqlClient
341327
return gqlClient, nil
342328
}
343329

344330
// GetRawClient implements ToolDependencies.
345331
func (d *RequestDeps) GetRawClient(ctx context.Context) (*raw.Client, error) {
346-
if d.RawClient != nil {
347-
return d.RawClient, nil
348-
}
349-
350332
client, err := d.GetClient(ctx)
351333
if err != nil {
352334
return nil, err
@@ -358,7 +340,6 @@ func (d *RequestDeps) GetRawClient(ctx context.Context) (*raw.Client, error) {
358340
}
359341

360342
rawClient := raw.NewClient(client, rawURL)
361-
d.RawClient = rawClient
362343

363344
return rawClient, nil
364345
}
@@ -369,18 +350,13 @@ func (d *RequestDeps) GetRepoAccessCache(ctx context.Context) (*lockdown.RepoAcc
369350
return nil, nil
370351
}
371352

372-
if d.RepoAccessCache != nil {
373-
return d.RepoAccessCache, nil
374-
}
375-
376353
gqlClient, err := d.GetGQLClient(ctx)
377354
if err != nil {
378355
return nil, err
379356
}
380357

381358
// Create repo access cache
382359
instance := lockdown.GetInstance(gqlClient, d.RepoAccessOpts...)
383-
d.RepoAccessCache = instance
384360
return instance, nil
385361
}
386362

0 commit comments

Comments
 (0)