fix: support both auth token and oauth token

This commit is contained in:
Derrick Hammer 2024-02-11 14:12:48 -05:00
parent 8abe1e7981
commit ea4e4aa00a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 1 deletions

View File

@ -39,10 +39,17 @@ type ClientParams struct {
func getClient(params ClientParams) (*gitea.Client, error) { func getClient(params ClientParams) (*gitea.Client, error) {
options := make([]gitea.ClientOption, 0) options := make([]gitea.ClientOption, 0)
authToken := ""
if len(params.AuthToken) > 0 { if len(params.AuthToken) > 0 {
options = append(options, gitea.SetToken(params.AuthToken)) authToken = params.AuthToken
} }
if len(authToken) == 0 {
authToken = params.Config.Oauth.Token
}
options = append(options, gitea.SetToken(authToken))
client, err := gitea.NewClient(params.Config.GiteaUrl, options...) client, err := gitea.NewClient(params.Config.GiteaUrl, options...)
if err != nil { if err != nil {
return nil, err return nil, err