fix: support both auth token and oauth token
This commit is contained in:
parent
8abe1e7981
commit
ea4e4aa00a
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue