...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/gateway/compilation_units.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/gateway

     1  package gateway
     2  
     3  import (
     4  	v3cluster "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/cluster/v3"
     5  	v3endpoint "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/endpoint/v3"
     6  	v3listener "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/listener/v3"
     7  	v3route "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/route/v3"
     8  	gw "sigs.k8s.io/gateway-api/apis/v1alpha1"
     9  )
    10  
    11  // The types in this file primarily decorate envoy configuration with pointers back to Sources
    12  // and/or error messages. In the case of CompiledListener there are some additional fields that
    13  // allow the Dispatcher to automatically assemble RouteConfigurations for a given v2.Listener.
    14  
    15  // CompiledItem has fields common to all compilation units.
    16  type CompiledItem struct {
    17  	Source    Source // Tracks the source of truth for whatever produced this compiled item.
    18  	Namespace string // The namespace of whatever produced this item.
    19  	Error     string // Holds any error associated with this compiled item.
    20  }
    21  
    22  func NewCompiledItem(source Source) CompiledItem {
    23  	return CompiledItem{Source: source}
    24  }
    25  
    26  func NewCompiledItemError(source Source, error string) CompiledItem {
    27  	return CompiledItem{Source: source, Error: error}
    28  }
    29  
    30  // CompiledConfig can hold any amount of any kind of envoy configuration fragments. All compile
    31  // functions produce this type.
    32  type CompiledConfig struct {
    33  	CompiledItem
    34  	Listeners       []*CompiledListener
    35  	Routes          []*CompiledRoute
    36  	Clusters        []*CompiledCluster
    37  	LoadAssignments []*CompiledLoadAssignment
    38  }
    39  
    40  // CompiledListener is an envoy Listener plus a Predicate that the dispatcher uses to determine
    41  // which routes to supply to the listener.
    42  type CompiledListener struct {
    43  	CompiledItem
    44  	Listener *v3listener.Listener
    45  
    46  	// The predicate determines which routes belong to which listeners. If the listener specifies
    47  	// and Rds configuration, this Predicate and the Domains below will be used to construct a
    48  	// RouteConfiguration from all the available CompiledRoutes.
    49  	Predicate func(route *CompiledRoute) bool
    50  	Domains   []string
    51  }
    52  
    53  // CompiledRoute is
    54  type CompiledRoute struct {
    55  	CompiledItem
    56  
    57  	// This field will likely get replaced with something more astract, e.g. just info about the
    58  	// source such as labels kind, namespace, name, etc.
    59  	HTTPRoute *gw.HTTPRoute
    60  
    61  	Routes      []*v3route.Route
    62  	ClusterRefs []*ClusterRef
    63  }
    64  
    65  // ClusterRef represents a reference to an envoy v2.Cluster.
    66  type ClusterRef struct {
    67  	CompiledItem
    68  	Name string
    69  
    70  	// These are temporary fields to deal with how endpoints are currently plumbed from the watcher
    71  	// through to ambex.
    72  	EndpointPath string
    73  }
    74  
    75  // CompiledCluster decorates an envoy v2.Cluster.
    76  type CompiledCluster struct {
    77  	CompiledItem
    78  	Cluster *v3cluster.Cluster
    79  }
    80  
    81  // CompiledLoadAssignment decorates an envoy v2.ClusterLoadAssignment.
    82  type CompiledLoadAssignment struct {
    83  	CompiledItem
    84  	LoadAssignment *v3endpoint.ClusterLoadAssignment
    85  }
    86  

View as plain text