aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github/github.go
blob: 176bdd84c1c02299d6617ab61732a9a66c77f1f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package github contains the Github bridge implementation
package github

import (
	"context"

	"github.com/shurcooL/githubv4"
	"golang.org/x/oauth2"

	"github.com/MichaelMure/git-bug/bridge/core"
)

func init() {
	core.Register(&Github{})
}

type Github struct{}

func (*Github) Target() string {
	return target
}

func (*Github) NewImporter() core.Importer {
	return &githubImporter{}
}

func (*Github) NewExporter() core.Exporter {
	return &githubExporter{}
}

func buildClient(token string) *githubv4.Client {
	src := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: token},
	)
	httpClient := oauth2.NewClient(context.TODO(), src)

	return githubv4.NewClient(httpClient)
}