validate that the schema contains the predicates whose namespace exist.
(sch string, namespaces map[uint64]struct{})
| 196 | |
| 197 | // validate that the schema contains the predicates whose namespace exist. |
| 198 | func validateSchema(sch string, namespaces map[uint64]struct{}) error { |
| 199 | result, err := schemapkg.Parse(sch) |
| 200 | if err != nil { |
| 201 | return err |
| 202 | } |
| 203 | for _, pred := range result.Preds { |
| 204 | ns := x.ParseNamespace(pred.Predicate) |
| 205 | if _, ok := namespaces[ns]; !ok { |
| 206 | return errors.Errorf("Namespace %#x doesn't exist for pred %s.", ns, pred.Predicate) |
| 207 | } |
| 208 | } |
| 209 | for _, typ := range result.Types { |
| 210 | ns := x.ParseNamespace(typ.TypeName) |
| 211 | if _, ok := namespaces[ns]; !ok { |
| 212 | return errors.Errorf("Namespace %#x doesn't exist for type %s.", ns, typ.TypeName) |
| 213 | } |
| 214 | } |
| 215 | return nil |
| 216 | } |
| 217 | |
| 218 | // processSchemaFile process schema for a given gz file. |
| 219 | func (l *loader) processSchemaFile(ctx context.Context, file string, key x.Sensitive, |
no test coverage detected