translator

package
v1.2.21 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 24 Imported by: 4

Documentation

Index

Constants

View Source
const GatewayProxyName = defaults.GatewayProxyName

deprecated, use defaults.GatewayProxyName

Variables

View Source
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, conflictingVsNames []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", conflictingVsNames)
		}
		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, conflictingVsNames)
	}
	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)
	}
)
View Source
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")
	HasHeaderMatcherErr = errors.New("invalid route: routes with delegate actions cannot use header matchers")
	HasMethodMatcherErr = errors.New("invalid route: routes with delegate actions cannot use method matchers")
	HasQueryMatcherErr  = errors.New("invalid route: routes with delegate actions cannot use query matchers")
	DelegationCycleErr  = func(cycleInfo string) error {
		return errors.Errorf("invalid route: delegation cycle detected: %s", cycleInfo)
	}

	NoDelegateActionErr = errors.New("internal error: convertDelegateAction() called on route without delegate action")

	RouteTableMissingWarning = func(ref core.ResourceRef) string {
		return fmt.Sprintf("route table %v.%v missing", ref.Namespace, ref.Name)
	}
	NoMatchingRouteTablesWarning    = "no route table matches the given selector"
	InvalidRouteTableForDelegateErr = func(delegatePrefix, pathString string) error {
		return errors.Wrapf(InvalidPrefixErr, "required prefix: %v, path: %v", delegatePrefix, pathString)
	}
	MissingRefAndSelectorWarning = func(res resources.InputResource) string {
		ref := res.GetMetadata().Ref()
		return fmt.Sprintf("cannot determine delegation target for %T %s.%s: you must specify a route table "+
			"either via a resource reference or a selector", res, ref.Namespace, ref.Name)
	}
)

Functions

func ForEachSource added in v1.0.0

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

func GatewayContainsVirtualService added in v0.19.0

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

func ListenerName added in v1.0.0

func ListenerName(gateway *v1.Gateway) string

func NewDefaultTranslator added in v0.19.0

func NewDefaultTranslator(opts Opts) *translator

func NewTranslator added in v0.18.0

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

func VirtualHostName added in v1.0.0

func VirtualHostName(vs *v1.VirtualService) string

Types

type HttpTranslator added in v0.18.0

type HttpTranslator struct{}

func (*HttpTranslator) GenerateListeners added in v0.18.0

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

type ListenerFactory added in v0.18.0

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

type ObjectWithMetadata added in v1.0.0

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

type Opts added in v1.0.0

type Opts struct {
	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 added in v1.2.15

type RouteConverter interface {
	// Converts a Gateway API route (i.e. a route on RouteTables/VirtualServices)
	// to one or more Gloo API routes (i.e. routes on a Proxy resource).
	// Can return multiple routes only if the input route uses delegation.
	ConvertRoute(route *gatewayv1.Route) ([]*gloov1.Route, error)
}

func NewRouteConverter added in v1.2.15

Initializes and returns a route converter instance. - root: root of the subtree of routes that we are going to visit; used primarily as a target to report errors and warnings on. - tables: all the route tables that should be considered when resolving delegation chains. - reports: this object will be updated with errors and warnings encountered during the conversion process.

type SourceMetadata added in v1.0.0

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

func GetSourceMeta added in v1.0.0

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

func SourceMetaFromStruct added in v1.0.0

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

type SourceRef added in v0.18.41

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

type TcpTranslator added in v0.18.0

type TcpTranslator struct{}

func (*TcpTranslator) GenerateListeners added in v0.18.0

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

type Translator added in v0.18.0

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

type ValidationOpts added in v1.0.0

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

Jump to

Keyboard shortcuts

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