policies

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateTargetRef

func ValidateTargetRef(
	ref v1alpha2.LocalPolicyTargetReference,
	basePath *field.Path,
	supportedKinds []gatewayv1.Kind,
) error

ValidateTargetRef validates a policy's targetRef for the proper group and kind.

Types

type ConfigGenerator

type ConfigGenerator interface {
	Generate(policy Policy, globalSettings *GlobalSettings) []byte
}

ConfigGenerator generates a slice of bytes containing the configuration from a Policy.

type GenerateFunc

type GenerateFunc func(policy Policy, globalSettings *GlobalSettings) []byte

GenerateFunc generates config as []byte for an NGF Policy.

type GlobalSettings

type GlobalSettings struct {
	// TracingSpanAttributes contain the attributes specified in the NginxProxy resource.
	TracingSpanAttributes []ngfAPI.SpanAttribute
	// NginxProxyValid is whether or not the NginxProxy resource is valid.
	NginxProxyValid bool
	// TelemetryEnabled is whether or not telemetry is enabled in the NginxProxy resource.
	TelemetryEnabled bool
}

GlobalSettings contains global settings from the current state of the graph that may be needed for policy validation or generation if certain policies rely on those global settings.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages the validators and generators for NGF Policies.

func NewManager

func NewManager(
	mustExtractGVK kinds.MustExtractGVK,
	configs ...ManagerConfig,
) *Manager

NewManager returns a new Manager. Implements dataplane.ConfigGenerator and validation.PolicyValidator.

func (*Manager) Conflicts

func (m *Manager) Conflicts(polA, polB Policy) bool

Conflicts returns true if the policies conflict.

func (*Manager) Generate

func (m *Manager) Generate(policy Policy, globalSettings *GlobalSettings) []byte

Generate generates config for the policy as a byte array.

func (*Manager) Validate

func (m *Manager) Validate(policy Policy, globalSettings *GlobalSettings) []conditions.Condition

Validate validates the policy.

type ManagerConfig

type ManagerConfig struct {
	// Validator is the Validator for the Policy.
	Validator Validator
	// Generate is the GenerateFunc for the Policy.
	Generator GenerateFunc
	// GVK is the GroupVersionKind of the Policy.
	GVK schema.GroupVersionKind
}

ManagerConfig contains the config to register a Policy with the Manager.

type Policy

type Policy interface {
	GetTargetRefs() []v1alpha2.LocalPolicyTargetReference
	GetPolicyStatus() v1alpha2.PolicyStatus
	SetPolicyStatus(status v1alpha2.PolicyStatus)
	client.Object
}

Policy is an extension of client.Object. It adds methods that are common among all NGF Policies.

type Validator

type Validator interface {
	// Validate validates an NGF Policy.
	Validate(policy Policy, globalSettings *GlobalSettings) []conditions.Condition
	// Conflicts returns true if the two Policies conflict.
	Conflicts(a, b Policy) bool
}

Validator validates an NGF Policy.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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