MCPcopy Index your code
hub / github.com/git-bug/git-bug / cacheAllClient

Method cacheAllClient

bridge/github/export.go:78–118  ·  view source on GitHub ↗
(repo *cache.RepoCache)

Source from the content-addressed store, hash-verified

76}
77
78func (ge *githubExporter) cacheAllClient(repo *cache.RepoCache) error {
79 creds, err := auth.List(repo, auth.WithTarget(target), auth.WithKind(auth.KindToken))
80 if err != nil {
81 return err
82 }
83
84 for _, cred := range creds {
85 login, ok := cred.GetMetadata(auth.MetaKeyLogin)
86 if !ok {
87 _, _ = fmt.Fprintf(os.Stderr, "credential %s is not tagged with a Github login\n", cred.ID().Human())
88 continue
89 }
90
91 user, err := repo.Identities().ResolveIdentityImmutableMetadata(metaKeyGithubLogin, login)
92 if entity.IsErrNotFound(err) {
93 continue
94 }
95 if err != nil {
96 return nil
97 }
98
99 if _, ok := ge.identityClient[user.Id()]; ok {
100 continue
101 }
102
103 client := buildClient(creds[0].(*auth.Token))
104 ge.identityClient[user.Id()] = client
105
106 // assign the default client and token as well
107 if ge.defaultClient == nil && login == ge.conf[confKeyDefaultLogin] {
108 ge.defaultClient = client
109 ge.defaultToken = creds[0].(*auth.Token)
110 }
111 }
112
113 if ge.defaultClient == nil {
114 return fmt.Errorf("no token found for the default login \"%s\"", ge.conf[confKeyDefaultLogin])
115 }
116
117 return nil
118}
119
120// getClientForIdentity return a githubv4 API client configured with the access token of the given identity.
121func (ge *githubExporter) getClientForIdentity(userId entity.Id) (*rateLimitHandlerClient, error) {

Callers 1

InitMethod · 0.95

Calls 12

ListFunction · 0.92
WithTargetFunction · 0.92
WithKindFunction · 0.92
IsErrNotFoundFunction · 0.92
IdentitiesMethod · 0.80
ErrorfMethod · 0.80
buildClientFunction · 0.70
GetMetadataMethod · 0.65
IDMethod · 0.65
IdMethod · 0.65
HumanMethod · 0.45

Tested by

no test coverage detected