2018-10-01 22:47:12 +03:00
|
|
|
// Package github contains the Github bridge implementation
|
2018-09-21 13:54:48 +03:00
|
|
|
package github
|
|
|
|
|
2018-09-21 19:23:46 +03:00
|
|
|
import (
|
2018-09-24 20:22:32 +03:00
|
|
|
"context"
|
2018-09-24 16:25:15 +03:00
|
|
|
|
2018-09-21 19:23:46 +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-21 19:23:46 +03:00
|
|
|
)
|
|
|
|
|
2018-09-24 16:25:15 +03:00
|
|
|
func init() {
|
|
|
|
core.Register(&Github{})
|
|
|
|
}
|
|
|
|
|
2018-09-21 19:23:46 +03:00
|
|
|
type Github struct{}
|
|
|
|
|
2018-09-24 16:25:15 +03:00
|
|
|
func (*Github) Target() string {
|
2018-09-21 19:23:46 +03:00
|
|
|
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-21 19:23:46 +03:00
|
|
|
|
2018-09-24 20:22:32 +03:00
|
|
|
return githubv4.NewClient(httpClient)
|
2018-09-21 13:54:48 +03:00
|
|
|
}
|