MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / JSONSchemaExtend

Method JSONSchemaExtend

cli/internal/specs/v0/metadata.go:98–120  ·  view source on GitHub ↗

JSONSchemaExtend has to be in sync with Registry.NeedVersion

(sc *jsonschema.Schema)

Source from the content-addressed store, hash-verified

96
97// JSONSchemaExtend has to be in sync with Registry.NeedVersion
98func (Metadata) JSONSchemaExtend(sc *jsonschema.Schema) {
99 sc.If = &jsonschema.Schema{
100 Title: "if registry is unset or is either `github` or `cloudquery`",
101 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
102 properties := orderedmap.New[string, *jsonschema.Schema]()
103 properties.Set("registry", &jsonschema.Schema{Enum: []any{RegistryUnset.String(), RegistryGitHub.String(), RegistryCloudQuery.String()}})
104 return properties
105 }(),
106 }
107 sc.Then = &jsonschema.Schema{
108 Title: "require version to be present",
109 Properties: func() *orderedmap.OrderedMap[string, *jsonschema.Schema] {
110 properties := orderedmap.New[string, *jsonschema.Schema]()
111 version := *sc.Properties.Value("version")
112 version.Pattern = `^v.*$` // v1.2.3, v1, v0
113 version.Description = ""
114 version.Default = nil
115 properties.Set("version", &version)
116 return properties
117 }(),
118 Required: []string{"version"},
119 }
120}
121
122func (m *Metadata) SetDefaults() {
123 if m.Registry == RegistryUnset {

Callers

nothing calls this directly

Calls 3

ValueMethod · 0.65
SetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected