diff --git a/bridge/core/bridge.go b/bridge/core/bridge.go index c72ff6b4150fb8ae6ce6c126bd44d6672d212cc0..10f6b109c32cf9d2f3021ee2608a9f33b115596b 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 63340a950b4e8913f8501356a028741cfc690444..f20f16427dc62f23c7e2d248cd4e871983392a4a 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 6cee41885fbb36fc0009d4daa074d370aca9c372..12b62fa6af3b97f035e40f466b1676a04c6720a6 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 a25d56d766e92323b72b950001594cd2cd1532dd..acbd657af76ce23bb84f15f8644e6a851d63b0c8 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 3267c0132894da80d50b418554f3a3b8ae9add39..b30be73a16bb37a0bedebf34d2e29928025aba6c 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 4f75f3684031d3f406093397bec17fc45b9526de..20b1b71e841e4b927cf4bda2bc1a224a38bf7c30 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 156aabaa6f1ed04b52d8dba7a0f5b3f2b7726875..918e6b5eb7420088a9b74d5f72bc3a085fe74f7d 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 5fbb392f14ebf62a9ec2e2742cdb190123101582..d704ac3b939804fb5f64b9f1c2a4387fa8ed5d28 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 c8d74bef7dd65525dd29f6618fa622d4ffdf6325..5faf5c48bf5927142f1f40307343c4052901c0c5 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 b70b291e1ccba07bae6387325bc41babcbe04e24..ea7acc18658b708d6a5cae6a17c10ade9860a7ff 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 5bca8e63db73c7bf5a44a1c887bb921f414c0ffb..dfcbb95e7cfb956d07203fd541ab171b6ee7477c 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 } diff --git a/identity/bare.go b/identity/bare.go index a02ec790bb29e1825eb237b96f2a69a8c8050ec5..58c278bebffbda148bc59d27f49912661d08eebf 100644 --- a/identity/bare.go +++ b/identity/bare.go @@ -21,6 +21,8 @@ var _ entity.Interface = &Bare{} // // in particular, this identity is designed to be compatible with the handling of // identities in the early version of git-bug. +// Deprecated: legacy identity for compat, might make sense to ditch entirely for +// simplicity but that would be a breaking change. type Bare struct { id entity.Id name string