From 8fb6ea0d9578bc1cf94649091ddd03d038dddc47 Mon Sep 17 00:00:00 2001 From: Alexander Scharinger Date: Fri, 9 Apr 2021 15:56:03 +0200 Subject: Github brdige: move credential loading and client creation back Reason: failing integration tests --- bridge/github/import.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'bridge') 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 = "" 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 -- cgit