with env
This commit is contained in:
parent
744f870e74
commit
1889f05db2
@ -2,7 +2,9 @@ package gitproviders
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"code.gitea.io/sdk/gitea"
|
"code.gitea.io/sdk/gitea"
|
||||||
@ -121,6 +123,15 @@ func (g *Gitea) getOrCreateClient(ctx context.Context, server string) (*gitea.Cl
|
|||||||
client, ok := g.giteaClients[server]
|
client, ok := g.giteaClients[server]
|
||||||
if !ok || client == nil {
|
if !ok || client == nil {
|
||||||
c, err := gitea.NewClient(server)
|
c, err := gitea.NewClient(server)
|
||||||
|
username, ok := os.LookupEnv("GITEA_USERNAME")
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("missing environment variable GITEA_USERNAME")
|
||||||
|
}
|
||||||
|
apitoken, ok := os.LookupEnv("GITEA_API_TOKEN")
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("missing environment variable GITEA_API_TOKEN")
|
||||||
|
}
|
||||||
|
c.SetBasicAuth(username, apitoken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user