woodpecker/server/plugins/permissions/orgs.go
runephilosof-karnovgroup adb2c82790
Update go module path for major version 2 (#2905)
https://go.dev/doc/modules/release-workflow#breaking

Fixes https://github.com/woodpecker-ci/woodpecker/issues/2913 fixes
#2654
```
runephilosof@fedora:~/code/platform-woodpecker/woodpecker-repo-configurator (master)$ go get go.woodpecker-ci.org/woodpecker@v2.0.0
go: go.woodpecker-ci.org/woodpecker@v2.0.0: invalid version: module contains a go.mod file, so module path must match major version ("go.woodpecker-ci.org/woodpecker/v2")
```

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-12-08 08:15:08 +01:00

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
}