|
1 | 1 | package io.kafbat.ui.controller;
|
2 | 2 |
|
3 | 3 | import io.kafbat.ui.api.BrokersApi;
|
| 4 | +import io.kafbat.ui.config.Config; |
| 5 | +import io.kafbat.ui.exception.ClusterNotFoundException; |
4 | 6 | import io.kafbat.ui.mapper.ClusterMapper;
|
5 | 7 | import io.kafbat.ui.model.BrokerConfigDTO;
|
6 | 8 | import io.kafbat.ui.model.BrokerConfigItemDTO;
|
@@ -30,6 +32,7 @@ public class BrokersController extends AbstractController implements BrokersApi
|
30 | 32 |
|
31 | 33 | private final BrokerService brokerService;
|
32 | 34 | private final ClusterMapper clusterMapper;
|
| 35 | + private final Config config; |
33 | 36 |
|
34 | 37 | @Override
|
35 | 38 | public Mono<ResponseEntity<Flux<BrokerDTO>>> getBrokers(String clusterName,
|
@@ -94,10 +97,24 @@ public Mono<ResponseEntity<Flux<BrokerConfigDTO>>> getBrokerConfig(String cluste
|
94 | 97 | .operationParams(Map.of(BROKER_ID, id))
|
95 | 98 | .build();
|
96 | 99 |
|
| 100 | + Flux<BrokerConfigDTO> brokerConfigs = brokerService.getBrokerConfig(getCluster(clusterName), id) |
| 101 | + .map(clusterMapper::toBrokerConfig); |
| 102 | + |
| 103 | + var kafkaCluster = clustersStorage.getClusterByName(clusterName) |
| 104 | + .orElseThrow( |
| 105 | + () -> new ClusterNotFoundException( |
| 106 | + String.format("No cluster for name '%s'", clusterName))); |
| 107 | + |
| 108 | + if (kafkaCluster.isReadOnly()) { |
| 109 | + brokerConfigs = brokerConfigs.map(config -> { |
| 110 | + config.setIsReadOnly(true); |
| 111 | + return config; |
| 112 | + }); |
| 113 | + } |
| 114 | + |
97 | 115 | return validateAccess(context).thenReturn(
|
98 | 116 | ResponseEntity.ok(
|
99 |
| - brokerService.getBrokerConfig(getCluster(clusterName), id) |
100 |
| - .map(clusterMapper::toBrokerConfig)) |
| 117 | + brokerConfigs) |
101 | 118 | ).doOnEach(sig -> audit(context, sig));
|
102 | 119 | }
|
103 | 120 |
|
|
0 commit comments