mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-01 18:18:46 +00:00
* Moving config files to core/config * fix package names * fix package dependencies * linting fixes * more linting fixes * ran golangci-lint run --fix
47 lines
840 B
Go
47 lines
840 B
Go
package valid
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
)
|
|
|
|
const (
|
|
LocalPolicySet string = "local"
|
|
GithubPolicySet string = "github"
|
|
)
|
|
|
|
// PolicySets defines version of policy checker binary(conftest) and a list of
|
|
// PolicySet objects. PolicySets struct is used by PolicyCheck workflow to build
|
|
// context to enforce policies.
|
|
type PolicySets struct {
|
|
Version *version.Version
|
|
Owners PolicyOwners
|
|
PolicySets []PolicySet
|
|
}
|
|
|
|
type PolicyOwners struct {
|
|
Users []string
|
|
}
|
|
|
|
type PolicySet struct {
|
|
Source string
|
|
Path string
|
|
Name string
|
|
Owners PolicyOwners
|
|
}
|
|
|
|
func (p *PolicySets) HasPolicies() bool {
|
|
return len(p.PolicySets) > 0
|
|
}
|
|
|
|
func (p *PolicySets) IsOwner(username string) bool {
|
|
for _, uname := range p.Owners.Users {
|
|
if strings.EqualFold(uname, username) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|