mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-28 19:30:30 +00:00
c9e587753e
closes #2854
18 lines
425 B
Go
18 lines
425 B
Go
package permissions
|
|
|
|
import (
|
|
"go.woodpecker-ci.org/woodpecker/server/model"
|
|
"go.woodpecker-ci.org/woodpecker/shared/utils"
|
|
)
|
|
|
|
func NewOwnersAllowlist(owners []string) *OwnersAllowlist {
|
|
return &OwnersAllowlist{owners: utils.SliceToBoolMap(owners)}
|
|
}
|
|
|
|
type OwnersAllowlist struct {
|
|
owners map[string]bool
|
|
}
|
|
|
|
func (o *OwnersAllowlist) IsAllowed(repo *model.Repo) bool {
|
|
return len(o.owners) < 1 || o.owners[repo.Owner]
|
|
}
|