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"
|
"os"
|
||||||
|
|
||||||
ghb "github.com/google/go-github/github"
|
ghb "github.com/google/go-github/github"
|
||||||
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,14 +23,12 @@ type GithubRepo struct {
|
|||||||
|
|
||||||
func NewGithubRepo(name, owner string) *GithubRepo {
|
func NewGithubRepo(name, owner string) *GithubRepo {
|
||||||
repo := 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,
|
Name: name,
|
||||||
Owner: owner,
|
Owner: owner,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repo.loadAPICredentials()
|
||||||
|
|
||||||
return &repo
|
return &repo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +90,23 @@ func (repo *GithubRepo) githubClient() (*ghb.Client, error) {
|
|||||||
return ghb.NewClient(oauthClient), nil
|
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
|
// myPullRequests returns a list of pull requests created by username on this repo
|
||||||
func (repo *GithubRepo) myPullRequests(username string) []*ghb.PullRequest {
|
func (repo *GithubRepo) myPullRequests(username string) []*ghb.PullRequest {
|
||||||
prs := []*ghb.PullRequest{}
|
prs := []*ghb.PullRequest{}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package weather
|
package weather
|
||||||
|
|
||||||
import (
|
import (
|
||||||
//"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
owm "github.com/briandowns/openweathermap"
|
owm "github.com/briandowns/openweathermap"
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
//"github.com/senorprogrammer/wtf/logger"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user