(repo *cache.RepoCache, baseURL string)
| 57 | } |
| 58 | |
| 59 | func (ge *gitlabExporter) cacheAllClient(repo *cache.RepoCache, baseURL string) error { |
| 60 | creds, err := auth.List(repo, |
| 61 | auth.WithTarget(target), |
| 62 | auth.WithKind(auth.KindToken), |
| 63 | auth.WithMeta(auth.MetaKeyBaseURL, baseURL), |
| 64 | ) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | |
| 69 | for _, cred := range creds { |
| 70 | login, ok := cred.GetMetadata(auth.MetaKeyLogin) |
| 71 | if !ok { |
| 72 | _, _ = fmt.Fprintf(os.Stderr, "credential %s is not tagged with a Gitlab login\n", cred.ID().Human()) |
| 73 | continue |
| 74 | } |
| 75 | |
| 76 | user, err := repo.Identities().ResolveIdentityImmutableMetadata(metaKeyGitlabLogin, login) |
| 77 | if entity.IsErrNotFound(err) { |
| 78 | continue |
| 79 | } |
| 80 | if err != nil { |
| 81 | return nil |
| 82 | } |
| 83 | |
| 84 | if _, ok := ge.identityClient[user.Id()]; !ok { |
| 85 | client, err := buildClient(ge.conf[confKeyGitlabBaseUrl], creds[0].(*auth.Token)) |
| 86 | if err != nil { |
| 87 | return err |
| 88 | } |
| 89 | ge.identityClient[user.Id()] = client |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | // getIdentityClient return a gitlab v4 API client configured with the access token of the given identity. |
| 97 | func (ge *gitlabExporter) getIdentityClient(userId entity.Id) (*gitlab.Client, error) { |
no test coverage detected