-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
107 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package permissions | ||
|
||
import ( | ||
"go.woodpecker-ci.org/woodpecker/server/model" | ||
"go.woodpecker-ci.org/woodpecker/shared/utils" | ||
) | ||
|
||
func NewAdmins(admins []string) *Admins { | ||
return &Admins{admins: utils.SliceToBoolMap(admins)} | ||
} | ||
|
||
type Admins struct { | ||
admins map[string]bool | ||
} | ||
|
||
func (a *Admins) IsAdmin(user *model.User) bool { | ||
return a.admins[user.Login] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package permissions | ||
|
||
import ( | ||
"go.woodpecker-ci.org/woodpecker/server/model" | ||
"go.woodpecker-ci.org/woodpecker/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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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) > 0 && o.owners[repo.Owner] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters