(repo *cache.RepoCache)
| 76 | } |
| 77 | |
| 78 | func (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. |
| 121 | func (ge *githubExporter) getClientForIdentity(userId entity.Id) (*rateLimitHandlerClient, error) { |
no test coverage detected