Back to godoc.org

Package translator

v1.5.0
Latest Go to latest

The latest major version is .

Published: 2 hours ago | License: Apache-2.0 | Module: github.com/solo-io/gloo

Index

Constants

const GatewayProxyName = defaults.GatewayProxyName

deprecated, use defaults.GatewayProxyName

Variables

var (
	NoActionErr          = errors.New("invalid route: route must specify an action")
	MatcherCountErr      = errors.New("invalid route: routes with delegate actions must omit or specify a single matcher")
	MissingPrefixErr     = errors.New("invalid route: routes with delegate actions must use a prefix matcher")
	InvalidPrefixErr     = errors.New("invalid route: route table matchers must begin with the prefix of their parent route's matcher")
	InvalidHeaderErr     = errors.New("invalid route: route table matchers must have all headers that were specified on their parent route's matcher")
	InvalidQueryParamErr = errors.New("invalid route: route table matchers must have all query params that were specified on their parent route's matcher")
	InvalidMethodErr     = errors.New("invalid route: route table matchers must have all methods that were specified on their parent route's matcher")

	DelegationCycleErr = func(cycleInfo string) error {
		return errors.Errorf("invalid route: delegation cycle detected: %s", cycleInfo)
	}
	InvalidRouteTableForDelegatePrefixErr = func(delegatePrefix, prefixString string) error {
		return errors.Wrapf(InvalidPrefixErr, "required prefix: %v, prefix: %v", delegatePrefix, prefixString)
	}
	InvalidRouteTableForDelegateHeadersErr = func(delegateHeaders, childHeaders []*matchersv1.HeaderMatcher) error {
		return errors.Wrapf(InvalidHeaderErr, "required headers: %v, headers: %v", delegateHeaders, childHeaders)
	}
	InvalidRouteTableForDelegateQueryParamsErr = func(delegateQueryParams, childQueryParams []*matchersv1.QueryParameterMatcher) error {
		return errors.Wrapf(InvalidQueryParamErr, "required query params: %v, query params: %v", delegateQueryParams, childQueryParams)
	}
	InvalidRouteTableForDelegateMethodsErr = func(delegateMethods, childMethods []string) error {
		return errors.Wrapf(InvalidMethodErr, "required methods: %v, methods: %v", delegateMethods, childMethods)
	}
	TopLevelVirtualResourceErr = func(rtRef core.Metadata, err error) error {
		return errors.Wrapf(err, "on sub route table %s", rtRef.Ref().Key())
	}
)
var (
	NoVirtualHostErr = func(vs *v1.VirtualService) error {
		return errors.Errorf("virtual service [%s] does not specify a virtual host", vs.Metadata.Ref().Key())
	}
	DomainInOtherVirtualServicesErr = func(domain string, conflictingVsRefs []string) error {
		if domain == "" {
			return errors.Errorf("domain conflict: other virtual services that belong to the same Gateway"+
				" as this one don't specify a domain (and thus default to '*'): %v", conflictingVsRefs)
		}
		return errors.Errorf("domain conflict: the [%s] domain is present in other virtual services "+
			"that belong to the same Gateway as this one: %v", domain, conflictingVsRefs)
	}
	GatewayHasConflictingVirtualServicesErr = func(conflictingDomains []string) error {
		var loggedDomains []string
		for _, domain := range conflictingDomains {
			if domain == "" {
				domain = "EMPTY_DOMAIN"
			}
			loggedDomains = append(loggedDomains, domain)
		}
		return errors.Errorf("domain conflict: the following domains are present in more than one of the "+
			"virtual services associated with this gateway: %v", loggedDomains)
	}
)
var (
	RouteTableMissingWarning = func(ref core.ResourceRef) error {
		return errors.Errorf("route table %v.%v missing", ref.Namespace, ref.Name)
	}
	NoMatchingRouteTablesWarning = errors.New("no route table matches the given selector")
	MissingRefAndSelectorWarning = errors.New("cannot determine delegation target: you must specify a route table " +
		"either via a resource reference or a selector")
	RouteTableSelectorExpressionsAndLabelsWarning = errors.New("cannot use both labels and expressions within the " +
		"same selector")
	RouteTableSelectorInvalidExpressionWarning = errors.New("the route table selector expression is invalid")

	// Map connecting Gloo Route Tables expression operator values and Kubernetes expression operator string values.
	RouteTableExpressionOperatorValues = map[gatewayv1.RouteTableSelector_Expression_Operator]selection.Operator{
		gatewayv1.RouteTableSelector_Expression_Equals:       selection.Equals,
		gatewayv1.RouteTableSelector_Expression_DoubleEquals: selection.DoubleEquals,
		gatewayv1.RouteTableSelector_Expression_NotEquals:    selection.NotEquals,
		gatewayv1.RouteTableSelector_Expression_In:           selection.In,
		gatewayv1.RouteTableSelector_Expression_NotIn:        selection.NotIn,
		gatewayv1.RouteTableSelector_Expression_Exists:       selection.Exists,
		gatewayv1.RouteTableSelector_Expression_DoesNotExist: selection.DoesNotExist,
		gatewayv1.RouteTableSelector_Expression_GreaterThan:  selection.GreaterThan,
		gatewayv1.RouteTableSelector_Expression_LessThan:     selection.LessThan,
	}
)

