MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / JSONSchemaExtend

Method JSONSchemaExtend

plugins/destination/s3/client/spec/schema.go:10–205  ·  view source on GitHub ↗
(sc *jsonschema.Schema)

Source from the content-addressed store, hash-verified

8)
9
10func (s Spec) JSONSchemaExtend(sc *jsonschema.Schema) {
11 s.FileSpec.JSONSchemaExtend(sc) // need to call manually
12
13 batchTimeout := sc.Properties.Value("batch_timeout").OneOf[0] // 0 - val, 1 - null
14 batchTimeout.Default = "30s"
15
16 // path patterns: should be a clean path
17 cleanPath := &jsonschema.Schema{
18 Title: "`path` is a clean path value",
19 Extras: map[string]any{
20 "errorMessage": map[string]any{
21 "properties": map[string]any{
22 "path": "value must not contain ./ or //",
23 },
24 },
25 },
26 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
27 // we make the non-zero requirement, so we want to allow only null here
28 properties := orderedmap.New[string, *jsonschema.Schema]()
29 properties.Set("path", &jsonschema.Schema{
30 Type: "string",
31 Not: &jsonschema.Schema{
32 AnyOf: []*jsonschema.Schema{
33 {
34 Pattern: `^.*\./.*$`,
35 },
36 {
37 Pattern: `^.*//.*$`,
38 },
39 },
40 },
41 })
42 return properties
43 }(),
44 }
45
46 pathWithUUID := &jsonschema.Schema{
47 Title: "Require {{UUID}} to be present in path",
48 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
49 // we make the non-zero requirement, so we want to allow only null here
50 properties := orderedmap.New[string, *jsonschema.Schema]()
51 properties.Set("path", &jsonschema.Schema{
52 Type: "string",
53 Pattern: `^.*\{\{UUID\}\}.*$`,
54 })
55 return properties
56 }(),
57 }
58
59 pathNotWithUUID := &jsonschema.Schema{
60 Title: "Disallow {{UUID}} in path",
61 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
62 // we make the non-zero requirement, so we want to allow only null here
63 properties := orderedmap.New[string, *jsonschema.Schema]()
64 properties.Set("path", &jsonschema.Schema{
65 Type: "string",
66 Not: &jsonschema.Schema{
67 Pattern: `^.*\{\{UUID\}\}.*$`,

Callers

nothing calls this directly

Calls 2

ValueMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected