store

package
v3.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Code generated by hack/generators/cache-stores/main.go; DO NOT EDIT. If you want to add a new type to the cache store, you need to add a new entry to the supportedTypes list in spec.go.

Index

Constants

View Source
const (

	// IngressClassKongController is the string used for the Controller field of a recognized IngressClass.
	IngressClassKongController = "ingress-controllers.konghq.com/kong"
)

Variables

This section is empty.

Functions

func GetTypedStore added in v3.2.0

func GetTypedStore[T client.Object](cs CacheStores) (cache.Store, error)

GetTypedStore returns a cache.Store for the given type.

func List added in v3.2.0

func List[T client.Object](cs CacheStores) ([]T, error)

List lists all objects of given type from the provided cache stores.

Types

type CacheStores

type CacheStores struct {
	IngressV1                      cache.Store
	IngressClassV1                 cache.Store
	Service                        cache.Store
	Secret                         cache.Store
	EndpointSlice                  cache.Store
	HTTPRoute                      cache.Store
	UDPRoute                       cache.Store
	TCPRoute                       cache.Store
	TLSRoute                       cache.Store
	GRPCRoute                      cache.Store
	ReferenceGrant                 cache.Store
	Gateway                        cache.Store
	Plugin                         cache.Store
	ClusterPlugin                  cache.Store
	Consumer                       cache.Store
	ConsumerGroup                  cache.Store
	KongIngress                    cache.Store
	TCPIngress                     cache.Store
	UDPIngress                     cache.Store
	KongUpstreamPolicy             cache.Store
	IngressClassParametersV1alpha1 cache.Store
	KongServiceFacade              cache.Store
	KongVault                      cache.Store
	KongCustomEntity               cache.Store
	// contains filtered or unexported fields
}

CacheStores stores cache.Store for all Kinds of k8s objects that the Ingress Controller reads.

func NewCacheStores

func NewCacheStores() CacheStores

NewCacheStores is a convenience function for CacheStores to initialize all attributes with new cache stores.

func NewCacheStoresFromObjYAML

func NewCacheStoresFromObjYAML(objs ...[]byte) (c CacheStores, err error)

NewCacheStoresFromObjYAML provides a new CacheStores object given any number of byte arrays containing YAML Kubernetes objects. An error is returned if any provided YAML was not a valid Kubernetes object.

func NewCacheStoresFromObjs

func NewCacheStoresFromObjs(objs ...runtime.Object) (CacheStores, error)

NewCacheStoresFromObjs provides a new CacheStores object given any number of Kubernetes objects that should be pre-populated. This function will sort objects into the appropriate sub-storage (e.g. IngressV1, TCPIngress, e.t.c.) but will produce an error if any of the input objects are erroneous or otherwise unusable as Kubernetes objects.

func (CacheStores) Add

func (c CacheStores) Add(obj runtime.Object) error

Add stores a provided runtime.Object into the CacheStore if it's of a supported type. The CacheStore must be initialized (see NewCacheStores()) or this will panic.

func (CacheStores) Delete

func (c CacheStores) Delete(obj runtime.Object) error

Delete removes a provided runtime.Object from the CacheStore if it's of a supported type. The CacheStore must be initialized (see NewCacheStores()) or this will panic.

func (CacheStores) Get

func (c CacheStores) Get(obj runtime.Object) (item interface{}, exists bool, err error)

Get checks whether or not there's already some version of the provided object present in the cache.

func (CacheStores) ListAllStores added in v3.2.0

func (c CacheStores) ListAllStores() []cache.Store

ListAllStores returns a list of all cache stores embedded in the struct.

func (CacheStores) SupportedTypes added in v3.2.0

func (c CacheStores) SupportedTypes() []client.Object

SupportedTypes returns a list of supported types for the cache.

func (CacheStores) TakeSnapshot added in v3.2.0

func (c CacheStores) TakeSnapshot() (CacheStores, error)

TakeSnapshot takes a snapshot of the CacheStores.

func (CacheStores) TakeSnapshotIfChanged added in v3.2.0

func (c CacheStores) TakeSnapshotIfChanged(previousSnapshotHash SnapshotHash) (
	snapshot CacheStores,
	newHash SnapshotHash,
	err error,
)

TakeSnapshotIfChanged takes a snapshot of the CacheStores if the hash of the current state differs from the hash of the previous snapshot supplied as an argument (to make and initial just pass empty string). When error is not nil discard all other return values. When newHash is empty it means that the snapshot hasn't been taken - returned snapshot is meaningless. This is a situation when hash of the current state is the same as the hash of the previous snapshot supplied as an argument.

