state

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeProcessor

type ChangeProcessor interface {
	// CaptureUpsertChange captures an upsert change to a resource.
	// It panics if the resource is of unsupported type or if the passed Gateway is different from the one this ChangeProcessor
	// was created for.
	CaptureUpsertChange(obj client.Object)
	// CaptureDeleteChange captures a delete change to a resource.
	// The method panics if the resource is of unsupported type or if the passed Gateway is different from the one this ChangeProcessor
	// was created for.
	CaptureDeleteChange(resourceType client.Object, nsname types.NamespacedName)
	// Process processes any captured changes and produces an internal representation of the Gateway configuration and
	// the status information about the processed resources.
	// If no changes were captured, the changed return argument will be false and both the configuration and statuses
	// will be empty.
	Process() (changed bool, conf Configuration, statuses Statuses)
}

ChangeProcessor processes the changes to resources producing the internal representation of the Gateway configuration. ChangeProcessor only supports one Gateway resource.

type ChangeProcessorConfig

type ChangeProcessorConfig struct {
	// GatewayNsName is the namespaced name of the Gateway resource.
	GatewayNsName types.NamespacedName
	// GatewayCtlrName is the name of the Gateway controller.
	GatewayCtlrName string
	// GatewayClassName is the name of the GatewayClass resource.
	GatewayClassName string
	// SecretMemoryManager is the secret memory manager.
	SecretMemoryManager SecretDiskMemoryManager
}

ChangeProcessorConfig holds configuration parameters for ChangeProcessorImpl.

type ChangeProcessorImpl

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

func NewChangeProcessorImpl

func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl

NewChangeProcessorImpl creates a new ChangeProcessorImpl for the Gateway resource with the configured namespace name.

func (*ChangeProcessorImpl) CaptureDeleteChange

func (c *ChangeProcessorImpl) CaptureDeleteChange(resourceType client.Object, nsname types.NamespacedName)

func (*ChangeProcessorImpl) CaptureUpsertChange

func (c *ChangeProcessorImpl) CaptureUpsertChange(obj client.Object)

func (*ChangeProcessorImpl) Process

func (c *ChangeProcessorImpl) Process() (changed bool, conf Configuration, statuses Statuses)

type Configuration

type Configuration struct {
	// HTTPServers holds all HTTPServers.
	// FIXME(pleshakov) We assume that all servers are HTTP and listen on port 80.
	HTTPServers []VirtualServer
	// SSLServers holds all SSLServers.
	// FIXME(kate-osborn) We assume that all SSL servers listen on port 443.
	SSLServers []VirtualServer
}

Configuration is an internal representation of Gateway configuration. We can think of Configuration as an intermediate state between the Gateway API resources and the data plane (NGINX) configuration.

type FileManager

type FileManager interface {
	// ReadDir returns the file info for the directory.
	ReadDir(dirname string) ([]fs.FileInfo, error)
	// Remove file with given name.
	Remove(name string) error
	// Create file at the provided filepath.
	Create(name string) (*os.File, error)
	// Chmod sets the mode of the file.
	Chmod(file *os.File, mode os.FileMode) error
	// Write writes contents to the file.
	Write(file *os.File, contents []byte) error
}

FileManager is an interface that exposes File I/O operations. Used for unit testing.

type GatewayClassStatus

type GatewayClassStatus struct {
	// Valid shows if the resource is valid.
	Valid bool
	// ErrorMsg describe the error when the resource is invalid.
	ErrorMsg string
	// ObservedGeneration is the generation of the resource that was processed.
	ObservedGeneration int64
}

GatewayClassStatus holds status-related infortmation about the GatewayClass resource.

type GatewayStatus

type GatewayStatus struct {
	NsName           types.NamespacedName
	ListenerStatuses ListenerStatuses
}

GatewayStatus holds the status of the winning Gateway resource.

type HTTPRouteStatus

type HTTPRouteStatus struct {
	ParentStatuses ParentStatuses
}

type HTTPRouteStatuses

type HTTPRouteStatuses map[types.NamespacedName]HTTPRouteStatus

HTTPRouteStatuses holds the statuses of HTTPRoutes where the key is the namespaced name of an HTTPRoute.

type IgnoredGatewayStatus

type IgnoredGatewayStatus struct {
	ObservedGeneration int64
}

IgnoredGatewayStatus holds the status of an ignored Gateway resource.

type IgnoredGatewayStatuses

type IgnoredGatewayStatuses map[types.NamespacedName]IgnoredGatewayStatus

IgnoredGatewayStatuses holds the statuses of the ignored Gateway resources.

type ListenerStatus

type ListenerStatus struct {
	// Valid shows if the listener is valid.
	Valid bool
	// AttachedRoutes is the number of routes attached to the listener.
	AttachedRoutes int32
}

ListenerStatus holds the status-related information about a listener in the Gateway resource.

type ListenerStatuses

type ListenerStatuses map[string]ListenerStatus

ListenerStatuses holds the statuses of listeners where the key is the name of a listener in the Gateway resource.

type MatchRule

type MatchRule struct {
	// MatchIdx is the index of the rule in the Rule.Matches.
	MatchIdx int
	// RuleIdx is the index of the corresponding rule in the HTTPRoute.
	RuleIdx int
	// Source is the corresponding HTTPRoute resource.
	Source *v1alpha2.HTTPRoute
}

