Filtered representation of FrameworkInfo. Executors and Tasks are filtered based on whether the user is authorized to view them.
| 284 | // Executors and Tasks are filtered based on whether the |
| 285 | // user is authorized to view them. |
| 286 | struct FrameworkWriter |
| 287 | { |
| 288 | FrameworkWriter( |
| 289 | const Owned<ObjectApprovers>& approvers, |
| 290 | const Framework* framework) |
| 291 | : approvers_(approvers), |
| 292 | framework_(framework) {} |
| 293 | |
| 294 | void operator()(JSON::ObjectWriter* writer) const |
| 295 | { |
| 296 | writer->field("id", framework_->id().value()); |
| 297 | writer->field("name", framework_->info.name()); |
| 298 | writer->field("user", framework_->info.user()); |
| 299 | writer->field("failover_timeout", framework_->info.failover_timeout()); |
| 300 | writer->field("checkpoint", framework_->info.checkpoint()); |
| 301 | writer->field("hostname", framework_->info.hostname()); |
| 302 | |
| 303 | if (framework_->info.has_principal()) { |
| 304 | writer->field("principal", framework_->info.principal()); |
| 305 | } |
| 306 | |
| 307 | // For multi-role frameworks the `role` field will be unset. |
| 308 | // Note that we could set `roles` here for both cases, which |
| 309 | // would make tooling simpler (only need to look for `roles`). |
| 310 | // However, we opted to just mirror the protobuf akin to how |
| 311 | // generic protobuf -> JSON translation works. |
| 312 | if (framework_->capabilities.multiRole) { |
| 313 | writer->field("roles", framework_->info.roles()); |
| 314 | } else { |
| 315 | writer->field("role", framework_->info.role()); |
| 316 | } |
| 317 | |
| 318 | writer->field("executors", [this](JSON::ArrayWriter* writer) { |
| 319 | foreachvalue (Executor* executor, framework_->executors) { |
| 320 | if (!approvers_->approved<VIEW_EXECUTOR>( |
| 321 | executor->info, framework_->info)) { |
| 322 | continue; |
| 323 | } |
| 324 | |
| 325 | ExecutorWriter executorWriter( |
| 326 | approvers_, |
| 327 | executor, |
| 328 | framework_); |
| 329 | |
| 330 | writer->element(executorWriter); |
| 331 | } |
| 332 | }); |
| 333 | |
| 334 | writer->field( |
| 335 | "completed_executors", [this](JSON::ArrayWriter* writer) { |
| 336 | foreach ( |
| 337 | const Owned<Executor>& executor, framework_->completedExecutors) { |
| 338 | if (!approvers_->approved<VIEW_EXECUTOR>( |
| 339 | executor->info, framework_->info)) { |
| 340 | continue; |
| 341 | } |
| 342 | |
| 343 | ExecutorWriter executorWriter( |
no outgoing calls
no test coverage detected