type FakeObjects

type FakeObjects struct {
	IngressesV1                    []*netv1.Ingress
	IngressClassesV1               []*netv1.IngressClass
	HTTPRoutes                     []*gatewayapi.HTTPRoute
	UDPRoutes                      []*gatewayapi.UDPRoute
	TCPRoutes                      []*gatewayapi.TCPRoute
	TLSRoutes                      []*gatewayapi.TLSRoute
	GRPCRoutes                     []*gatewayapi.GRPCRoute
	ReferenceGrants                []*gatewayapi.ReferenceGrant
	Gateways                       []*gatewayapi.Gateway
	TCPIngresses                   []*kongv1beta1.TCPIngress
	UDPIngresses                   []*kongv1beta1.UDPIngress
	IngressClassParametersV1alpha1 []*kongv1alpha1.IngressClassParameters
	Services                       []*corev1.Service
	EndpointSlices                 []*discoveryv1.EndpointSlice
	Secrets                        []*corev1.Secret
	KongPlugins                    []*kongv1.KongPlugin
	KongClusterPlugins             []*kongv1.KongClusterPlugin
	KongIngresses                  []*kongv1.KongIngress
	KongConsumers                  []*kongv1.KongConsumer
	KongConsumerGroups             []*kongv1beta1.KongConsumerGroup
	KongUpstreamPolicies           []*kongv1beta1.KongUpstreamPolicy
	KongServiceFacades             []*incubatorv1alpha1.KongServiceFacade
	KongVaults                     []*kongv1alpha1.KongVault
	KongCustomEntities             []*kongv1alpha1.KongCustomEntity
}

FakeObjects can be used to populate a fake Store.

func (FakeObjects) MarshalToYAML

func (objects FakeObjects) MarshalToYAML() ([]byte, error)

MarshalToYAML marshals the contents of every object in the store as YAML, separated by "---". This is useful for debugging.

type NotFoundError

type NotFoundError struct {
	Message string
}

NotFoundError error is returned when a lookup results in no resource. This type is meant to be used for error handling using `errors.As()`.

func (NotFoundError) Error

func (e NotFoundError) Error() string

type SnapshotHash added in v3.2.0

type SnapshotHash string

SnapshotHash is type that represents a hash of the snapshot. It's a base32 encoded string of the sha256 hash of the snapshot. It's printable and human-readable.

const SnapshotHashEmpty SnapshotHash = ""

SnapshotHashEmpty is a constant that represents an empty snapshot hash.

type Store

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

Store implements Storer and can be used to list Ingress, Services and other resources from k8s APIserver. The backing stores should be synced and updated by the caller. It is ingressClass filter aware.

func New

func New(cs CacheStores, ingressClass string, logger logr.Logger) *Store

New creates a new object store to be used in the ingress controller.

func (Store) GetEndpointSlicesForService

func (s Store) GetEndpointSlicesForService(namespace, name string) ([]*discoveryv1.EndpointSlice, error)

GetEndpointSlicesForService returns all EndpointSlices for service 'namespace/name' inside K8s.

func (Store) GetGateway

func (s Store) GetGateway(namespace string, name string) (*gatewayapi.Gateway, error)

GetGateway returns gateway resource having specified namespace and name.

func (Store) GetIngressClassName

func (s Store) GetIngressClassName() string

func (Store) GetIngressClassParametersV1Alpha1

func (s Store) GetIngressClassParametersV1Alpha1(ingressClass *netv1.IngressClass) (*kongv1alpha1.IngressClassParameters, error)

GetIngressClassParametersV1Alpha1 returns IngressClassParameters for provided IngressClass.

func (Store) GetIngressClassV1

func (s Store) GetIngressClassV1(name string) (*netv1.IngressClass, error)

GetIngressClassV1 returns the 'name' IngressClass resource.

func (Store) GetKongClusterPlugin

func (s Store) GetKongClusterPlugin(name string) (*kongv1.KongClusterPlugin, error)

GetKongClusterPlugin returns the 'name' KongClusterPlugin resource.

func (Store) GetKongConsumer

func (s Store) GetKongConsumer(namespace, name string) (*kongv1.KongConsumer, error)

GetKongConsumer returns the 'name' KongConsumer resource in namespace.

func (Store) GetKongConsumerGroup

func (s Store) GetKongConsumerGroup(namespace, name string) (*kongv1beta1.KongConsumerGroup, error)

GetKongConsumerGroup returns the 'name' KongConsumerGroup resource in namespace.

