forked from amalgam8/amalgam8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.go
294 lines (255 loc) · 10.4 KB
/
resources.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// Copyright 2016 IBM Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package envoy
// AbortFilter definition.
type AbortFilter struct {
Percent int `json:"abort_percent,omitempty"`
HTTPStatus int `json:"http_status,omitempty"`
}
// DelayFilter definition.
type DelayFilter struct {
Type string `json:"type,omitempty"`
Percent int `json:"fixed_delay_percent,omitempty"`
Duration int `json:"fixed_duration_ms,omitempty"`
}
// GRPCHTTP1BridgeFilter definition
type GRPCHTTP1BridgeFilter struct{}
// Header definition.
// See: https://lyft.github.io/envoy/docs/configuration/http_filters/fault_filter.html#config-http-filters-fault-injection-headers
type Header struct {
Name string `json:"name"`
Value string `json:"value"`
Regex bool `json:"regex"`
}
// FilterFaultConfig definition.
// See: https://lyft.github.io/envoy/docs/configuration/http_filters/fault_filter.html
type FilterFaultConfig struct {
Abort *AbortFilter `json:"abort,omitempty"`
Delay *DelayFilter `json:"delay,omitempty"`
Headers []Header `json:"headers,omitempty"`
}
// FilterRouterConfig definition.
type FilterRouterConfig struct {
DynamicStats bool `json:"dynamic_stats"`
}
// Filter definition.
type Filter struct {
Type string `json:"type"`
Name string `json:"name"`
Config interface{} `json:"config"`
}
// Runtime definition.
type Runtime struct {
Key string `json:"key"`
Default int `json:"default"`
}
// RetryPolicy definition
// See: https://lyft.github.io/envoy/docs/configuration/http_conn_man/route_config/route.html#retry-policy
type RetryPolicy struct {
Policy string `json:"retry_on"` //5xx,connect-failure,refused-stream
NumRetries int `json:"num_retries,omitempty"`
}
// WeightedCluster definition
// See: https://lyft.github.io/envoy/docs/configuration/http_conn_man/route_config/route.html#weighted-clusters
type WeightedCluster struct {
Name string `json:"name"`
Weight int `json:"weight"`
}
// WeightedClusters definition
// See: https://lyft.github.io/envoy/docs/configuration/http_conn_man/route_config/route.html#weighted-clusters
type WeightedClusters struct {
Clusters []WeightedCluster `json:"clusters"`
RunTimeKeyPrefix string `json:"runtime_key_prefix,omitempty"`
}
// Route definition.
// See: https://lyft.github.io/envoy/docs/configuration/http_conn_man/route_config/route.html#config-http-conn-man-route-table-route
type Route struct {
Runtime *Runtime `json:"runtime,omitempty"`
Path string `json:"path,omitempty"`
Prefix string `json:"prefix,omitempty"`
PrefixRewrite string `json:"prefix_rewrite,omitempty"`
WeightedClusters WeightedClusters `json:"weighted_clusters,omitempty"`
Cluster string `json:"cluster,omitempty"`
Headers []Header `json:"headers,omitempty"`
TimeoutMS int `json:"timeout_ms,omitempty"`
RetryPolicy RetryPolicy `json:"retry_policy"`
AutoHostRewrite bool `json:"auto_host_rewrite,omitempty"`
}
// VirtualHost definition.
// See: https://lyft.github.io/envoy/docs/configuration/http_conn_man/route_config/vhost.html#config-http-conn-man-route-table-vhost
type VirtualHost struct {
Name string `json:"name"`
Domains []string `json:"domains"`
Routes []Route `json:"routes"`
}
// TCPRoute definition
type TCPRoute struct {
Cluster string `json:"cluster"`
DestinationIPList []string `json:"destination_ip_list,omitempty"`
DestinationPorts string `json:"destination_ports,omitempty"`
SourceIPList []string `json:"source_ip_list,omitempty"`
SourcePorts string `json:"source_ports,omitempty"`
}
// HTTPRouteConfig definition.
// See: https://lyft.github.io/envoy/docs/configuration/http_conn_man/route_config/route_config.html#config-http-conn-man-route-table
type HTTPRouteConfig struct {
VirtualHosts []VirtualHost `json:"virtual_hosts"`
}
// TCPRouteConfig definition
type TCPRouteConfig struct {
Routes []TCPRoute `json:"routes"`
}
// AccessLog definition.
type AccessLog struct {
Path string `json:"path"`
Format string `json:"format,omitempty"`
Filter string `json:"filter,omitempty"`
}
// RDS definition
// See: https://lyft.github.io/envoy/docs/configuration/http_conn_man/rds.html#config-http-conn-man-rds
type RDS struct {
Cluster string `json:"cluster"`
RefreshDelayMS int `json:"refresh_delay_ms"`
RouteConfigName string `json:"route_config_name"`
}
// HTTPFilterConfig definition.
type HTTPFilterConfig struct {
CodecType string `json:"codec_type"`
StatPrefix string `json:"stat_prefix"`
GenerateRequestID bool `json:"generate_request_id"`
UserAgent bool `json:"add_user_agent"`
RouteConfig *HTTPRouteConfig `json:"route_config,omitempty"`
RDS *RDS `json:"rds,omitempty"`
Filters []Filter `json:"filters"`
AccessLog []AccessLog `json:"access_log"`
}
// TCPFilterConfig definition
type TCPFilterConfig struct {
StatPrefix string `json:"stat_prefix"`
RouteConfig *TCPRouteConfig `json:"route_config"`
}
// NetworkFilter definition.
// See: https://lyft.github.io/envoy/docs/configuration/listeners/filters.html#config-listener-filters
type NetworkFilter struct {
Type string `json:"type"`
Name string `json:"name"`
Config interface{} `json:"config"`
}
// SSLContext defintion
// See: https://lyft.github.io/envoy/docs/configuration/listeners/ssl.html#config-listener-ssl-context
type SSLContext struct {
CertChainFile string `json:"cert_chain_file"`
PrivateKeyFile string `json:"private_key_file"`
CACertFile *string `json:"ca_cert_file,omitempty"`
}
// Listener definition.
// See: https://lyft.github.io/envoy/docs/configuration/listeners/listeners.html#config-listeners
type Listener struct {
Port int `json:"port"`
Filters []NetworkFilter `json:"filters"`
SSLContext *SSLContext `json:"ssl_context,omitempty"`
}
// Admin definition.
// See: https://lyft.github.io/envoy/docs/configuration/overview/admin.html#config-admin
type Admin struct {
AccessLogPath string `json:"access_log_path"`
Port int `json:"port"`
}
// Host definition.
type Host struct {
URL string `json:"url"`
}
// Cluster definition.
// See: https://lyft.github.io/envoy/docs/configuration/cluster_manager/cluster.html#config-cluster-manager-cluster
type Cluster struct {
Name string `json:"name"`
ServiceName string `json:"service_name,omitempty"`
ConnectTimeoutMs int `json:"connect_timeout_ms"`
Type string `json:"type"`
LbType string `json:"lb_type"`
MaxRequestsPerConnection int `json:"max_requests_per_connection,omitempty"`
Hosts []Host `json:"hosts,omitempty"`
CircuitBreakers *CircuitBreakers `json:"circuit_breakers,omitempty"`
OutlierDetection *OutlierDetection `json:"outlier_detection,omitempty"`
SSLContext *SSLContext `json:"ssl_context,omitempty"`
}
// OutlierDetection definition
// See: https://lyft.github.io/envoy/docs/configuration/cluster_manager/cluster_runtime.html#outlier-detection
type OutlierDetection struct {
ConsecutiveError int `json:"consecutive_5xx,omitempty"`
IntervalMS int `json:"interval_ms,omitempty"`
BaseEjectionTimeMS int `json:"base_ejection_time_ms,omitempty"`
MaxEjectionPercent int `json:"max_ejection_percent,omitempty"`
}
// DefaultCB definition
// See: https://lyft.github.io/envoy/docs/configuration/cluster_manager/cluster_circuit_breakers.html#config-cluster-manager-cluster-circuit-breakers
type DefaultCB struct {
MaxConnections int `json:"max_connections,omitempty"`
MaxPendingRequest int `json:"max_pending_requests,omitempty"`
MaxRequests int `json:"max_requests,omitempty"`
MaxRetries int `json:"max_retries,omitempty"`
}
// CircuitBreakers definition
// See: https://lyft.github.io/envoy/docs/configuration/cluster_manager/cluster_circuit_breakers.html#circuit-breakers
type CircuitBreakers struct {
Default DefaultCB `json:"default,omitempty"`
}
// ClustersByName implements name based sort for clusters.
type ClustersByName []Cluster
// Len length.
func (s ClustersByName) Len() int {
return len(s)
}
// Swap elements.
func (s ClustersByName) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Less compare elements.
func (s ClustersByName) Less(i, j int) bool {
return s[i].Name < s[j].Name
}
// SDS definition.
// See: https://lyft.github.io/envoy/docs/configuration/cluster_manager/sds.html#config-cluster-manager-sds
type SDS struct {
Cluster Cluster `json:"cluster"`
RefreshDelayMs int `json:"refresh_delay_ms"`
}
// CDS definition
// See: https://lyft.github.io/envoy/docs/configuration/cluster_manager/cds.html#config-cluster-manager-cds
type CDS struct {
Cluster Cluster `json:"cluster"`
RefreshDelayMs int `json:"refresh_delay_ms"`
}
// ClusterManager definition.
// See: https://lyft.github.io/envoy/docs/configuration/cluster_manager/cluster_manager.html#config-cluster-manager
type ClusterManager struct {
Clusters []Cluster `json:"clusters"`
SDS SDS `json:"sds"`
CDS CDS `json:"cds"`
}
// RootRuntime definition.
// See: https://lyft.github.io/envoy/docs/configuration/overview/overview.html
type RootRuntime struct {
SymlinkRoot string `json:"symlink_root"`
Subdirectory string `json:"subdirectory"`
OverrideSubdirectory string `json:"override_subdirectory,omitempty"`
}
// Config definition.
// See: https://lyft.github.io/envoy/docs/configuration/overview/overview.html
type Config struct {
RootRuntime RootRuntime `json:"runtime"`
Listeners []Listener `json:"listeners"`
Admin Admin `json:"admin"`
ClusterManager ClusterManager `json:"cluster_manager"`
}