Skip to content

Commit

Permalink
allow auth with token
Browse files Browse the repository at this point in the history
  • Loading branch information
theleeeo committed Jan 27, 2024
1 parent 6293430 commit f72a538
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
Github struct {
Owner string `yaml:"owner"`
Repo string `yaml:"repo"`
Token string `yaml:"token"`
} `yaml:"github"`
} `yaml:"provider"`

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func main() {
panic(err)
}

ghClient := provider.NewGithub(cfg.Provider.Github.Owner, cfg.Provider.Github.Repo)
ghClient := provider.NewGithub(cfg.Provider.Github.Owner, cfg.Provider.Github.Repo, cfg.Provider.Github.Token)

serverConfig := &server.Config{
PathPrefix: cfg.Server.PathPrefix,
Expand Down
11 changes: 9 additions & 2 deletions provider/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ import (
type githubProvider struct {
owner string
repo string
token string
client *github.Client
}

func NewGithub(owner, repo string) *githubProvider {
func NewGithub(owner, repo, token string) *githubProvider {
cl := github.NewClient(nil)
if token != "" {
cl = cl.WithAuthToken(token)
}

return &githubProvider{
owner: owner,
repo: repo,
client: github.NewClient(nil),
token: token,
client: cl,
}
}

Expand Down

0 comments on commit f72a538

Please sign in to comment.