// BuildIndex causes the storage layer to create an index for the given // reference over the snapshot identified by the transaction. func (s *Storage) BuildIndex(ctx context.Context, txn Transaction, ref ast.Ref) error { path, err := NewPathForRef(ref.GroundPrefix()) if err != nil { return indexingNotSupportedError() } // TODO(tsandall): for now we prevent indexing against stores other than the // built-in. This will be revisited in the future. To determine the // reference touches an external store, we collect the ground portion of // the reference and see if it matches any mounts. for _, mount := range s.mounts { if path.HasPrefix(mount.path) || mount.path.HasPrefix(path) { return indexingNotSupportedError() } } return s.indices.Build(ctx, s.builtin, txn, ref) }