aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github
diff options
context:
space:
mode:
authorAlexander Scharinger <rng.dynamics@gmail.com>2021-04-09 15:56:03 +0200
committerAlexander Scharinger <rng.dynamics@gmail.com>2021-04-09 15:56:32 +0200
commit8fb6ea0d9578bc1cf94649091ddd03d038dddc47 (patch)
tree77c89ecb03b92e9cd016fc3b98f4d502374f5570 /bridge/github
parentbe24cdfec43fe9adcd937ed4bdac28250e214ec6 (diff)
downloadgit-bug-8fb6ea0d9578bc1cf94649091ddd03d038dddc47.tar.gz
Github brdige: move credential loading and client creation back
Reason: failing integration tests
Diffstat (limited to 'bridge/github')
-rw-r--r--bridge/github/import.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/bridge/github/import.go b/bridge/github/import.go
index 306ef087..bf43a877 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -21,6 +21,9 @@ const EmptyTitlePlaceholder = "<empty string>"
type githubImporter struct {
conf core.Configuration
+ // default client
+ client *githubv4.Client
+
// mediator to access the Github API
mediator *importMediator
@@ -28,27 +31,28 @@ type githubImporter struct {
out chan<- core.ImportResult
}
-func (gi *githubImporter) Init(_ context.Context, _ *cache.RepoCache, conf core.Configuration) error {
+func (gi *githubImporter) Init(_ context.Context, repo *cache.RepoCache, conf core.Configuration) error {
gi.conf = conf
- return nil
-}
-
-// ImportAll iterate over all the configured repository issues and ensure the creation of the
-// missing issues / timeline items / edits / label events ...
-func (gi *githubImporter) 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.MetaKeyLogin, gi.conf[confKeyDefaultLogin]),
+ auth.WithMeta(auth.MetaKeyLogin, conf[confKeyDefaultLogin]),
)
if err != nil {
- return nil, err
+ return err
}
if len(creds) <= 0 {
- return nil, ErrMissingIdentityToken
+ return ErrMissingIdentityToken
}
- client := buildClient(creds[0].(*auth.Token))
- gi.mediator = NewImportMediator(ctx, client, gi.conf[confKeyOwner], gi.conf[confKeyProject], since)
+ gi.client = buildClient(creds[0].(*auth.Token))
+
+ return nil
+}
+
+// ImportAll iterate over all the configured repository issues and ensure the creation of the
+// missing issues / timeline items / edits / label events ...
+func (gi *githubImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ImportResult, error) {
+ gi.mediator = NewImportMediator(ctx, gi.client, gi.conf[confKeyOwner], gi.conf[confKeyProject], since)
out := make(chan core.ImportResult)
gi.out = out