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

Method cacheAllClient

bridge/gitlab/export.go:59–94  ·  view source on GitHub ↗
(repo *cache.RepoCache, baseURL string)

Source from the content-addressed store, hash-verified

57}
58
59func (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.
97func (ge *gitlabExporter) getIdentityClient(userId entity.Id) (*gitlab.Client, error) {

Callers 1

InitMethod · 0.95

Calls 12

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

Tested by

no test coverage detected