JSONSchemaExtend has to be in sync with Registry.NeedVersion
(sc *jsonschema.Schema)
| 96 | |
| 97 | // JSONSchemaExtend has to be in sync with Registry.NeedVersion |
| 98 | func (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 | |
| 122 | func (m *Metadata) SetDefaults() { |
| 123 | if m.Registry == RegistryUnset { |