policies

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 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 CompositeGenerator

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

CompositeGenerator contains all policy generators.

func NewCompositeGenerator

func NewCompositeGenerator(generators ...Generator) *CompositeGenerator

NewCompositeGenerator returns a new instance of a CompositeGenerator.

func (*CompositeGenerator) GenerateForInternalLocation

func (g *CompositeGenerator) GenerateForInternalLocation(policies []Policy) GenerateResultFiles

GenerateForInternalLocation calls all policy generators for an internal location block.

func (*CompositeGenerator) GenerateForLocation

func (g *CompositeGenerator) GenerateForLocation(policies []Policy, location http.Location) GenerateResultFiles

GenerateForLocation calls all policy generators for a normal location block.

func (*CompositeGenerator) GenerateForServer

func (g *CompositeGenerator) GenerateForServer(policies []Policy, server http.Server) GenerateResultFiles

GenerateForServer calls all policy generators for the server block.

type CompositeValidator

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

CompositeValidator manages the validators for NGF Policies.

func NewManager

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

NewManager returns a new CompositeValidator. Implements validation.PolicyValidator.

func (*CompositeValidator) Conflicts

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

Conflicts returns true if the policies conflict.

func (*CompositeValidator) Validate

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

Validate validates the policy.

type File

type File struct {
	Name    string
	Content []byte
}

File is the contents of the generated file.

type GenerateResultFiles

type GenerateResultFiles []File

GenerateResultFiles is a list of files generated for inclusion by policy generators.

type Generator

type Generator interface {
	// GenerateForServer generates policy configuration for the server block.
	GenerateForServer(policies []Policy, server http.Server) GenerateResultFiles
	// GenerateForLocation generates policy configuration for a normal location block.
	GenerateForLocation(policies []Policy, location http.Location) GenerateResultFiles
	// GenerateForInternalLocation generates policy configuration for an internal location block.
	GenerateForInternalLocation(policies []Policy) GenerateResultFiles
}

Generator defines an interface for a policy to implement its appropriate generator functions.

type GlobalSettings

type GlobalSettings struct {
	// 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 ManagerConfig

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

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

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 UnimplementedGenerator

type UnimplementedGenerator struct{}

UnimplementedGenerator can be inherited by any policy generator that may not need to implement all of possible generations, in order to satisfy the Generator interface.

func (UnimplementedGenerator) GenerateForInternalLocation

func (u UnimplementedGenerator) GenerateForInternalLocation(_ []Policy) GenerateResultFiles

func (UnimplementedGenerator) GenerateForLocation

func (u UnimplementedGenerator) GenerateForLocation(_ []Policy, _ http.Location) GenerateResultFiles

func (UnimplementedGenerator) GenerateForServer

func (u UnimplementedGenerator) GenerateForServer(_ []Policy, _ http.Server) GenerateResultFiles

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