Files
atlantis/server/core/config/valid/policies.go
Sarvar Muminov 7a927c050b Moving config files to core/config (#2036)
* Moving config files to core/config

* fix package names

* fix package dependencies

* linting fixes

* more linting fixes

* ran golangci-lint run --fix
2022-02-03 11:06:04 -08:00

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
}