aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab
diff options
context:
space:
mode:
authorAlexander Scharinger <rng.dynamics@gmail.com>2021-04-08 22:48:31 +0200
committerAlexander Scharinger <rng.dynamics@gmail.com>2021-04-08 22:48:31 +0200
commit3d14e2e67c4985c429471ea6643f013ade2c2692 (patch)
treedb4938de27b1240220630d6723e321a060866542 /bridge/gitlab
parentb2e98ef07f3083db303099fbcedbd98a33ad1164 (diff)
downloadgit-bug-3d14e2e67c4985c429471ea6643f013ade2c2692.tar.gz
Bridges: move credential loading and client creation
Gitlab and Jira bridge: move credential loading and client creation from `Init` to `ImportAll` in order to harmonize the behaviour of the different bridges.
Diffstat (limited to 'bridge/gitlab')
-rw-r--r--bridge/gitlab/import.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go
index cf4f0039..93c6a1a9 100644
--- a/bridge/gitlab/import.go
+++ b/bridge/gitlab/import.go
@@ -33,32 +33,29 @@ type gitlabImporter struct {
func (gi *gitlabImporter) Init(_ context.Context, repo *cache.RepoCache, conf core.Configuration) error {
gi.conf = conf
+ return nil
+}
+// ImportAll iterate over all the configured repository issues (notes) and ensure the creation
+// of the missing issues / comments / label events / title changes ...
+func (gi *gitlabImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ImportResult, error) {
creds, err := auth.List(repo,
auth.WithTarget(target),
auth.WithKind(auth.KindToken),
- auth.WithMeta(auth.MetaKeyBaseURL, conf[confKeyGitlabBaseUrl]),
- auth.WithMeta(auth.MetaKeyLogin, conf[confKeyDefaultLogin]),
+ auth.WithMeta(auth.MetaKeyBaseURL, gi.conf[confKeyGitlabBaseUrl]),
+ auth.WithMeta(auth.MetaKeyLogin, gi.conf[confKeyDefaultLogin]),
)
if err != nil {
- return err
+ return nil, err
}
-
if len(creds) == 0 {
- return ErrMissingIdentityToken
+ return nil, ErrMissingIdentityToken
}
-
- gi.client, err = buildClient(conf[confKeyGitlabBaseUrl], creds[0].(*auth.Token))
+ gi.client, err = buildClient(gi.conf[confKeyGitlabBaseUrl], creds[0].(*auth.Token))
if err != nil {
- return err
+ return nil, err
}
- return nil
-}
-
-// ImportAll iterate over all the configured repository issues (notes) and ensure the creation
-// of the missing issues / comments / label events / title changes ...
-func (gi *gitlabImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ImportResult, error) {
gi.iterator = iterator.NewIterator(ctx, gi.client, 10, gi.conf[confKeyProjectID], since)
out := make(chan core.ImportResult)
gi.out = out