forked from istio/istio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
544 lines (497 loc) · 11.7 KB
/
data.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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
// Copyright 2018 Istio Authors
//
// 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 data
import "strings"
// ServiceConfig is a standard service config.
var ServiceConfig = `
apiVersion: "config.istio.io/v1alpha2"
kind: attributemanifest
metadata:
name: istio-proxy
namespace: default
spec:
attributes:
source.name:
value_type: STRING
destination.name:
value_type: STRING
response.count:
value_type: INT64
attr.bool:
value_type: BOOL
attr.string:
value_type: STRING
attr.double:
value_type: DOUBLE
attr.int64:
value_type: INT64
---
`
// InstanceCheck1 is a standard testing instance for template tcheck.
var InstanceCheck1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: tcheck
metadata:
name: icheck1
namespace: istio-system
spec:
`
// FqnI1 is the fully qualified name for I1.
var FqnI1 = "icheck1.tcheck.istio-system"
// InstanceCheck2 is another instance.
var InstanceCheck2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: tcheck
metadata:
name: icheck2
namespace: istio-system
spec:
`
// InstanceCheck3 is another instance.
var InstanceCheck3 = `
apiVersion: "config.istio.io/v1alpha2"
kind: tcheck
metadata:
name: icheck3
namespace: istio-system
spec:
`
// InstanceCheck4NS2 is in the ns2 namespace
var InstanceCheck4NS2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: tcheck
metadata:
name: icheck4
namespace: ns2
spec:
`
// InstanceCheck1WithSpec has a spec with expressions
var InstanceCheck1WithSpec = `
apiVersion: "config.istio.io/v1alpha2"
kind: tcheck
metadata:
name: icheck1
namespace: istio-system
spec:
foo: attr.string
`
// InstanceHalt1 is a standard testing instance.
var InstanceHalt1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: thalt
metadata:
name: ihalt1
namespace: istio-system
spec:
`
// InstanceReport1 is a standard testing instance for template treport.
var InstanceReport1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: treport
metadata:
name: ireport1
namespace: istio-system
spec:
`
// InstanceReport1WithSpec has a spec with expressions
var InstanceReport1WithSpec = `
apiVersion: "config.istio.io/v1alpha2"
kind: treport
metadata:
name: ireport1
namespace: istio-system
spec:
foo: attr.string
`
// InstanceReport2 is a standard testing instance for template treport.
var InstanceReport2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: treport
metadata:
name: ireport2
namespace: istio-system
spec:
`
// InstanceQuota1 is a standard testing instance for template tquota.
var InstanceQuota1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: tquota
metadata:
name: iquota1
namespace: istio-system
spec:
`
// InstanceQuota2 is a copy of InstanceQuota1 with a different name.
var InstanceQuota2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: tquota
metadata:
name: iquota2
namespace: istio-system
spec:
`
// InstanceQuota1WithSpec has a spec with expressions
var InstanceQuota1WithSpec = `
apiVersion: "config.istio.io/v1alpha2"
kind: tquota
metadata:
name: iquota1
namespace: istio-system
spec:
foo: attr.string
`
// InstanceAPA1 is an APA instance
var InstanceAPA1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: tapa
metadata:
name: iapa1
namespace: istio-system
spec:
`
// InstanceAPA1WithSpec has a spec with expressions
var InstanceAPA1WithSpec = `
apiVersion: "config.istio.io/v1alpha2"
kind: tapa
metadata:
name: iapa1
namespace: istio-system
spec:
foo: attr.string
attribute_bindings:
source.name: $out.generated.string | ""
`
// HandlerACheck1 is a handler of type acheck with name hcheck1.
var HandlerACheck1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: acheck
metadata:
name: hcheck1
namespace: istio-system
spec:
`
// FqnACheck1 is the fully qualified name of HandlerH1.
var FqnACheck1 = "hcheck1.acheck.istio-system"
// HandlerACheck2 is a handler of type acheck with name hcheck2.
var HandlerACheck2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: acheck
metadata:
name: hcheck2
namespace: istio-system
spec:
`
// HandlerACheck3NS2 is a handler in namespace NS2.
var HandlerACheck3NS2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: acheck
metadata:
name: hcheck3
namespace: ns2
spec:
`
// HandlerAReport1 is a handler of type acheck with name hreport1.
var HandlerAReport1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: areport
metadata:
name: hreport1
namespace: istio-system
spec:
`
// FqnAReport1 is the fully qualified name of HandlerAReport1.
var FqnAReport1 = "hreport1.areport.istio-system"
// HandlerAQuota1 is a handler of type aquota with name hquota1.
var HandlerAQuota1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: aquota
metadata:
name: hquota1
namespace: istio-system
spec:
`
// FqnAQuota1 is the fully qualified name of HandlerAReport1.
var FqnAQuota1 = "hquota1.aquota.istio-system"
// HandlerAPA1 is an APA handler.
var HandlerAPA1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: apa
metadata:
name: hapa1
namespace: istio-system
spec:
`
// RuleCheck1 is a standard testing instance config with name R1. It references I1 and H1.
var RuleCheck1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
`
// RuleCheck1TrueCondition is a standard testing instance config with name R1. It references I1 and H1.
var RuleCheck1TrueCondition = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
selector: 'true'
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
`
// RuleCheck1WithBadCondition has a parseable but not compilable condition
var RuleCheck1WithBadCondition = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
selector: needmorecheese
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
`
// RuleCheck1WithInstance1And2 has instances icheck1 & icheck2.
var RuleCheck1WithInstance1And2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
- icheck2.tcheck.istio-system
`
// RuleCheck1WithMatchClause is Rule Check1 with a conditional.
var RuleCheck1WithMatchClause = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
match: match(destination.name, "foo*")
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
`
// RuleCheck1WithInstance1And2WithMatchClause is Rule Check1 with a conditional.
var RuleCheck1WithInstance1And2WithMatchClause = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
match: match(destination.name, "foo*")
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
- icheck2.tcheck.istio-system
`
// RuleCheck1WithBadHandler is a standard testing rule config with a bad handler name.
var RuleCheck1WithBadHandler = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
actions:
- handler: hcheck1.inspector-gadget
instances:
- icheck1.tcheck.istio-system
`
// RuleCheck1WithNonBooleanCondition has a non-boolean condition.
var RuleCheck1WithNonBooleanCondition = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: istio-system
spec:
selector: destination.name
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
`
// RuleCheck2WithInstance1AndHandler is Rule Check1 with a different name.
var RuleCheck2WithInstance1AndHandler = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck2
namespace: istio-system
spec:
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
`
// RuleCheck2WithInstance2And3 references instances icheck2 and icheck2.
var RuleCheck2WithInstance2And3 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck2
namespace: istio-system
spec:
actions:
- handler: hcheck1.acheck
instances:
- icheck2.tcheck.istio-system
- icheck3.tcheck.istio-system
`
// RuleCheck2WithInstance2And3WithMatchClause is RuleCheck2WithInstance2And3 with a conditional.
var RuleCheck2WithInstance2And3WithMatchClause = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck2
namespace: istio-system
spec:
match: destination.name.startsWith("foo")
actions:
- handler: hcheck1.acheck
instances:
- icheck2.tcheck.istio-system
- icheck3.tcheck.istio-system
`
// RuleCheck2WithHandler2AndInstance2 references hcheck2 and icheck2.
var RuleCheck2WithHandler2AndInstance2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck2
namespace: istio-system
spec:
actions:
- handler: hcheck2.acheck
instances:
- icheck2.tcheck.istio-system
`
// RuleCheck3NS2 is check rule in namespace NS2
var RuleCheck3NS2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheck1
namespace: ns2
spec:
actions:
- handler: hcheck3.acheck
instances:
- icheck4.tcheck.ns2
`
// Rule4CheckAndHalt has two instances that goes to the same adapter, but have different templates.
var Rule4CheckAndHalt = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rcheckandhalt4
namespace: istio-system
spec:
actions:
- handler: hcheck1.acheck
instances:
- icheck1.tcheck.istio-system
- ihalt1.thalt.istio-system
`
// RuleReport1 is a standard testing instance config with name rreport1. It references I1 and H1.
var RuleReport1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rreport1
namespace: istio-system
spec:
actions:
- handler: hreport1.areport
instances:
- ireport1.treport.istio-system
`
// RuleReport1And2 is a standard testing instance config with name rreport1.
var RuleReport1And2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rreport1
namespace: istio-system
spec:
actions:
- handler: hreport1.areport
instances:
- ireport1.treport.istio-system
- ireport2.treport.istio-system
`
// RuleQuota1 is a standard testing instance config with name rquota1. It references I1 and H1.
var RuleQuota1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rquota1
namespace: istio-system
spec:
actions:
- handler: hquota1.aquota
instances:
- iquota1.tquota.istio-system
`
// RuleQuota2 references iquota1 and hquota1.
var RuleQuota2 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rquota2
namespace: istio-system
spec:
actions:
- handler: hquota1.aquota
instances:
- iquota2.tquota.istio-system
`
// RuleApa1 is a rule that target APA.
var RuleApa1 = `
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
name: rapa1
namespace: istio-system
spec:
actions:
- handler: hapa1.apa
instances:
- iapa1.tapa.istio-system
`
// JoinConfigs is a utility for joining various pieces of config for consumption by store code.
func JoinConfigs(configs ...string) string {
return strings.Join(configs, "\n---\n")
}