git-bug/bridge/github/github.go

38 lines
686 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
"github.com/MichaelMure/git-bug/bridge/core"
2018-09-24 20:22:32 +03:00
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)
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 "github"
}
func (*Github) Importer() core.Importer {
return &githubImporter{}
}
func (*Github) Exporter() core.Exporter {
return nil
}
2018-09-24 20:22:32 +03:00
func buildClient(conf core.Configuration) *githubv4.Client {
src := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: conf[keyToken]},
)
httpClient := oauth2.NewClient(context.TODO(), src)
2018-09-24 20:22:32 +03:00
return githubv4.NewClient(httpClient)
}