gitlab.go

 1package gitlab
 2
 3import (
 4	"time"
 5
 6	"github.com/xanzy/go-gitlab"
 7
 8	"github.com/MichaelMure/git-bug/bridge/core"
 9)
10
11const (
12	target      = "gitlab"
13	gitlabV4Url = "https://gitlab.com/api/v4"
14
15	keyProjectID   = "project-id"
16	keyGitlabId    = "gitlab-id"
17	keyGitlabUrl   = "gitlab-url"
18	keyGitlabLogin = "gitlab-login"
19	keyToken       = "token"
20	keyTarget      = "target"
21	keyOrigin      = "origin"
22
23	defaultTimeout = 60 * time.Second
24)
25
26func init() {
27	core.Register(&Gitlab{})
28}
29
30type Gitlab struct{}
31
32func (*Gitlab) Target() string {
33	return target
34}
35
36func (*Gitlab) NewImporter() core.Importer {
37	return &gitlabImporter{}
38}
39
40func (*Gitlab) NewExporter() core.Exporter {
41	return &gitlabExporter{}
42}
43
44func buildClient(token string) *gitlab.Client {
45	return gitlab.NewClient(nil, token)
46}
47
48func buildClientFromUsernameAndPassword(username, password string) (*gitlab.Client, error) {
49	return gitlab.NewBasicAuthClient(nil, "https://gitlab.com", username, password)
50
51}