-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFields.jsx
More file actions
746 lines (719 loc) · 20.8 KB
/
Fields.jsx
File metadata and controls
746 lines (719 loc) · 20.8 KB
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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
import React from 'react'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import ReactMarkdown from 'react-markdown'
import useBaseUrl from '@docusaurus/useBaseUrl';
let schemes = {
envvar: '[EnvVar](/docs/reference/env-var)',
"map[string]string": '`[map[string]string]`',
matchpattern: '[MatchPattern](/docs/reference/types#match-pattern)',
'[]envvar': '[[]EnvVar](/docs/reference/env-var)',
cel: '[CEL](/docs/reference/scripting/cel)',
javascript: '[Javascript](/docs/reference/scripting/javascript)',
gotemplate: '[Go Template](/docs/reference/scripting/gotemplate)',
duration: '[Duration](/docs/reference/types#duration)',
jsonpathorstring: '`string` or [JSONPath](https://jsonpath.com/)',
'[]jsonpathorstring': '`[]string` or [[]JSONPath](https://jsonpath.com/)',
jsonpath: '[JSONPath](https://jsonpath.com/)',
size: '[Size](/docs/reference/types#size)',
"[]metric": '[[]Metric](/docs/guides/canary-checker/concepts/metrics#custom-metrics)',
agent: '[Agent](/docs/reference/types#agent)',
resourceselector: '[ResourceSelector](/docs/reference/resource-selector)',
resourceselectors: '[[]ResourceSelector](/docs/reference/resource-selector)',
connection: '[Connection](/docs/reference/connections)',
string: '`string`',
"[]string": '`[]string`',
icon: '[Icon](/docs/reference/types#icon)',
bool: '`boolean`',
int: '`integer`',
"map[string]EnvVar": '`[map[string]EnvVar](/docs/reference/env-var)`',
notificationurl: '[Notification](/docs/reference/notifications)',
notificationconnection: '[Connection](/docs/reference/connections)',
notificationproperties:
'[map[string]string](/docs/reference/notifications#properties)'
}
let ossSchemes = {
icon: '[Icon](/types#icon)',
envvar: '[EnvVar](/concepts/secret-management)',
matchpattern: '[MatchPattern](/types#match-pattern)',
'[]envvar': '[[]EnvVar](/concepts/secret-management)',
cel: '[CEL](/scripting/cel)',
javascript: '[Javascript](/scripting/javascript)',
gotemplate: '[Go Template](/scripting/gotemplate)',
duration: '[Duration](/types#duration)',
size: '[Size](/types#size)',
"[]metric": '[[]Metric](/concepts/metrics#custom-metrics)',
resourceselector: '[ResourceSelector](/resource-selector)',
resourceselectors: '[[]ResourceSelector](/resource-selector)',
}
function useSchemeUrl(value, oss) {
if (value == null) {
return "string"
}
const key = value.toLowerCase();
if (!(key in schemes)) {
return value;
}
if (oss) {
for (const key of Object.keys(ossSchemes)) {
schemes[key] = ossSchemes[key];
}
}
let mapping = schemes[value.toLowerCase()]
if (mapping == null || !mapping.includes('](/')) {
return mapping
}
value = mapping;
// Extract link text and URL
const matches = value.match(/\[(.*?)\]\((.*?)\)/);
if (matches) {
const [_, text, url] = matches;
// Only process internal links (starting with /)
if (url.startsWith('/')) {
return `[${text}](${useBaseUrl(url)})`;
}
}
return value
}
export default function Fields({ common = [], rows = [], oneOf, anyOf, connection, withTemplates }) {
const { siteConfig, siteMetadata } = useDocusaurusContext();
const oss = siteConfig.customFields.oss;
rows = rows.filter(row => row.field != null &&
(row.field != "artifacts" || !oss));
var fieldSorter = function (a, b) {
if (a.required && !b.required) {
return -1;
}
if (!a.required && b.required) {
return 1;
}
if (a.priority && !b.priority) {
return -1
}
if (!a.priority && b.priority) {
return 1
}
if (a.priority && b.priority && a.priority > b.priority) {
return -1
}
if (a.priority && b.priority && a.priority < b.priority) {
return 1
}
return a.field.localeCompare(b.field)
}
// Common AWS connection fields
const awsFields = [
{
field: oss ? null : "connection",
description: "The connection url to use, mutually exclusive with `accessKey` and `secretKey`",
scheme: "Connection",
},
{
field: "accessKey",
description: "Access Key ID",
scheme: "EnvVar"
},
{
field: "secretKey",
description: "Secret Access Key",
scheme: "EnvVar"
},
{
field: "region",
description: "The AWS region",
scheme: "string"
},
{
field: "endpoint",
scheme: "string",
description: "Custom AWS Endpoint to use",
},
{
field: "skipTLSVerify",
description: "Skip TLS verify when connecting to AWS",
scheme: 'bool'
}
]
// Common GCP connection fields
const gcpFields = [
{
field: oss ? null : 'connection',
description:
'The connection url to use, mutually exclusive with `credentials`',
scheme: 'Connection'
},
{
field: 'credentials',
description: 'The credentials to use for authentication',
scheme: 'EnvVar'
},
{
field: 'endpoint',
description: 'Custom GCP Endpoint to use',
scheme: 'string'
},
{
field: 'skipTLSVerify',
description: 'Skip TLS verification when connecting to GCP',
scheme: 'bool'
}
]
// Common Azure connection fields
const azureFields = [
{
field: oss ? null : "connection",
description: "The connection url to use, mutually exclusive with `tenantId`, `clientId`, and `clientSecret`",
scheme: "Connection",
},
{
field: "tenantId",
description: "The Azure Active Directory tenant ID",
scheme: "EnvVar",
required: true
},
{
field: "clientId",
description: "The Azure client/application ID",
scheme: "EnvVar"
},
{
field: "clientSecret",
description: "The Azure client/application secret",
scheme: "EnvVar"
}
]
if (connection == "url") {
rows = rows.concat([
{
field: oss ? null : "connection",
description: "The connection url to use, mutually exclusive with `username` and `password`",
scheme: "Connection",
},
{
field: !oss && rows.filter(i => i.field == "url").length == 0 ? "url" : null,
description: "If `connection` is specified and it also includes a `url`, this field will take precedence",
scheme: "string",
},
{
field: oss && rows.filter(i => i.field == "url").length == 0 ? "url" : null,
scheme: "string",
},
{
field: "username",
scheme: "EnvVar",
},
{
field: "password",
scheme: "EnvVar",
}
])
}
if (connection == "sql") {
rows = rows.concat([
{
field: oss ? null : "connection",
description: "The connection url or name to use`",
scheme: "Connection",
},
{
field: !oss && rows.filter(i => i.field == "url").length == 0 ? "url" : null,
description: "If `connection` is specified and it also includes a `url`, this field will take precedence",
scheme: "string",
},
{
field: oss && rows.filter(i => i.field == "url").length == 0 ? "url" : null,
scheme: "string",
},
{
field: "auth.username",
scheme: "EnvVar",
},
{
field: "auth.password",
scheme: "EnvVar",
}
])
} else if (connection == "git") {
rows = rows.concat([
{
field: oss ? null : "connection",
description: "The connection url to use, mutually exclusive with `username` and `password`",
scheme: "Connection",
},
{
field: !oss && rows.filter(i => i.field == "url").length == 0 ? "url" : null,
description: "If `connection` is specified and it also includes a `url`, this field will take precedence",
scheme: "string",
},
{
field: oss && rows.filter(i => i.field == "url").length == 0 ? "url" : null,
scheme: "string",
},
{
field: "certificate",
scheme: "EnvVar",
},
{
field: "username",
scheme: "EnvVar",
},
{
field: "password",
scheme: "EnvVar",
}
])
} else if (connection == "aws") {
rows = rows.concat(awsFields)
} else if (connection == "gcp") {
rows = rows.concat(gcpFields)
} else if (connection == "sftp") {
rows = rows.concat([
{
field: oss ? null : "connection",
description: "The connection url to use, mutually exclusive with `host` and `port`",
scheme: "Connection",
},
{
field: "host",
description: "SFTP host",
scheme: "string"
},
{
field: "port",
description: "SFTP port",
scheme: "int"
},
{
field: "username",
scheme: "EnvVar"
},
{
field: "password",
scheme: "EnvVar"
}
])
} else if (connection == "smb") {
rows = rows.concat([
{
field: oss ? null : "connection",
description: "The connection url to use, mutually exclusive with `host`, `share`, and `credentials`",
scheme: "Connection",
},
{
field: "host",
description: "The SMB host",
scheme: "string"
},
{
field: "port",
scheme: "int"
},
{
field: "domain",
description: "Windows Domain",
},
{
field: "username",
scheme: "EnvVar",
},
{
field: "password",
scheme: "EnvVar",
}
])
} else if (connection == "kubeconfig") {
rows = rows.concat([
{
field: "kubeconfig",
description: "Path to a kubeconfig on disk, or a reference to an existing secret",
scheme: "EnvVar",
}])
} else if (connection == "kubernetes") {
rows = rows.concat([
{
field: "connection",
description: "The connection url to use, mutually exclusive with `kubeconfig`",
scheme: "Connection",
},
{
field: "kubeconfig",
description: "Source for kubeconfig",
scheme: "EnvVar"
},
{
field: "eks",
description: "EKS connection details",
scheme: "[EKS](/docs/reference/connections/kubernetes/#eks-connection)",
},
{
field: "gke",
description: "GKE connection details",
scheme: "[GKE](/docs/reference/connections/kubernetes/#gke-connection)",
},
{
field: "cnrm",
description: "CNRM connection details",
scheme: "[CNRM](/docs/reference/connections/kubernetes/#cnrm-connection)",
}])
} else if (connection == "azure") {
rows = rows.concat(azureFields)
} else if (connection == "openai") {
rows = rows.concat([
{
field: "model",
description: "OpenAI model to use",
scheme: "string",
required: true
},
{
field: "url",
description: "Optional API endpoint URL",
scheme: "EnvVar"
},
{
field: "apiKey",
description: "OpenAI API key for authentication",
scheme: "EnvVar",
required: true
}
])
} else if (connection == "ollama") {
rows = rows.concat([
{
field: "model",
description: "Ollama model to use",
scheme: "string",
required: true
},
{
field: "url",
description: "Ollama API endpoint URL",
scheme: "EnvVar",
required: true
}
])
} else if (connection == "anthropic") {
rows = rows.concat([
{
field: "model",
description: "Anthropic model to use",
scheme: "string",
required: true
},
{
field: "url",
description: "Optional API endpoint URL",
scheme: "EnvVar"
},
{
field: "apiKey",
description: "Anthropic API key for authentication",
scheme: "EnvVar",
required: true
}
])
} else if (connection == "http") {
rows = rows.concat([
{
field: 'tls.insecureSkipVerify',
description: 'Skip TLS certificate verification. Use with caution - only enable in trusted environments or for testing',
scheme: 'boolean'
},
{
field: 'tls.handshakeTimeout',
description: 'Maximum time to wait for TLS handshake completion. Example: "30s", "1m"',
scheme: 'duration'
},
{
field: 'tls.ca',
description: 'Custom Certificate Authority (CA) certificate for TLS verification. Used for self-signed or internal certificates',
scheme: 'EnvVar'
},
{
field: 'tls.cert',
description: 'Client TLS certificate for mutual TLS authentication (mTLS)',
scheme: 'EnvVar'
},
{
field: 'tls.key',
description: 'Private key corresponding to the client TLS certificate for mTLS',
scheme: 'EnvVar'
},
{
field: 'connection',
description: 'Reference to a pre-configured HTTP connection. Use this to reuse connection settings across multiple scrapers',
scheme: 'string'
},
{
field: 'bearer',
description: 'Bearer token for authentication',
scheme: 'EnvVar'
},
{
field: 'username',
description: 'Username for Basic or Digest authentication.',
scheme: 'EnvVar'
},
{
field: 'password',
description: 'Password for Basic or Digest authentication.',
scheme: 'EnvVar'
},
{
field: 'ntlm',
description: 'Enable Windows NTLM authentication protocol. Typically used in corporate environments',
scheme: 'boolean'
},
{
field: 'ntlmv2',
description: 'Enable NTLMv2 authentication protocol, a more secure version of NTLM',
scheme: 'boolean'
},
{
field: 'digest',
description: 'Enable Digest authentication, a more secure alternative to Basic authentication',
scheme: 'boolean'
},
{
field: 'oauth.clientID',
description: 'OAuth 2.0 client identifier',
scheme: 'EnvVar'
},
{
field: 'oauth.clientSecret',
description: 'OAuth 2.0 client secret',
scheme: 'EnvVar'
},
{
field: 'oauth.tokenURL',
description: 'OAuth 2.0 token endpoint URL',
scheme: 'string'
},
{
field: 'oauth.scopes',
description: 'List of OAuth 2.0 scopes',
scheme: '[]string'
},
{
field: 'oauth.params',
description: 'Additional OAuth 2.0 parameters to include in the token request',
scheme: 'map[string]string'
},
{
field: 'url',
description: 'The URL to send the HTTP request to. Must include the scheme _(http:// or https://)_',
scheme: 'string',
required: true
},
])
} else if (connection == "s3") {
rows = rows.concat([
{
field: "bucket",
description: "S3 bucket name",
scheme: "string",
required: true
},
{
field: "objectPath",
description: "Glob path to restrict matches to a subset of objects",
scheme: "string"
},
{
field: "usePathStyle",
description: "Use path style URL (http://s3.amazonaws.com/BUCKET/KEY) instead of virtual hosted-style (http://BUCKET.s3.amazonaws.com/KEY)",
scheme: "bool"
}
])
} else if (connection == "eks") {
rows = rows.concat([
{
field: "cluster",
description: "Name of the EKS cluster",
scheme: "string",
required: true
}
])
} else if (connection == "gke") {
rows = rows.concat([
{
field: "projectID",
description: "Google Cloud project ID containing the GKE cluster",
scheme: "string",
required: true
},
{
field: "zone",
description: "Zone or region where the GKE cluster is located",
scheme: "string",
required: true
},
{
field: "cluster",
description: "Name of the GKE cluster",
scheme: "string",
required: true
}
])
} else if (connection == "gcs") {
rows = rows.concat([
{
field: "bucket",
description: "GCS bucket name",
scheme: "string",
required: true
}
])
} else if (connection == "cnrm") {
rows = rows.concat([
{
field: "gke.projectID",
description: "Google Cloud project ID containing the management GKE cluster",
scheme: "string",
required: true
},
{
field: "gke.zone",
description: "Zone or region where the management GKE cluster is located",
scheme: "string",
required: true
},
{
field: "gke.cluster",
description: "Name of the management GKE cluster",
scheme: "string",
required: true
},
{
field: "clusterResource",
description: "Name of the ContainerCluster resource managed by Config Connector",
scheme: "string",
required: true
},
{
field: "clusterResourceNamespace",
description: "Namespace containing the ContainerCluster resource",
scheme: "string",
required: true
}
])
} else if (connection == "prometheus") {
// Prometheus extends HTTP connection, so HTTP fields will be included
rows = rows.concat([])
} else if (connection == "aws_kms") {
rows = rows.concat(awsFields.concat([
{
field: "keyID",
description: "KMS key ID, alias, or ARN. Can include region specification for aliases (e.g., alias/ExampleAlias?region=us-east-1)",
scheme: "string",
required: true
}
]))
} else if (connection == "gcp_kms") {
rows = rows.concat(gcpFields.concat([
{
field: "keyID",
description: "KMS key resource path in the format: projects/PROJECT/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY",
scheme: "string",
required: true
}
]))
} else if (connection == "azure_key_vault") {
rows = rows.concat(azureFields.concat([
{
field: "keyID",
description: "Key Vault key URL in the format: https://vault-name.vault.azure.net/keys/key-name",
scheme: "string",
required: true
}
]))
}
rows = rows.concat(common.filter(row => row.required)).filter(i => i.field != null)
rows.sort(fieldSorter);
common = common.filter(row => !row.required).filter(i => i.field != null)
common.sort(fieldSorter)
rows = rows.concat(common)
return (
<>
<table className="fields">
<thead>
<tr>
<th>Field</th>
<th>Description</th>
<th>Scheme</th>
{withTemplates && <th>Template Env</th>}
</tr>
</thead>
<tbody>
{rows.map((row, index) => (
<tr key={index}>
<td>
<code className={row.required ? 'font-bold' : ''}>
{row.field}
{row.required ? '*' : ''}
</code>
</td>
<td>
{typeof (row.description) === 'string' ? (
<ReactMarkdown>
{(row.description ? row.description : '') +
(row.default ? `. Defaults to \`${row.default}\`` : '')}
</ReactMarkdown>
) : row.description}
</td>
<td>
{row.anyOf && <code>{row.anyOf.join(' | ')}</code>}
{!row.anyOf && row.scheme && (
<ReactMarkdown>
{useSchemeUrl(row.scheme, oss)}
</ReactMarkdown>
)}
</td>
{withTemplates && (
<td>
{row.templateEnv &&
row.templateEnv.map((v) => (
<p>
<a href={v.url}>
<code>{v.name}</code>
</a>
</p>
))}
</td>
)}
</tr>
))}
</tbody>
</table>
{anyOf && (
<blockquote
style={{ borderLeft: '2px solid var(--ifm-color-warning-light)' }}
>
<p>
You must specify <code>{anyOf[0]}</code> and/or{' '}
<code>{anyOf[1]}</code>
</p>
</blockquote>
)}
{oneOf && oneOf.length == 2 && (
<blockquote
style={{ borderLeft: '2px solid var(--ifm-color-warning-light)' }}
>
<p>
You must specify <code>{oneOf[0]}</code> or <code>{oneOf[1]}</code>{' '}
but not both
</p>
</blockquote>
)}
{oneOf && oneOf.length == 3 && (
<blockquote
style={{ borderLeft: '2px solid var(--ifm-color-warning-light)' }}
>
<p>
You must specify one of <code>{oneOf[0]}</code>,{' '}
<code>{oneOf[1]}</code> or <code>{oneOf[2]}</code>
</p>
</blockquote>
)}
</>
)
}