aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/jira
diff options
context:
space:
mode:
authorAlexander Scharinger <rng.dynamics@gmail.com>2021-04-09 15:41:27 +0200
committerAlexander Scharinger <rng.dynamics@gmail.com>2021-04-09 15:41:27 +0200
commitbe24cdfec43fe9adcd937ed4bdac28250e214ec6 (patch)
treee5cd4234ac6c34467094be9f70e581d4563a5273 /bridge/jira
parent10a80f188861157b5f58bb700fe7f1c84bb4da95 (diff)
downloadgit-bug-be24cdfec43fe9adcd937ed4bdac28250e214ec6.tar.gz
Revert "Bridges: move credential loading and client creation"
This reverts commit 3d14e2e67c4985c429471ea6643f013ade2c2692.
Diffstat (limited to 'bridge/jira')
-rw-r--r--bridge/jira/import.go52
1 files changed, 25 insertions, 27 deletions
diff --git a/bridge/jira/import.go b/bridge/jira/import.go
index f9daadd8..00148bb6 100644
--- a/bridge/jira/import.go
+++ b/bridge/jira/import.go
@@ -34,12 +34,6 @@ type jiraImporter struct {
// Init .
func (ji *jiraImporter) Init(ctx context.Context, repo *cache.RepoCache, conf core.Configuration) error {
ji.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 (ji *jiraImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ImportResult, error) {
var cred auth.Credential
@@ -47,40 +41,44 @@ func (ji *jiraImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, si
creds, err := auth.List(repo,
auth.WithTarget(target),
auth.WithKind(auth.KindLoginPassword),
- auth.WithMeta(auth.MetaKeyBaseURL, ji.conf[confKeyBaseUrl]),
- auth.WithMeta(auth.MetaKeyLogin, ji.conf[confKeyDefaultLogin]),
+ auth.WithMeta(auth.MetaKeyBaseURL, conf[confKeyBaseUrl]),
+ auth.WithMeta(auth.MetaKeyLogin, conf[confKeyDefaultLogin]),
)
if err != nil {
- return nil, err
+ return err
}
if len(creds) > 0 {
cred = creds[0]
- } else {
- creds, err = auth.List(repo,
- auth.WithTarget(target),
- auth.WithKind(auth.KindLogin),
- auth.WithMeta(auth.MetaKeyBaseURL, ji.conf[confKeyBaseUrl]),
- auth.WithMeta(auth.MetaKeyLogin, ji.conf[confKeyDefaultLogin]),
- )
- if err != nil {
- return nil, err
- }
- if len(creds) > 0 {
- cred = creds[0]
- }
+ goto end
}
+ creds, err = auth.List(repo,
+ auth.WithTarget(target),
+ auth.WithKind(auth.KindLogin),
+ auth.WithMeta(auth.MetaKeyBaseURL, conf[confKeyBaseUrl]),
+ auth.WithMeta(auth.MetaKeyLogin, conf[confKeyDefaultLogin]),
+ )
+ if err != nil {
+ return err
+ }
+ if len(creds) > 0 {
+ cred = creds[0]
+ }
+
+end:
if cred == nil {
- return nil, fmt.Errorf("no credential for this bridge")
+ return fmt.Errorf("no credential for this bridge")
}
// TODO(josh)[da52062]: Validate token and if it is expired then prompt for
// credentials and generate a new one
- ji.client, err = buildClient(ctx, ji.conf[confKeyBaseUrl], ji.conf[confKeyCredentialType], cred)
- if err != nil {
- return nil, err
- }
+ ji.client, err = buildClient(ctx, conf[confKeyBaseUrl], conf[confKeyCredentialType], cred)
+ return err
+}
+// ImportAll iterate over all the configured repository issues and ensure the
+// creation of the missing issues / timeline items / edits / label events ...
+func (ji *jiraImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ImportResult, error) {
sinceStr := since.Format("2006-01-02 15:04")
project := ji.conf[confKeyProject]