func (Store) GetKongCustomEntity added in v3.2.0

func (s Store) GetKongCustomEntity(namespace, name string) (*kongv1alpha1.KongCustomEntity, error)

func (Store) GetKongIngress

func (s Store) GetKongIngress(namespace, name string) (*kongv1.KongIngress, error)

GetKongIngress returns the 'name' KongIngress resource in namespace.

func (Store) GetKongPlugin

func (s Store) GetKongPlugin(namespace, name string) (*kongv1.KongPlugin, error)

GetKongPlugin returns the 'name' KongPlugin resource in namespace.

func (Store) GetKongServiceFacade added in v3.1.0

func (s Store) GetKongServiceFacade(namespace, name string) (*incubatorv1alpha1.KongServiceFacade, error)

func (Store) GetKongUpstreamPolicy

func (s Store) GetKongUpstreamPolicy(namespace, name string) (*kongv1beta1.KongUpstreamPolicy, error)

func (Store) GetKongVault added in v3.1.0

func (s Store) GetKongVault(name string) (*kongv1alpha1.KongVault, error)

GetKongVault returns kongvault resource having specified name.

func (Store) GetSecret

func (s Store) GetSecret(namespace, name string) (*corev1.Secret, error)

GetSecret returns a Secret using the namespace and name as key.

func (Store) GetService

func (s Store) GetService(namespace, name string) (*corev1.Service, error)

GetService returns a Service using the namespace and name as key.

func (Store) ListCACerts

func (s Store) ListCACerts() ([]*corev1.Secret, error)

ListCACerts returns all Secrets containing the label "konghq.com/ca-cert"="true".

func (Store) ListGRPCRoutes

func (s Store) ListGRPCRoutes() ([]*gatewayapi.GRPCRoute, error)

ListGRPCRoutes returns the list of GRPCRoutes in the GRPCRoute cache store.

func (Store) ListGateways

func (s Store) ListGateways() ([]*gatewayapi.Gateway, error)

ListGateways returns the list of Gateways in the Gateway cache store.

func (Store) ListGlobalKongClusterPlugins

func (s Store) ListGlobalKongClusterPlugins() ([]*kongv1.KongClusterPlugin, error)

ListGlobalKongClusterPlugins returns all KongClusterPlugin resources filtered by the ingress.class annotation and with the label global:"true".

func (Store) ListHTTPRoutes

func (s Store) ListHTTPRoutes() ([]*gatewayapi.HTTPRoute, error)

ListHTTPRoutes returns the list of HTTPRoutes in the HTTPRoute cache store.

func (Store) ListIngressClassParametersV1Alpha1

func (s Store) ListIngressClassParametersV1Alpha1() []*kongv1alpha1.IngressClassParameters

ListIngressClassParametersV1Alpha1 returns the list of IngressClassParameters in the Ingress v1alpha1 store.

func (Store) ListIngressClassesV1

func (s Store) ListIngressClassesV1() []*netv1.IngressClass

ListIngressClassesV1 returns the list of Ingresses in the Ingress v1 store.

func (Store) ListIngressesV1

func (s Store) ListIngressesV1() []*netv1.Ingress

ListIngressesV1 returns the list of Ingresses in the Ingress v1 store.

func (Store) ListKongClusterPlugins

func (s Store) ListKongClusterPlugins() []*kongv1.KongClusterPlugin

ListKongClusterPlugins lists all KongClusterPlugins that match expected ingress.class annotation.

func (Store) ListKongConsumerGroups

func (s Store) ListKongConsumerGroups() []*kongv1beta1.KongConsumerGroup

ListKongConsumerGroups returns all KongConsumerGroups filtered by the ingress.class annotation.

func (Store) ListKongConsumers

func (s Store) ListKongConsumers() []*kongv1.KongConsumer

ListKongConsumers returns all KongConsumers filtered by the ingress.class annotation.

func (Store) ListKongCustomEntities added in v3.2.0

func (s Store) ListKongCustomEntities() []*kongv1alpha1.KongCustomEntity

func (Store) ListKongPlugins

func (s Store) ListKongPlugins() []*kongv1.KongPlugin

ListKongPlugins lists all KongPlugins.

func (Store) ListKongVaults added in v3.1.0

func (s Store) ListKongVaults() []*kongv1alpha1.KongVault

func (Store) ListReferenceGrants

func (s Store) ListReferenceGrants() ([]*gatewayapi.ReferenceGrant, error)

ListReferenceGrants returns the list of ReferenceGrants in the ReferenceGrant cache store.

