Documentation ¶
Index ¶
- func CountsByStatus(results []ResourceResult) map[Status]int
- func ResultTable(result ResourceResult, clusterName string, baseDir string, verbose bool) string
- type CheckResult
- type CheckType
- type Checker
- type KubeValidator
- type KubeValidatorConfig
- type KubeconformChecker
- type PolicyChecker
- type PolicyModule
- type Resource
- type ResourceResult
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountsByStatus ¶ added in v0.0.31
func CountsByStatus(results []ResourceResult) map[Status]int
CountsByStatus returns the number of check results for each status type.
func ResultTable ¶ added in v0.0.31
func ResultTable( result ResourceResult, clusterName string, baseDir string, verbose bool, ) string
Types ¶
type CheckResult ¶ added in v0.0.30
type CheckResult struct { CheckType CheckType CheckName string Status Status Message string Reasons []string }
CheckResult contains the detailed results of a single check.
type CheckType ¶ added in v0.0.30
type CheckType string
CheckType represents the type of check that has been done.
type Checker ¶ added in v0.0.30
type Checker interface {
Check(context.Context, Resource) CheckResult
}
Checker is an interface that checks a resource and then returns a CheckResult.
type KubeValidator ¶
type KubeValidator struct {
// contains filtered or unexported fields
}
KubeValidator is a struct that validates the kube configs associated with a cluster.
func NewKubeValidator ¶
func NewKubeValidator(config KubeValidatorConfig) *KubeValidator
NewKubeValidator returns a new KubeValidator instance.
func (*KubeValidator) RunChecks ¶ added in v0.0.30
func (k *KubeValidator) RunChecks( ctx context.Context, path string, ) ([]ResourceResult, error)
RunChecks runs all checks over all resources in the path and returns the results.
type KubeValidatorConfig ¶ added in v0.0.30
KubeValidatorConfig is the configuration used to construct a KubeValidator.
type KubeconformChecker ¶ added in v0.0.30
type KubeconformChecker struct {
// contains filtered or unexported fields
}
KubeconformChecker is a Checker implementation that runs kubeconform over all Kubernetes resources.
func NewKubeconformChecker ¶ added in v0.0.30
func NewKubeconformChecker() (*KubeconformChecker, error)
NewKubeconformChecker creates a new KubeconformChecker instance.
func (*KubeconformChecker) Check ¶ added in v0.0.30
func (k *KubeconformChecker) Check(_ context.Context, resource Resource) CheckResult
Check runs Kubeconform over the argument resource.
type PolicyChecker ¶ added in v0.0.30
type PolicyChecker struct { Module PolicyModule Query rego.PreparedEvalQuery ExtraFields map[string]interface{} }
Policy wraps a policy module and a prepared query.
func DefaultPoliciesFromGlobs ¶ added in v0.0.30
func DefaultPoliciesFromGlobs( ctx context.Context, globs []string, extraFields map[string]interface{}, ) ([]*PolicyChecker, error)
DefaultPoliciesFromGlobs creates policy checkers from one or more file policy globs, using the default package and result values.
func NewPolicyChecker ¶ added in v0.0.30
func NewPolicyChecker(ctx context.Context, module PolicyModule) (*PolicyChecker, error)
NewPolicyChecker creates a new PolicyChecker from the given module.
func (*PolicyChecker) Check ¶ added in v0.0.30
func (p *PolicyChecker) Check(ctx context.Context, resource Resource) CheckResult
Check runs a check against the argument resource using the current policy.
type PolicyModule ¶ added in v0.0.30
type PolicyModule struct { Name string // Contents is a string that stores the policy in rego format. Contents string // Package is the name of the package in the rego contents. Package string // Result is the variable that should be accessed to get the evaluation results. Result string // ExtraFields are added into the input and usable for policy evaluation. ExtraFields map[string]interface{} }
PolicyModule contains information about a policy.
type Resource ¶ added in v0.0.30
type Resource struct { Path string Contents []byte Name string Namespace string Version string Kind string // contains filtered or unexported fields }
Resource is a Kubernetes resource from a file that we want to do checks on.
func MakeResource ¶ added in v0.0.30
MakeResource constructs a resource from a path, contents, and index.
func (Resource) PrettyName ¶ added in v0.0.30
PrettyName returns a pretty, compact name for a resource.
func (Resource) TokResource ¶ added in v0.0.30
TokResource converts a Resource to a Kubeconform resource (useful for running the latter).
type ResourceResult ¶ added in v0.0.31
type ResourceResult struct { Resource Resource CheckResults []CheckResult }
Result stores the results of validating a single resource in a single file, for all checks.
func ResultsWithIssues ¶ added in v0.0.31
func ResultsWithIssues(results []ResourceResult) []ResourceResult
ResultsWithIssues filters the argument resource results to just those with potential issues.
func (ResourceResult) HasIssues ¶ added in v0.0.31
func (r ResourceResult) HasIssues() bool
HasIssues returns whether a ResourceResult has at least one check result with an error or warning.