xds

package
v0.0.0-...-25e6f9d Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package xds contains the implementation for the xds server cache updates

Index

Constants

This section is empty.

Variables

View Source
var (

	// KeyManagerList to store data
	KeyManagerList = make([]eventhubTypes.KeyManager, 0)
)
View Source
var (

	// RequestEventChannel is the channel which communicates between callback and the server
	RequestEventChannel chan RequestEvent
)

Functions

func DeleteAPI

func DeleteAPI(uuid string, gatewayNames map[string]struct{}) error

DeleteAPI deletes API with the given UUID from the given gw environments

func ExtractUUIDFromAPIIdentifier

func ExtractUUIDFromAPIIdentifier(id string) (string, error)

ExtractUUIDFromAPIIdentifier extracts UUID from the API identifier

func ExtractVhostFromAPIIdentifier

func ExtractVhostFromAPIIdentifier(id string) (string, error)

ExtractVhostFromAPIIdentifier extracts vhost from the API identifier

func GenerateEnvoyResoucesForGateway

func GenerateEnvoyResoucesForGateway(gatewayName string) ([]types.Resource,
	[]types.Resource, []types.Resource, []types.Resource, []types.Resource)

GenerateEnvoyResoucesForGateway generates envoy resources for a given gateway This method will list out all APIs mapped to the label. and generate envoy resources for all of these APIs.

func GenerateGlobalClusters

func GenerateGlobalClusters(label string)

GenerateGlobalClusters generates the globally available clusters and endpoints.

func GenerateHashedAPINameVersionIDWithoutVhost

func GenerateHashedAPINameVersionIDWithoutVhost(name, version string) string

GenerateHashedAPINameVersionIDWithoutVhost generates a hashed identifier unique to the API Name and Version

func GenerateIdentifierForAPI

func GenerateIdentifierForAPI(vhost, name, version string) string

GenerateIdentifierForAPI generates an identifier unique to the API

func GenerateIdentifierForAPIWithUUID

func GenerateIdentifierForAPIWithUUID(vhost, uuid string) string

GenerateIdentifierForAPIWithUUID generates an identifier unique to the API

func GenerateIdentifierForAPIWithoutVersion

func GenerateIdentifierForAPIWithoutVersion(vhost, name string) string

GenerateIdentifierForAPIWithoutVersion generates an identifier unique to the API despite of the version

func GenerateIdentifierForAPIWithoutVhost

func GenerateIdentifierForAPIWithoutVhost(name, version string) string

GenerateIdentifierForAPIWithoutVhost generates an identifier unique to the API name and version

func GenerateInterceptorClusters

func GenerateInterceptorClusters(label string,
	gwReqICluster *clusterv3.Cluster, gwReqIAddresses []*corev3.Address,
	gwResICluster *clusterv3.Cluster, gwResIAddresses []*corev3.Address)

GenerateInterceptorClusters generates the globally available clusters and endpoints with interceptors.

func GetEnforcerAPICache

func GetEnforcerAPICache() wso2_cache.SnapshotCache

GetEnforcerAPICache returns xds server cache.

func GetEnforcerApplicationPolicyCache

func GetEnforcerApplicationPolicyCache() wso2_cache.SnapshotCache

GetEnforcerApplicationPolicyCache returns xds server cache.

func GetEnforcerCache

func GetEnforcerCache() wso2_cache.SnapshotCache

GetEnforcerCache returns xds server cache.

func GetEnforcerJWTIssuerCache

func GetEnforcerJWTIssuerCache() wso2_cache.SnapshotCache

GetEnforcerJWTIssuerCache returns xds server cache.

func GetEnforcerKeyManagerCache

func GetEnforcerKeyManagerCache() wso2_cache.SnapshotCache

GetEnforcerKeyManagerCache returns xds server cache.

func GetEnforcerRevokedTokenCache

func GetEnforcerRevokedTokenCache() wso2_cache.SnapshotCache

GetEnforcerRevokedTokenCache return token cache

