mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
ability to pull list of orgs and verify membership
This commit is contained in:
@@ -26,8 +26,6 @@ type GitHub struct {
|
||||
Secret string
|
||||
PrivateMode bool
|
||||
SkipVerify bool
|
||||
Orgs []string
|
||||
Open bool
|
||||
|
||||
cache *lru.Cache
|
||||
}
|
||||
@@ -40,8 +38,6 @@ func New(service *settings.Service) *GitHub {
|
||||
Secret: service.OAuth.Secret,
|
||||
PrivateMode: service.PrivateMode,
|
||||
SkipVerify: service.SkipVerify,
|
||||
Orgs: service.Orgs,
|
||||
Open: service.Open,
|
||||
}
|
||||
var err error
|
||||
github.cache, err = lru.New(1028)
|
||||
@@ -81,6 +77,20 @@ func (g *GitHub) Login(token, secret string) (*common.User, error) {
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
// Orgs fetches the organizations for the given user.
|
||||
func (g *GitHub) Orgs(u *common.User) ([]string, error) {
|
||||
client := NewClient(g.API, u.Token, g.SkipVerify)
|
||||
orgs_ := []string{}
|
||||
orgs, err := GetOrgs(client)
|
||||
if err != nil {
|
||||
return orgs_, err
|
||||
}
|
||||
for _, org := range orgs {
|
||||
orgs_ = append(orgs_, *org.Login)
|
||||
}
|
||||
return orgs_, nil
|
||||
}
|
||||
|
||||
// Repo fetches the named repository from the remote system.
|
||||
func (g *GitHub) Repo(u *common.User, owner, name string) (*common.Repo, error) {
|
||||
client := NewClient(g.API, u.Token, g.SkipVerify)
|
||||
|
||||
Reference in New Issue
Block a user