diff options
author | Michael Muré <batolettre@gmail.com> | 2019-11-19 19:25:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-19 19:25:43 +0100 |
commit | e01cefff9826589b77bd34464301f196112d68f7 (patch) | |
tree | 44b32dfc7727c957ce7e364c6dc631ba8d76a4a5 /bridge/launchpad | |
parent | 67c82f4a2d683e746df5f8af9e0725acd252d29d (diff) | |
parent | 8ffe2a9b03f5d489e12d2d4d2677bbe67a1b53d7 (diff) | |
download | git-bug-e01cefff9826589b77bd34464301f196112d68f7.tar.gz |
Merge pull request #247 from MichaelMure/bridge-origin
bridge: move keyOrigin to core package
Diffstat (limited to 'bridge/launchpad')
-rw-r--r-- | bridge/launchpad/config.go | 6 | ||||
-rw-r--r-- | bridge/launchpad/import.go | 19 |
2 files changed, 14 insertions, 11 deletions
diff --git a/bridge/launchpad/config.go b/bridge/launchpad/config.go index 6669d0fa..be81c0ac 100644 --- a/bridge/launchpad/config.go +++ b/bridge/launchpad/config.go @@ -62,7 +62,7 @@ func (l *Launchpad) Configure(repo repository.RepoCommon, params core.BridgePara } conf[keyProject] = project - conf[core.KeyTarget] = target + conf[core.ConfigKeyTarget] = target err = l.ValidateConfig(conf) if err != nil { @@ -77,8 +77,8 @@ func (*Launchpad) ValidateConfig(conf core.Configuration) error { return fmt.Errorf("missing %s key", keyProject) } - if _, ok := conf[core.KeyTarget]; !ok { - return fmt.Errorf("missing %s key", core.KeyTarget) + if _, ok := conf[core.ConfigKeyTarget]; !ok { + return fmt.Errorf("missing %s key", core.ConfigKeyTarget) } return nil diff --git a/bridge/launchpad/import.go b/bridge/launchpad/import.go index 7f50d898..178945b6 100644 --- a/bridge/launchpad/import.go +++ b/bridge/launchpad/import.go @@ -20,12 +20,14 @@ func (li *launchpadImporter) Init(conf core.Configuration) error { return nil } -const keyLaunchpadID = "launchpad-id" -const keyLaunchpadLogin = "launchpad-login" +const ( + metaKeyLaunchpadID = "launchpad-id" + metaKeyLaunchpadLogin = "launchpad-login" +) func (li *launchpadImporter) ensurePerson(repo *cache.RepoCache, owner LPPerson) (*cache.IdentityCache, error) { // Look first in the cache - i, err := repo.ResolveIdentityImmutableMetadata(keyLaunchpadLogin, owner.Login) + i, err := repo.ResolveIdentityImmutableMetadata(metaKeyLaunchpadLogin, owner.Login) if err == nil { return i, nil } @@ -39,7 +41,7 @@ func (li *launchpadImporter) ensurePerson(repo *cache.RepoCache, owner LPPerson) owner.Login, "", map[string]string{ - keyLaunchpadLogin: owner.Login, + metaKeyLaunchpadLogin: owner.Login, }, ) } @@ -65,7 +67,7 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach return default: lpBugID := fmt.Sprintf("%d", lpBug.ID) - b, err := repo.ResolveBugCreateMetadata(keyLaunchpadID, lpBugID) + b, err := repo.ResolveBugCreateMetadata(metaKeyLaunchpadID, lpBugID) if err != nil && err != bug.ErrBugNotExist { out <- core.NewImportError(err, entity.Id(lpBugID)) return @@ -86,7 +88,8 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach lpBug.Description, nil, map[string]string{ - keyLaunchpadID: lpBugID, + core.MetaKeyOrigin: target, + metaKeyLaunchpadID: lpBugID, }, ) if err != nil { @@ -108,7 +111,7 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach // The Launchpad API returns the bug description as the first // comment, so skip it. for _, lpMessage := range lpBug.Messages[1:] { - _, err := b.ResolveOperationWithMetadata(keyLaunchpadID, lpMessage.ID) + _, err := b.ResolveOperationWithMetadata(metaKeyLaunchpadID, lpMessage.ID) if err != nil && err != cache.ErrNoMatchingOp { out <- core.NewImportError(err, entity.Id(lpMessage.ID)) return @@ -136,7 +139,7 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach lpMessage.Content, nil, map[string]string{ - keyLaunchpadID: lpMessage.ID, + metaKeyLaunchpadID: lpMessage.ID, }) if err != nil { out <- core.NewImportError(err, op.Id()) |