aboutsummaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-15 15:51:16 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-15 15:51:16 +0100
commit0bb9ed9b0e6a53fd668be0c60127af78ddd061b5 (patch)
tree72efd9bdbf1ecdda60cdeaab561a5fc36b032871 /bridge
parentcfa005889a7d398ee71eac4a6d4b23a691a7ef2a (diff)
parent157e10f2e1d49748f62e210cadc088ecae9f3dfc (diff)
downloadgit-bug-0bb9ed9b0e6a53fd668be0c60127af78ddd061b5.tar.gz
Merge remote-tracking branch 'origin/master' into cheshirekow-jira
Diffstat (limited to 'bridge')
-rw-r--r--bridge/core/bridge.go20
-rw-r--r--bridge/core/interfaces.go4
-rw-r--r--bridge/github/export.go2
-rw-r--r--bridge/github/export_test.go7
-rw-r--r--bridge/github/import.go2
-rw-r--r--bridge/github/import_test.go5
-rw-r--r--bridge/gitlab/export.go2
-rw-r--r--bridge/gitlab/export_test.go7
-rw-r--r--bridge/gitlab/import.go2
-rw-r--r--bridge/gitlab/import_test.go5
-rw-r--r--bridge/launchpad/import.go2
11 files changed, 27 insertions, 31 deletions
diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go
index c72ff6b4..10f6b109 100644
--- a/bridge/core/bridge.go
+++ b/bridge/core/bridge.go
@@ -299,14 +299,14 @@ func (b *Bridge) getExporter() Exporter {
return b.exporter
}
-func (b *Bridge) ensureImportInit() error {
+func (b *Bridge) ensureImportInit(ctx context.Context) error {
if b.initImportDone {
return nil
}
importer := b.getImporter()
if importer != nil {
- err := importer.Init(b.repo, b.conf)
+ err := importer.Init(ctx, b.repo, b.conf)
if err != nil {
return err
}
@@ -316,22 +316,14 @@ func (b *Bridge) ensureImportInit() error {
return nil
}
-func (b *Bridge) ensureExportInit() error {
+func (b *Bridge) ensureExportInit(ctx context.Context) error {
if b.initExportDone {
return nil
}
- importer := b.getImporter()
- if importer != nil {
- err := importer.Init(b.repo, b.conf)
- if err != nil {
- return err
- }
- }
-
exporter := b.getExporter()
if exporter != nil {
- err := exporter.Init(b.repo, b.conf)
+ err := exporter.Init(ctx, b.repo, b.conf)
if err != nil {
return err
}
@@ -355,7 +347,7 @@ func (b *Bridge) ImportAllSince(ctx context.Context, since time.Time) (<-chan Im
return nil, err
}
- err = b.ensureImportInit()
+ err = b.ensureImportInit(ctx)
if err != nil {
return nil, err
}
@@ -409,7 +401,7 @@ func (b *Bridge) ExportAll(ctx context.Context, since time.Time) (<-chan ExportR
return nil, err
}
- err = b.ensureExportInit()
+ err = b.ensureExportInit(ctx)
if err != nil {
return nil, err
}
diff --git a/bridge/core/interfaces.go b/bridge/core/interfaces.go
index 63340a95..f20f1642 100644
--- a/bridge/core/interfaces.go
+++ b/bridge/core/interfaces.go
@@ -36,11 +36,11 @@ type BridgeImpl interface {
}
type Importer interface {
- Init(repo *cache.RepoCache, conf Configuration) error
+ Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error
ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ImportResult, error)
}
type Exporter interface {
- Init(repo *cache.RepoCache, conf Configuration) error
+ Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error
ExportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ExportResult, error)
}
diff --git a/bridge/github/export.go b/bridge/github/export.go
index 6cee4188..12b62fa6 100644
--- a/bridge/github/export.go
+++ b/bridge/github/export.go
@@ -53,7 +53,7 @@ type githubExporter struct {
}
// Init .
-func (ge *githubExporter) Init(repo *cache.RepoCache, conf core.Configuration) error {
+func (ge *githubExporter) Init(_ context.Context, repo *cache.RepoCache, conf core.Configuration) error {
ge.conf = conf
ge.identityClient = make(map[entity.Id]*githubv4.Client)
ge.cachedOperationIDs = make(map[entity.Id]string)
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go
index a25d56d7..acbd657a 100644
--- a/bridge/github/export_test.go
+++ b/bridge/github/export_test.go
@@ -185,15 +185,16 @@ func TestPushPull(t *testing.T) {
return deleteRepository(projectName, envUser, envToken)
})
+ ctx := context.Background()
+
// initialize exporter
exporter := &githubExporter{}
- err = exporter.Init(backend, core.Configuration{
+ err = exporter.Init(ctx, backend, core.Configuration{
confKeyOwner: envUser,
confKeyProject: projectName,
})
require.NoError(t, err)
- ctx := context.Background()
start := time.Now()
// export all bugs
@@ -215,7 +216,7 @@ func TestPushPull(t *testing.T) {
require.NoError(t, err)
importer := &githubImporter{}
- err = importer.Init(backend, core.Configuration{
+ err = importer.Init(ctx, backend, core.Configuration{
confKeyOwner: envUser,
confKeyProject: projectName,
})
diff --git a/bridge/github/import.go b/bridge/github/import.go
index 3267c013..b30be73a 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -29,7 +29,7 @@ type githubImporter struct {
out chan<- core.ImportResult
}
-func (gi *githubImporter) Init(repo *cache.RepoCache, conf core.Configuration) error {
+func (gi *githubImporter) Init(_ context.Context, repo *cache.RepoCache, conf core.Configuration) error {
gi.conf = conf
creds, err := auth.List(repo, auth.WithTarget(target), auth.WithKind(auth.KindToken))
diff --git a/bridge/github/import_test.go b/bridge/github/import_test.go
index 4f75f368..20b1b71e 100644
--- a/bridge/github/import_test.go
+++ b/bridge/github/import_test.go
@@ -149,14 +149,15 @@ func Test_Importer(t *testing.T) {
err = auth.Store(repo, token)
require.NoError(t, err)
+ ctx := context.Background()
+
importer := &githubImporter{}
- err = importer.Init(backend, core.Configuration{
+ err = importer.Init(ctx, backend, core.Configuration{
confKeyOwner: "MichaelMure",
confKeyProject: "git-bug-test-github-bridge",
})
require.NoError(t, err)
- ctx := context.Background()
start := time.Now()
events, err := importer.ImportAll(ctx, backend, time.Time{})
diff --git a/bridge/gitlab/export.go b/bridge/gitlab/export.go
index 156aabaa..918e6b5e 100644
--- a/bridge/gitlab/export.go
+++ b/bridge/gitlab/export.go
@@ -38,7 +38,7 @@ type gitlabExporter struct {
}
// Init .
-func (ge *gitlabExporter) Init(repo *cache.RepoCache, conf core.Configuration) error {
+func (ge *gitlabExporter) Init(_ context.Context, repo *cache.RepoCache, conf core.Configuration) error {
ge.conf = conf
ge.identityClient = make(map[entity.Id]*gitlab.Client)
ge.cachedOperationIDs = make(map[string]string)
diff --git a/bridge/gitlab/export_test.go b/bridge/gitlab/export_test.go
index 5fbb392f..d704ac3b 100644
--- a/bridge/gitlab/export_test.go
+++ b/bridge/gitlab/export_test.go
@@ -191,15 +191,16 @@ func TestPushPull(t *testing.T) {
return deleteRepository(context.TODO(), projectID, token)
})
+ ctx := context.Background()
+
// initialize exporter
exporter := &gitlabExporter{}
- err = exporter.Init(backend, core.Configuration{
+ err = exporter.Init(ctx, backend, core.Configuration{
confKeyProjectID: strconv.Itoa(projectID),
confKeyGitlabBaseUrl: defaultBaseURL,
})
require.NoError(t, err)
- ctx := context.Background()
start := time.Now()
// export all bugs
@@ -221,7 +222,7 @@ func TestPushPull(t *testing.T) {
require.NoError(t, err)
importer := &gitlabImporter{}
- err = importer.Init(backend, core.Configuration{
+ err = importer.Init(ctx, backend, core.Configuration{
confKeyProjectID: strconv.Itoa(projectID),
confKeyGitlabBaseUrl: defaultBaseURL,
})
diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go
index c8d74bef..5faf5c48 100644
--- a/bridge/gitlab/import.go
+++ b/bridge/gitlab/import.go
@@ -30,7 +30,7 @@ type gitlabImporter struct {
out chan<- core.ImportResult
}
-func (gi *gitlabImporter) Init(repo *cache.RepoCache, conf core.Configuration) error {
+func (gi *gitlabImporter) Init(_ context.Context, repo *cache.RepoCache, conf core.Configuration) error {
gi.conf = conf
creds, err := auth.List(repo,
diff --git a/bridge/gitlab/import_test.go b/bridge/gitlab/import_test.go
index b70b291e..ea7acc18 100644
--- a/bridge/gitlab/import_test.go
+++ b/bridge/gitlab/import_test.go
@@ -104,14 +104,15 @@ func TestImport(t *testing.T) {
err = auth.Store(repo, token)
require.NoError(t, err)
+ ctx := context.Background()
+
importer := &gitlabImporter{}
- err = importer.Init(backend, core.Configuration{
+ err = importer.Init(ctx, backend, core.Configuration{
confKeyProjectID: projectID,
confKeyGitlabBaseUrl: defaultBaseURL,
})
require.NoError(t, err)
- ctx := context.Background()
start := time.Now()
events, err := importer.ImportAll(ctx, backend, time.Time{})
diff --git a/bridge/launchpad/import.go b/bridge/launchpad/import.go
index 5bca8e63..dfcbb95e 100644
--- a/bridge/launchpad/import.go
+++ b/bridge/launchpad/import.go
@@ -15,7 +15,7 @@ type launchpadImporter struct {
conf core.Configuration
}
-func (li *launchpadImporter) Init(repo *cache.RepoCache, conf core.Configuration) error {
+func (li *launchpadImporter) Init(_ context.Context, repo *cache.RepoCache, conf core.Configuration) error {
li.conf = conf
return nil
}