Documentation ¶
Overview ¶
Package cts is a set of methods for constructing ConstraintTemplates for use in tests.
Index ¶
- Constants
- func Code(engine string, source interface{}) templates.Code
- func ExpectedSchema(pm PropMap) *apiextensions.JSONSchemaProps
- func MakeConstraint(t testing.TB, kind, name string, args ...ConstraintArg) *unstructured.Unstructured
- func MakeConstraintWithoutActions(t testing.TB, kind, name string, args ...ConstraintArg) *unstructured.Unstructured
- func MakeScopedEnforcementConstraint(t testing.TB, kind, name string, globalAction string, actions []string, ...) *unstructured.Unstructured
- func New(opts ...Opt) *templates.ConstraintTemplate
- func Prop(properties map[string]apiextensions.JSONSchemaProps) apiextensions.JSONSchemaProps
- func PropTyped(propType string) apiextensions.JSONSchemaProps
- func PropUnstructured() apiextensions.JSONSchemaProps
- func Target(name string, rego string, libs ...string) templates.Target
- func TargetCustomEngines(name string, codes ...templates.Code) templates.Target
- func TargetNoEngine(name string) templates.Target
- type ConstraintArg
- type Opt
- type PropMap
Constants ¶
const ( ModuleDeny = ` package foo violation[{"msg": msg}] { true msg := "denied" } ` MockTemplateName string = "fakes" MockTemplate string = "Fakes" MockTargetHandler string = "foo" )
Variables ¶
This section is empty.
Functions ¶
func ExpectedSchema ¶
func ExpectedSchema(pm PropMap) *apiextensions.JSONSchemaProps
func MakeConstraint ¶
func MakeConstraint(t testing.TB, kind, name string, args ...ConstraintArg) *unstructured.Unstructured
MakeConstraint creates a new test Constraint.
func MakeConstraintWithoutActions ¶
func MakeConstraintWithoutActions(t testing.TB, kind, name string, args ...ConstraintArg) *unstructured.Unstructured
func MakeScopedEnforcementConstraint ¶
func MakeScopedEnforcementConstraint(t testing.TB, kind, name string, globalAction string, actions []string, eps ...string) *unstructured.Unstructured
func New ¶
func New(opts ...Opt) *templates.ConstraintTemplate
func Prop ¶
func Prop(properties map[string]apiextensions.JSONSchemaProps) apiextensions.JSONSchemaProps
Prop constructs an Object schema node with the passed property map.
func PropTyped ¶
func PropTyped(propType string) apiextensions.JSONSchemaProps
PropTyped creates a typed property with no subfields.
func PropUnstructured ¶
func PropUnstructured() apiextensions.JSONSchemaProps
PropUnstructured constructs a schema node with no specified underlying structure.
func TargetCustomEngines ¶
func TargetNoEngine ¶
Types ¶
type ConstraintArg ¶
type ConstraintArg func(*unstructured.Unstructured) error
func EnforcementAction ¶
func EnforcementAction(action string) ConstraintArg
EnforcementAction sets the action to be taken if the Constraint is violated.
func MatchNamespace ¶
func MatchNamespace(namespace string) ConstraintArg
MatchNamespace modifies the Constraint to only match objects with the passed Namespace.
func Set ¶
func Set(value interface{}, path ...string) ConstraintArg
Set sets an arbitrary value inside the Constraint.
func WantData ¶
func WantData(data string) ConstraintArg
WantData sets the Constraint to verify that data of objects under review is set to wantData. Only meaningful for CheckData constraints.
type Opt ¶
type Opt func(*templates.ConstraintTemplate)
func OptCRDNames ¶
func OptCRDSchema ¶
func OptTargets ¶
type PropMap ¶
type PropMap map[string]apiextensions.JSONSchemaProps