mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Clean up the GitHub module's API credentials loading
This commit is contained in:
parent
c7223843f0
commit
0a019ff836
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
|
||||
ghb "github.com/google/go-github/github"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
@ -22,14 +23,12 @@ type GithubRepo struct {
|
||||
|
||||
func NewGithubRepo(name, owner string) *GithubRepo {
|
||||
repo := GithubRepo{
|
||||
apiKey: os.Getenv("WTF_GITHUB_TOKEN"),
|
||||
baseURL: os.Getenv("WTF_GITHUB_BASE_URL"),
|
||||
uploadURL: os.Getenv("WTF_GITHUB_UPLOAD_URL"),
|
||||
|
||||
Name: name,
|
||||
Owner: owner,
|
||||
}
|
||||
|
||||
repo.loadAPICredentials()
|
||||
|
||||
return &repo
|
||||
}
|
||||
|
||||
@ -91,6 +90,23 @@ func (repo *GithubRepo) githubClient() (*ghb.Client, error) {
|
||||
return ghb.NewClient(oauthClient), nil
|
||||
}
|
||||
|
||||
func (repo *GithubRepo) loadAPICredentials() {
|
||||
repo.apiKey = wtf.Config.UString(
|
||||
"wtf.mods.github.apiKey",
|
||||
os.Getenv("WTF_GITHUB_TOKEN"),
|
||||
)
|
||||
|
||||
repo.baseURL = wtf.Config.UString(
|
||||
"wtf.mods.github.baseURL",
|
||||
os.Getenv("WTF_GITHUB_BASE_URL"),
|
||||
)
|
||||
|
||||
repo.uploadURL = wtf.Config.UString(
|
||||
"wtf.mods.github.uploadURL",
|
||||
os.Getenv("WTF_GITHUB_UPLOAD_URL"),
|
||||
)
|
||||
}
|
||||
|
||||
// myPullRequests returns a list of pull requests created by username on this repo
|
||||
func (repo *GithubRepo) myPullRequests(username string) []*ghb.PullRequest {
|
||||
prs := []*ghb.PullRequest{}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package weather
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
"os"
|
||||
|
||||
owm "github.com/briandowns/openweathermap"
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/rivo/tview"
|
||||
//"github.com/senorprogrammer/wtf/logger"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user