func ForEachSource

func ForEachSource(obj ObjectWithMetadata, fn func(source SourceRef) error) error

func GatewayContainsVirtualService

func GatewayContainsVirtualService(gateway *v1.Gateway, virtualService *v1.VirtualService) bool

func ListenerName

func ListenerName(gateway *v1.Gateway) string

func NewDefaultTranslator

func NewDefaultTranslator(opts Opts) *translator

func NewTranslator

func NewTranslator(factories []ListenerFactory, opts Opts) *translator

func RouteTableLabelsMatchesExpressionRequirements

func RouteTableLabelsMatchesExpressionRequirements(requirements labels.Requirements, rtLabels labels.Set) bool

Asserts that the route table labels matches all of the expression requirements (logical AND).

func RouteTablesForSelector

func RouteTablesForSelector(routeTables gatewayv1.RouteTableList, selector *gatewayv1.RouteTableSelector, ownerNamespace string) (gatewayv1.RouteTableList, error)

Returns the subset of `routeTables` that matches the given `selector`. Search will be restricted to the `ownerNamespace` if the selector does not specify any namespaces.

func VirtualHostName

func VirtualHostName(vs *v1.VirtualService) string

type HttpTranslator

type HttpTranslator struct{}

func (*HttpTranslator) GenerateListeners

func (t *HttpTranslator) GenerateListeners(ctx context.Context, snap *v1.ApiSnapshot, filteredGateways []*v1.Gateway, reports reporter.ResourceReports) []*gloov1.Listener

type ListenerFactory

type ListenerFactory interface {
	GenerateListeners(ctx context.Context, snap *v1.ApiSnapshot, filteredGateways []*v1.Gateway, reports reporter.ResourceReports) []*gloov1.Listener
}

type ObjectWithMetadata

type ObjectWithMetadata interface {
	GetMetadata() *types.Struct
}

type Opts

type Opts struct {
	GlooNamespace                 string
	WriteNamespace                string
	WatchNamespaces               []string
	Gateways                      factory.ResourceClientFactory
	VirtualServices               factory.ResourceClientFactory
	RouteTables                   factory.ResourceClientFactory
	Proxies                       factory.ResourceClientFactory
	WatchOpts                     clients.WatchOpts
	ValidationServerAddress       string
	DevMode                       bool
	ReadGatewaysFromAllNamespaces bool
	Validation                    *ValidationOpts
}

type RouteConverter

type RouteConverter interface {
	// Converts a VirtualService to a set of Gloo API routes (i.e. routes on a Proxy resource).
	// A non-nil error indicates an unexpected internal failure, all configuration errors are added to the given report object.
	ConvertVirtualService(virtualService *gatewayv1.VirtualService, reports reporter.ResourceReports) ([]*gloov1.Route, error)
}

func NewRouteConverter

func NewRouteConverter(selector RouteTableSelector, indexer RouteTableIndexer) RouteConverter

type RouteTableIndexer

type RouteTableIndexer interface {
	// Indexes the given route tables by weight and returns them as a map.
	// The map key set is also returned as a sorted array so the client can range over the map in the desired order.
	// The error slice contain warning about route tables with duplicated weights.
	IndexByWeight(routeTables v1.RouteTableList) (map[int32]v1.RouteTableList, []int32)
}

func NewRouteTableIndexer

func NewRouteTableIndexer() RouteTableIndexer

type RouteTableSelector

type RouteTableSelector interface {
	SelectRouteTables(action *gatewayv1.DelegateAction, parentNamespace string) (gatewayv1.RouteTableList, error)
}

func NewRouteTableSelector

func NewRouteTableSelector(allRouteTables gatewayv1.RouteTableList) RouteTableSelector

type SourceMetadata

type SourceMetadata struct {
	Sources []SourceRef `json:"sources"`
}

func GetSourceMeta

func GetSourceMeta(obj ObjectWithMetadata) (*SourceMetadata, error)

func SourceMetaFromStruct

func SourceMetaFromStruct(s *types.Struct) (*SourceMetadata, error)

type SourceRef

type SourceRef struct {
	core.ResourceRef
	ResourceKind       string `json:"kind"`
	ObservedGeneration int64  `json:"observedGeneration"`
}

type TcpTranslator

type TcpTranslator struct{}

func (*TcpTranslator) GenerateListeners

func (t *TcpTranslator) GenerateListeners(ctx context.Context, snap *v1.ApiSnapshot, filteredGateways []*v1.Gateway, reports reporter.ResourceReports) []*gloov1.Listener

type Translator

type Translator interface {
	Translate(ctx context.Context, proxyName, namespace string, snap *v1.ApiSnapshot, filteredGateways v1.GatewayList) (*gloov1.Proxy, reporter.ResourceReports)
}

go:generate mockgen -destination mocks/mock_translator.go -package mocks github.com/solo-io/gloo/projects/gateway/pkg/translator Translator

type ValidationOpts

type ValidationOpts struct {
	ProxyValidationServerAddress string
	ValidatingWebhookPort        int
	ValidatingWebhookCertPath    string
	ValidatingWebhookKeyPath     string
	IgnoreProxyValidationFailure bool
	AlwaysAcceptResources        bool
	AllowWarnings                bool
}

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier