Filter out the tablets that do not belong to the requestor's namespace.
(ctx context.Context, ms *pb.MembershipState)
| 1267 | |
| 1268 | // Filter out the tablets that do not belong to the requestor's namespace. |
| 1269 | func filterTablets(ctx context.Context, ms *pb.MembershipState) error { |
| 1270 | if !x.WorkerConfig.AclEnabled { |
| 1271 | return nil |
| 1272 | } |
| 1273 | namespace, err := x.ExtractNamespaceFrom(ctx) |
| 1274 | if err != nil { |
| 1275 | return errors.Errorf("Namespace not found in JWT.") |
| 1276 | } |
| 1277 | if namespace == x.RootNamespace { |
| 1278 | // For galaxy namespace, we don't want to filter out the predicates. |
| 1279 | return nil |
| 1280 | } |
| 1281 | for _, group := range ms.GetGroups() { |
| 1282 | tablets := make(map[string]*pb.Tablet) |
| 1283 | for pred, tablet := range group.GetTablets() { |
| 1284 | if ns, attr := x.ParseNamespaceAttr(pred); namespace == ns { |
| 1285 | tablets[attr] = tablet |
| 1286 | tablets[attr].Predicate = attr |
| 1287 | } |
| 1288 | } |
| 1289 | group.Tablets = tablets |
| 1290 | } |
| 1291 | return nil |
| 1292 | } |
| 1293 | |
| 1294 | // State handles state requests |
| 1295 | func (s *Server) State(ctx context.Context) (*api.Response, error) { |
no test coverage detected