func GetEnforcerSubscriptionPolicyCache

func GetEnforcerSubscriptionPolicyCache() wso2_cache.SnapshotCache

GetEnforcerSubscriptionPolicyCache returns xds server cache.

func GetEnforcerThrottleDataCache

func GetEnforcerThrottleDataCache() wso2_cache.SnapshotCache

GetEnforcerThrottleDataCache return throttle data cache

func GetEnvoyGatewayConfigClusters

func GetEnvoyGatewayConfigClusters() int

GetEnvoyGatewayConfigClusters method gets the number of clusters in envoy gateway config

func GetEnvoyInternalAPIClusters

func GetEnvoyInternalAPIClusters() int

GetEnvoyInternalAPIClusters method gets the number of clusters in envoy internal API

func GetEnvoyInternalAPICount

func GetEnvoyInternalAPICount() int

GetEnvoyInternalAPICount method gets the number of APIs deployed in Envoy

func GetEnvoyInternalAPIRoutes

func GetEnvoyInternalAPIRoutes() int

GetEnvoyInternalAPIRoutes method gets the number of routes in envoy internal API

func GetLastSuccessState

func GetLastSuccessState(label string) (*EnforcerAPIState, *RouterResourceState)

GetLastSuccessState returns the successful enforcer state and router state which belongs to the provided label

func GetMajorMinorVersionRangeRegex

func GetMajorMinorVersionRangeRegex(semVersion *semantic_version.SemVersion) string

GetMajorMinorVersionRangeRegex generates major and minor version compatible range regex for the given version

func GetMajorVersionRange

func GetMajorVersionRange(semVersion semantic_version.SemVersion) string

GetMajorVersionRange generates major version range for the given version

func GetMinorVersionRange

func GetMinorVersionRange(semVersion semantic_version.SemVersion) string

GetMinorVersionRange generates minor version range for the given version

func GetMinorVersionRangeRegex

func GetMinorVersionRangeRegex(semVersion *semantic_version.SemVersion) string

GetMinorVersionRangeRegex generates minor version compatible range regex for the given version

func GetRequestEventChannel

func GetRequestEventChannel() chan RequestEvent

GetRequestEventChannel returns the state change channel. RequestEventChannel should be a singleton object

func GetVersionMatchRegex

func GetVersionMatchRegex(version string) string

GetVersionMatchRegex returns the regex to match the full version string

func GetXdsCache

func GetXdsCache() envoy_cachev3.SnapshotCache

GetXdsCache returns xds server cache.

func GetvHostsIdentifier

func GetvHostsIdentifier(UUID string, envType string) string

GetvHostsIdentifier creates a identifier for vHosts for a API considering prod and sand env

func IsSemanticVersioningEnabled

func IsSemanticVersioningEnabled(apiName, apiVersion string) bool

IsSemanticVersioningEnabled checks whether semantic versioning is enabled for the given API

func MarshalConfig

func MarshalConfig(config *config.Config) *enforcer.Config

MarshalConfig will marshal a Config struct - read from the config toml - to enfocer's CDS resource representation.

func PopulateInternalMaps

func PopulateInternalMaps(adapterInternalAPI *model.AdapterInternalAPI, labels, vHosts map[string]struct{}, sectionName, listenerName string) error

PopulateInternalMaps populates the internal maps from the GQLRoute.

func RemoveAPIFromAllInternalMaps

func RemoveAPIFromAllInternalMaps(uuid string) map[string]struct{}

RemoveAPIFromAllInternalMaps removes api from all maps

func SanitizeGateway

func SanitizeGateway(gatewayName string, create bool) error

SanitizeGateway method sanitizes the gateway name

func SetReady

func SetReady()

SetReady Method to set the status after the last api is fected and updated in router.

func SetSuccessState

func SetSuccessState(label string, enforerSuccessState EnforcerAPIState, routerSuccessState RouterResourceState)

SetSuccessState set the last successful state of enforcer and router

