test

package
v3.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithGatherStats added in v3.22.0

func WithGatherStats() gator.Opt

func WithK8sCEL added in v3.22.0

func WithK8sCEL(gatherStats bool) gator.Opt

func WithTrace added in v3.22.0

func WithTrace() gator.Opt

Types

type GatorResponse

type GatorResponse struct {
	Trace   *string
	Target  string
	Results []*GatorResult
}

Response is a collection of Constraint violations for a particular Target. Each Result is for a distinct Constraint.

type GatorResponses

type GatorResponses struct {
	ByTarget     map[string]*GatorResponse
	Handled      map[string]bool
	StatsEntries []*instrumentation.StatsEntry
}

func Test

func Test(objs []*unstructured.Unstructured, opts ...gator.Opt) (*GatorResponses, error)

func (*GatorResponses) Results

func (r *GatorResponses) Results() []*GatorResult

type GatorResult

type GatorResult struct {
	types.Result

	ViolatingObject *unstructured.Unstructured `json:"violatingObject"`

	// Trace is an explanation of the underlying constraint evaluation.
	// For instance, for OPA based evaluations, the trace is an explanation of the rego query:
	// https://www.openpolicyagent.org/docs/v0.44.0/policy-reference/#tracing
	// NOTE: This is a string pointer to differentiate between an empty ("") trace and an unset one (nil);
	// also for efficiency reasons as traces could be arbitrarily large theoretically.
	Trace *string `json:"trace"`
}

type YamlGatorResult

type YamlGatorResult struct {
	types.Result
	ViolatingObject map[string]interface{} `yaml:"violatingObject"`
	Trace           *string                `yaml:"trace,flow"`
}

YamlGatorResult is a GatorResult minues a level of indirection on the ViolatingObject and with struct tags for yaml marshaling.

func GetYamlFriendlyResults

func GetYamlFriendlyResults(results []*GatorResult) []*YamlGatorResult

GetYamlFriendlyResults is a convenience func to remove a level of indirection between unstructured.Unstructured and unstructured.Unstructured.Object when calling MarshalYaml.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL