...

Source file src/github.com/datawire/ambassador/v2/pkg/gateway/compilation_units.go

Documentation: github.com/datawire/ambassador/v2/pkg/gateway

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

View as plain text