test

package
v3.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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, tOpts Opts) (*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 Opts

type Opts struct {
	// Driver specific options
	IncludeTrace bool
	GatherStats  bool
	UseK8sCEL    bool
}

options for the Test func.

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