MatchRule represents a routing rule. It corresponds directly to a Match in the HTTPRoute resource. An HTTPRoute is guaranteed to have at least one rule with one match. If no rule or match is specified by the user, the default rule {{path:{ type: "PathPrefix", value: "/"}}} is set by the schema.

func (*MatchRule) GetMatch

func (r *MatchRule) GetMatch() v1alpha2.HTTPRouteMatch

GetMatch returns the HTTPRouteMatch of the Route .

type ParentStatus

type ParentStatus struct {
	// Attached is true if the route attaches to the parent (listener).
	Attached bool
}

ParentStatus holds status-related information related to how the HTTPRoute binds to a specific parentRef.

type ParentStatuses

type ParentStatuses map[string]ParentStatus

ParentStatuses holds the statuses of parents where the key is the section name in a parentRef.

type PathRule

type PathRule struct {
	// Path is a path. For example, '/hello'.
	Path string
	// MatchRules holds routing rules.
	MatchRules []MatchRule
}

PathRule represents routing rules that share a common path.

type SSL

type SSL struct {
	// CertificatePath is the path to the certificate file.
	CertificatePath string
}

type Secret

type Secret struct {
	// Secret is the Kubernetes Secret object.
	Secret *apiv1.Secret
	// Valid is whether the Kubernetes Secret is valid.
	Valid bool
}

Secret is the internal representation of a Kubernetes Secret.

type SecretDiskMemoryManager

type SecretDiskMemoryManager interface {
	// Request marks the secret as requested so that it can be written to disk before reloading NGINX.
	// Returns the path to the secret and an error if the secret does not exist in the secret store or the secret is invalid.
	Request(nsname types.NamespacedName) (string, error)
	// WriteAllRequestedSecrets writes all requested secrets to disk.
	WriteAllRequestedSecrets() error
}

SecretDiskMemoryManager manages secrets that are requested by Gateway resources.

type SecretDiskMemoryManagerImpl

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

FIXME(kate-osborn): Is it necessary to make this concurrent-safe?

func NewSecretDiskMemoryManager

func NewSecretDiskMemoryManager(secretDirectory string, secretStore SecretStore, options ...SecretDiskMemoryManagerOption) *SecretDiskMemoryManagerImpl

func (*SecretDiskMemoryManagerImpl) Request

func (*SecretDiskMemoryManagerImpl) WriteAllRequestedSecrets

func (s *SecretDiskMemoryManagerImpl) WriteAllRequestedSecrets() error

type SecretDiskMemoryManagerOption

type SecretDiskMemoryManagerOption func(*SecretDiskMemoryManagerImpl)

SecretDiskMemoryManagerOption is a function that modifies the configuration of the SecretDiskMemoryManager.

func WithSecretFileManager

func WithSecretFileManager(fileManager FileManager) SecretDiskMemoryManagerOption

WithSecretFileManager sets the file manager of the SecretDiskMemoryManager. Used to inject a fake fileManager for unit tests.

type SecretStore

type SecretStore interface {
	// Upsert upserts the secret into the store.
	Upsert(secret *apiv1.Secret)
	// Delete deletes the secret from the store.
	Delete(nsname types.NamespacedName)
	// Get gets the secret from the store.
	Get(nsname types.NamespacedName) *Secret
}

SecretStore stores secrets.

type SecretStoreImpl

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

func NewSecretStore

func NewSecretStore() *SecretStoreImpl

func (SecretStoreImpl) Delete

func (s SecretStoreImpl) Delete(nsname types.NamespacedName)

func (SecretStoreImpl) Get

func (s SecretStoreImpl) Get(nsname types.NamespacedName) *Secret

func (SecretStoreImpl) Upsert

func (s SecretStoreImpl) Upsert(secret *apiv1.Secret)

type ServiceStore

type ServiceStore interface {
	// Upsert upserts the service into the store.
	Upsert(svc *v1.Service)
	// Delete deletes the service from the store.
	Delete(nsname types.NamespacedName)
	// Resolve returns the cluster IP  the service specified by its namespace and name.
	// If the service doesn't have a cluster IP or it doesn't exist, resolve will return an error.
	// FIXME(pleshakov): later, we will start using the Endpoints rather than cluster IPs.
	Resolve(nsname types.NamespacedName) (string, error)
}

ServiceStore stores services and can be queried for the cluster IP of a service.

func NewServiceStore

func NewServiceStore() ServiceStore

NewServiceStore creates a new ServiceStore.

type Statuses

type Statuses struct {
	GatewayClassStatus     *GatewayClassStatus
	GatewayStatus          *GatewayStatus
	IgnoredGatewayStatuses IgnoredGatewayStatuses
	HTTPRouteStatuses      HTTPRouteStatuses
}

Statuses holds the status-related information about Gateway API resources.

type VirtualServer

type VirtualServer struct {
	// Hostname is the hostname of the server.
	Hostname string
	// PathRules is a collection of routing rules.
	PathRules []PathRule
	// SSL holds the SSL configuration options fo the server.
	SSL *SSL
}

VirtualServer is a virtual server.

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