mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-02 14:46:31 +00:00
27 lines
484 B
Go
27 lines
484 B
Go
package permissions
|
|
|
|
import (
|
|
"go.woodpecker-ci.org/woodpecker/v2/server/model"
|
|
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
|
|
)
|
|
|
|
func NewOrgs(orgs []string) *Orgs {
|
|
return &Orgs{
|
|
IsConfigured: len(orgs) > 0,
|
|
orgs: utils.SliceToBoolMap(orgs),
|
|
}
|
|
}
|
|
|
|
type Orgs struct {
|
|
IsConfigured bool
|
|
orgs map[string]bool
|
|
}
|
|
|
|
func (o *Orgs) IsMember(teams []*model.Team) bool {
|
|
for _, team := range teams {
|
|
if o.orgs[team.Login] {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|