git-bug/bridge/github/github.go

39 lines
685 B
Go
Raw Normal View History

2018-10-01 22:47:12 +03:00
// Package github contains the Github bridge implementation
package github
import (
2018-09-24 20:22:32 +03:00
"context"
2018-09-24 16:25:15 +03:00
2018-09-24 20:22:32 +03:00
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
"github.com/MichaelMure/git-bug/bridge/core"
)
2018-09-24 16:25:15 +03:00
func init() {
core.Register(&Github{})
}
type Github struct{}
2018-09-24 16:25:15 +03:00
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 {
2018-09-24 20:22:32 +03:00
src := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
2018-09-24 20:22:32 +03:00
)
httpClient := oauth2.NewClient(context.TODO(), src)
2018-09-24 20:22:32 +03:00
return githubv4.NewClient(httpClient)
}