aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/gitlab')
-rw-r--r--bridge/gitlab/config.go6
-rw-r--r--bridge/gitlab/export.go18
-rw-r--r--bridge/gitlab/export_test.go10
-rw-r--r--bridge/gitlab/gitlab.go8
-rw-r--r--bridge/gitlab/import.go34
-rw-r--r--bridge/gitlab/import_test.go2
6 files changed, 39 insertions, 39 deletions
diff --git a/bridge/gitlab/config.go b/bridge/gitlab/config.go
index a673af8c..f2e667a8 100644
--- a/bridge/gitlab/config.go
+++ b/bridge/gitlab/config.go
@@ -80,7 +80,7 @@ func (g *Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams)
conf[keyProjectID] = strconv.Itoa(id)
conf[keyToken] = token
- conf[core.KeyTarget] = target
+ conf[core.ConfigKeyTarget] = target
err = g.ValidateConfig(conf)
if err != nil {
@@ -91,8 +91,8 @@ func (g *Gitlab) Configure(repo repository.RepoCommon, params core.BridgeParams)
}
func (g *Gitlab) ValidateConfig(conf core.Configuration) error {
- if v, ok := conf[core.KeyTarget]; !ok {
- return fmt.Errorf("missing %s key", core.KeyTarget)
+ if v, ok := conf[core.ConfigKeyTarget]; !ok {
+ return fmt.Errorf("missing %s key", core.ConfigKeyTarget)
} else if v != target {
return fmt.Errorf("unexpected target name: %v", v)
}
diff --git a/bridge/gitlab/export.go b/bridge/gitlab/export.go
index 251d720a..44778b44 100644
--- a/bridge/gitlab/export.go
+++ b/bridge/gitlab/export.go
@@ -141,7 +141,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc
// from Gitlab) and we do not have the token of the bug author, there is nothing we can do.
// skip bug if origin is not allowed
- origin, ok := snapshot.GetCreateMetadata(core.KeyOrigin)
+ origin, ok := snapshot.GetCreateMetadata(core.MetaKeyOrigin)
if ok && origin != target {
out <- core.NewExportNothing(b.Id(), fmt.Sprintf("issue tagged with origin: %s", origin))
return
@@ -152,9 +152,9 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc
author := snapshot.Author
// get gitlab bug ID
- gitlabID, ok := snapshot.GetCreateMetadata(keyGitlabId)
+ gitlabID, ok := snapshot.GetCreateMetadata(metaKeyGitlabId)
if ok {
- projectID, ok := snapshot.GetCreateMetadata(keyGitlabProject)
+ projectID, ok := snapshot.GetCreateMetadata(metaKeyGitlabProject)
if !ok {
err := fmt.Errorf("expected to find gitlab project id")
out <- core.NewExportError(err, b.Id())
@@ -199,9 +199,9 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc
_, err = b.SetMetadata(
createOp.Id(),
map[string]string{
- keyGitlabId: idString,
- keyGitlabUrl: url,
- keyGitlabProject: ge.repositoryID,
+ metaKeyGitlabId: idString,
+ metaKeyGitlabUrl: url,
+ metaKeyGitlabProject: ge.repositoryID,
},
)
if err != nil {
@@ -235,7 +235,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc
// ignore operations already existing in gitlab (due to import or export)
// cache the ID of already exported or imported issues and events from Gitlab
- if id, ok := op.GetMetadata(keyGitlabId); ok {
+ if id, ok := op.GetMetadata(metaKeyGitlabId); ok {
ge.cachedOperationIDs[op.Id().String()] = id
out <- core.NewExportNothing(op.Id(), "already exported operation")
continue
@@ -378,8 +378,8 @@ func markOperationAsExported(b *cache.BugCache, target entity.Id, gitlabID, gitl
_, err := b.SetMetadata(
target,
map[string]string{
- keyGitlabId: gitlabID,
- keyGitlabUrl: gitlabURL,
+ metaKeyGitlabId: gitlabID,
+ metaKeyGitlabUrl: gitlabURL,
},
)
diff --git a/bridge/gitlab/export_test.go b/bridge/gitlab/export_test.go
index 02e06efd..46c8c494 100644
--- a/bridge/gitlab/export_test.go
+++ b/bridge/gitlab/export_test.go
@@ -236,27 +236,27 @@ func TestPushPull(t *testing.T) {
for _, op := range tt.bug.Snapshot().Operations {
// Check if the originals operations (*not* SetMetadata) are tagged properly
if _, ok := op.(*bug.SetMetadataOperation); !ok {
- _, haveIDMetadata := op.GetMetadata(keyGitlabId)
+ _, haveIDMetadata := op.GetMetadata(metaKeyGitlabId)
require.True(t, haveIDMetadata)
- _, haveURLMetada := op.GetMetadata(keyGitlabUrl)
+ _, haveURLMetada := op.GetMetadata(metaKeyGitlabUrl)
require.True(t, haveURLMetada)
}
}
// get bug gitlab ID
- bugGitlabID, ok := tt.bug.Snapshot().GetCreateMetadata(keyGitlabId)
+ bugGitlabID, ok := tt.bug.Snapshot().GetCreateMetadata(metaKeyGitlabId)
require.True(t, ok)
// retrieve bug from backendTwo
- importedBug, err := backendTwo.ResolveBugCreateMetadata(keyGitlabId, bugGitlabID)
+ importedBug, err := backendTwo.ResolveBugCreateMetadata(metaKeyGitlabId, bugGitlabID)
require.NoError(t, err)
// verify bug have same number of original operations
require.Len(t, importedBug.Snapshot().Operations, tt.numOpImp)
// verify bugs are taged with origin=gitlab
- issueOrigin, ok := importedBug.Snapshot().GetCreateMetadata(core.KeyOrigin)
+ issueOrigin, ok := importedBug.Snapshot().GetCreateMetadata(core.MetaKeyOrigin)
require.True(t, ok)
require.Equal(t, issueOrigin, target)
diff --git a/bridge/gitlab/gitlab.go b/bridge/gitlab/gitlab.go
index f4b980ac..7e5c37cc 100644
--- a/bridge/gitlab/gitlab.go
+++ b/bridge/gitlab/gitlab.go
@@ -12,10 +12,10 @@ import (
const (
target = "gitlab"
- keyGitlabId = "gitlab-id"
- keyGitlabUrl = "gitlab-url"
- keyGitlabLogin = "gitlab-login"
- keyGitlabProject = "gitlab-project-id"
+ metaKeyGitlabId = "gitlab-id"
+ metaKeyGitlabUrl = "gitlab-url"
+ metaKeyGitlabLogin = "gitlab-login"
+ metaKeyGitlabProject = "gitlab-project-id"
keyProjectID = "project-id"
keyToken = "token"
diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go
index e2015773..e92067af 100644
--- a/bridge/gitlab/import.go
+++ b/bridge/gitlab/import.go
@@ -97,7 +97,7 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue
}
// resolve bug
- b, err := repo.ResolveBugCreateMetadata(keyGitlabUrl, issue.WebURL)
+ b, err := repo.ResolveBugCreateMetadata(metaKeyGitlabUrl, issue.WebURL)
if err == nil {
gi.out <- core.NewImportNothing("", "bug already imported")
return b, nil
@@ -120,10 +120,10 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue
cleanText,
nil,
map[string]string{
- core.KeyOrigin: target,
- keyGitlabId: parseID(issue.IID),
- keyGitlabUrl: issue.WebURL,
- keyGitlabProject: gi.conf[keyProjectID],
+ core.MetaKeyOrigin: target,
+ metaKeyGitlabId: parseID(issue.IID),
+ metaKeyGitlabUrl: issue.WebURL,
+ metaKeyGitlabProject: gi.conf[keyProjectID],
},
)
@@ -140,7 +140,7 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue
func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, note *gitlab.Note) error {
gitlabID := parseID(note.ID)
- id, errResolve := b.ResolveOperationWithMetadata(keyGitlabId, gitlabID)
+ id, errResolve := b.ResolveOperationWithMetadata(metaKeyGitlabId, gitlabID)
if errResolve != nil && errResolve != cache.ErrNoMatchingOp {
return errResolve
}
@@ -162,7 +162,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
author,
note.CreatedAt.Unix(),
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -180,7 +180,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
author,
note.CreatedAt.Unix(),
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -204,7 +204,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
firstComment.Id(),
issue.Description,
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -230,7 +230,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
cleanText,
nil,
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -278,7 +278,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
note.CreatedAt.Unix(),
body,
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -311,7 +311,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
}
func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCache, labelEvent *gitlab.LabelEvent) error {
- _, err := b.ResolveOperationWithMetadata(keyGitlabId, parseID(labelEvent.ID))
+ _, err := b.ResolveOperationWithMetadata(metaKeyGitlabId, parseID(labelEvent.ID))
if err != cache.ErrNoMatchingOp {
return err
}
@@ -330,7 +330,7 @@ func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCa
[]string{labelEvent.Label.Name},
nil,
map[string]string{
- keyGitlabId: parseID(labelEvent.ID),
+ metaKeyGitlabId: parseID(labelEvent.ID),
},
)
@@ -341,7 +341,7 @@ func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCa
nil,
[]string{labelEvent.Label.Name},
map[string]string{
- keyGitlabId: parseID(labelEvent.ID),
+ metaKeyGitlabId: parseID(labelEvent.ID),
},
)
@@ -354,7 +354,7 @@ func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCa
func (gi *gitlabImporter) ensurePerson(repo *cache.RepoCache, id int) (*cache.IdentityCache, error) {
// Look first in the cache
- i, err := repo.ResolveIdentityImmutableMetadata(keyGitlabId, strconv.Itoa(id))
+ i, err := repo.ResolveIdentityImmutableMetadata(metaKeyGitlabId, strconv.Itoa(id))
if err == nil {
return i, nil
}
@@ -376,8 +376,8 @@ func (gi *gitlabImporter) ensurePerson(repo *cache.RepoCache, id int) (*cache.Id
user.AvatarURL,
map[string]string{
// because Gitlab
- keyGitlabId: strconv.Itoa(id),
- keyGitlabLogin: user.Username,
+ metaKeyGitlabId: strconv.Itoa(id),
+ metaKeyGitlabLogin: user.Username,
},
)
if err != nil {
diff --git a/bridge/gitlab/import_test.go b/bridge/gitlab/import_test.go
index a6fd8524..8e596349 100644
--- a/bridge/gitlab/import_test.go
+++ b/bridge/gitlab/import_test.go
@@ -116,7 +116,7 @@ func TestImport(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- b, err := backend.ResolveBugCreateMetadata(keyGitlabUrl, tt.url)
+ b, err := backend.ResolveBugCreateMetadata(metaKeyGitlabUrl, tt.url)
require.NoError(t, err)
ops := b.Snapshot().Operations