func UpdateEnforcerApis

func UpdateEnforcerApis(label string, apis []types.Resource, version string)

UpdateEnforcerApis Sets new update to the enforcer's Apis

func UpdateEnforcerConfig

func UpdateEnforcerConfig(configFile *config.Config)

UpdateEnforcerConfig Sets new update to the enforcer's configuration

func UpdateEnforcerJWTIssuers

func UpdateEnforcerJWTIssuers(jwtIssuers *subscription.JWTIssuerList)

UpdateEnforcerJWTIssuers sets new update to the enforcer's Applications

func UpdateGatewayCache

func UpdateGatewayCache(gateway *gwapiv1b1.Gateway, resolvedListenerCerts map[string]map[string][]byte,
	gwLuaScript string, customRateLimitPolicies []*model.CustomRateLimitPolicy) error

UpdateGatewayCache updates the xDS cache related to the Gateway Lifecycle event.

func UpdateOrgAPIMap

func UpdateOrgAPIMap(vHosts, newLabels map[string]struct{}, listener string, sectionName string,
	adapterInternalAPI *model.AdapterInternalAPI) error

UpdateOrgAPIMap updates the xDS cache related to the API Lifecycle event.

func UpdateXdsCacheOnAPIChange

func UpdateXdsCacheOnAPIChange(labels map[string]struct{}) bool

UpdateXdsCacheOnAPIChange when this method is called, openAPIEnvoy map is updated. Old labels refers to the previously assigned labels New labels refers to the the updated labels

func UpdateXdsCacheWithLock

func UpdateXdsCacheWithLock(label string, endpoints []types.Resource, clusters []types.Resource, routes []types.Resource,
	listeners []types.Resource) bool

UpdateXdsCacheWithLock uses mutex and lock to avoid different go routines updating XDS at the same time

Types

type EnforcerAPIState

type EnforcerAPIState struct {
	OpenAPIEnforcerApisMap   map[string]types.Resource
	APIUUIDToGatewayToVhosts map[string]map[string]string
	APIToVhostsMap           map[string]map[string]struct{}
	Version                  string
}

EnforcerAPIState Stores the last success state of the enforcer apis

type EnforcerInternalAPI

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

EnforcerInternalAPI struct use to hold enforcer resources

type EnvoyGatewayConfig

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

EnvoyGatewayConfig struct use to hold envoy gateway resources

type EnvoyInternalAPI

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

EnvoyInternalAPI struct use to hold envoy resources and adapter internal resources

type EventType

type EventType int

EventType is a enum to distinguish Create, Update and Delete Events

const (
	// CreateEvent : enum
	CreateEvent EventType = iota
	// UpdateEvent : enum
	UpdateEvent
	// DeleteEvent : enum
	DeleteEvent
)

type IDHash

type IDHash struct{}

IDHash uses ID field as the node hash.

func (IDHash) ID

func (IDHash) ID(node *corev3.Node) string

ID uses the node ID field

type RequestEvent

type RequestEvent struct {
	IsError bool
	Version string
	Node    string
}

RequestEvent is the event that is published by the xds callback (onStreamRequest)

func NewRequestEvent

func NewRequestEvent() RequestEvent

NewRequestEvent create new change event

type RouterResourceState

type RouterResourceState struct {
	APIRoutesMap           map[string][]*routev3.Route     // Envoy Routes map
	APIClustersMap         map[string][]*clusterv3.Cluster // Envoy Clusters map
	APIEndpointsMap        map[string][]*corev3.Address
	EnvoyListenerConfigMap map[string][]*listenerv3.Listener // Listener Configuration map
	EnvoyRouteConfigMap    map[string]*routev3.RouteConfiguration
	Version                string
}

RouterResourceState Stores the last successful state of the router resources

Directories

Path Synopsis
Package common includes the common functions shared between enforcer and router callbacks.
Package common includes the common functions shared between enforcer and router callbacks.

Jump to

Keyboard shortcuts

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