func (Store) ListTCPIngresses

func (s Store) ListTCPIngresses() ([]*kongv1beta1.TCPIngress, error)

ListTCPIngresses returns the list of TCP Ingresses from configuration.konghq.com group.

func (Store) ListTCPRoutes

func (s Store) ListTCPRoutes() ([]*gatewayapi.TCPRoute, error)

ListTCPRoutes returns the list of TCPRoutes in the TCPRoute cache store.

func (Store) ListTLSRoutes

func (s Store) ListTLSRoutes() ([]*gatewayapi.TLSRoute, error)

ListTLSRoutes returns the list of TLSRoutes in the TLSRoute cache store.

func (Store) ListUDPIngresses

func (s Store) ListUDPIngresses() ([]*kongv1beta1.UDPIngress, error)

ListUDPIngresses returns the list of UDP Ingresses.

func (Store) ListUDPRoutes

func (s Store) ListUDPRoutes() ([]*gatewayapi.UDPRoute, error)

ListUDPRoutes returns the list of UDPRoutes in the UDPRoute cache store.

func (*Store) UpdateCache added in v3.2.0

func (s *Store) UpdateCache(cs CacheStores)

UpdateCache updates the cache stores in the Store.

type Storer

type Storer interface {
	UpdateCache(cs CacheStores)

	GetSecret(namespace, name string) (*corev1.Secret, error)
	GetService(namespace, name string) (*corev1.Service, error)
	GetEndpointSlicesForService(namespace, name string) ([]*discoveryv1.EndpointSlice, error)
	GetKongIngress(namespace, name string) (*kongv1.KongIngress, error)
	GetKongPlugin(namespace, name string) (*kongv1.KongPlugin, error)
	GetKongClusterPlugin(name string) (*kongv1.KongClusterPlugin, error)
	GetKongConsumer(namespace, name string) (*kongv1.KongConsumer, error)
	GetKongConsumerGroup(namespace, name string) (*kongv1beta1.KongConsumerGroup, error)
	GetIngressClassName() string
	GetIngressClassV1(name string) (*netv1.IngressClass, error)
	GetIngressClassParametersV1Alpha1(ingressClass *netv1.IngressClass) (*kongv1alpha1.IngressClassParameters, error)
	GetGateway(namespace string, name string) (*gatewayapi.Gateway, error)
	GetKongUpstreamPolicy(namespace, name string) (*kongv1beta1.KongUpstreamPolicy, error)
	GetKongServiceFacade(namespace, name string) (*incubatorv1alpha1.KongServiceFacade, error)
	GetKongVault(name string) (*kongv1alpha1.KongVault, error)
	GetKongCustomEntity(namespace, name string) (*kongv1alpha1.KongCustomEntity, error)

	ListIngressesV1() []*netv1.Ingress
	ListIngressClassesV1() []*netv1.IngressClass
	ListIngressClassParametersV1Alpha1() []*kongv1alpha1.IngressClassParameters
	ListHTTPRoutes() ([]*gatewayapi.HTTPRoute, error)
	ListUDPRoutes() ([]*gatewayapi.UDPRoute, error)
	ListTCPRoutes() ([]*gatewayapi.TCPRoute, error)
	ListTLSRoutes() ([]*gatewayapi.TLSRoute, error)
	ListGRPCRoutes() ([]*gatewayapi.GRPCRoute, error)
	ListReferenceGrants() ([]*gatewayapi.ReferenceGrant, error)
	ListGateways() ([]*gatewayapi.Gateway, error)
	ListTCPIngresses() ([]*kongv1beta1.TCPIngress, error)
	ListUDPIngresses() ([]*kongv1beta1.UDPIngress, error)
	ListGlobalKongClusterPlugins() ([]*kongv1.KongClusterPlugin, error)
	ListKongPlugins() []*kongv1.KongPlugin
	ListKongClusterPlugins() []*kongv1.KongClusterPlugin
	ListKongConsumers() []*kongv1.KongConsumer
	ListKongConsumerGroups() []*kongv1beta1.KongConsumerGroup
	ListCACerts() ([]*corev1.Secret, error)
	ListKongVaults() []*kongv1alpha1.KongVault
	ListKongCustomEntities() []*kongv1alpha1.KongCustomEntity
}

Storer is the interface that wraps the required methods to gather information about ingresses, services, secrets and ingress annotations.

func NewFakeStore

func NewFakeStore(
	objects FakeObjects,
) (Storer, error)

NewFakeStore creates a store backed by the objects passed in as arguments.

Jump to

Keyboard shortcuts

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