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