(ctx context.Context)
| 1273 | } |
| 1274 | |
| 1275 | func (m *imlMonitorConfig) GetMonitorConfig(ctx context.Context) (*monitor_dto.MonitorConfig, error) { |
| 1276 | clusterId := cluster.DefaultClusterID |
| 1277 | _, err := m.clusterService.Get(ctx, clusterId) |
| 1278 | if err != nil { |
| 1279 | return nil, err |
| 1280 | |
| 1281 | } |
| 1282 | info, err := m.monitorService.GetByCluster(ctx, clusterId) |
| 1283 | if err != nil { |
| 1284 | if !errors.Is(err, gorm.ErrRecordNotFound) { |
| 1285 | return nil, err |
| 1286 | } |
| 1287 | return &monitor_dto.MonitorConfig{ |
| 1288 | Driver: "influxdb-v2", |
| 1289 | Config: map[string]interface{}{}, |
| 1290 | }, nil |
| 1291 | } |
| 1292 | cfg := make(map[string]interface{}) |
| 1293 | err = json.Unmarshal([]byte(info.Config), &cfg) |
| 1294 | if err != nil { |
| 1295 | return nil, err |
| 1296 | } |
| 1297 | return &monitor_dto.MonitorConfig{ |
| 1298 | Driver: info.Driver, |
| 1299 | Config: cfg, |
| 1300 | }, nil |
| 1301 | } |
| 1302 | |
| 1303 | func (m *imlMonitorConfig) GetMonitorCluster(ctx context.Context) ([]*monitor_dto.MonitorCluster, error) { |
| 1304 | clusters, err := m.clusterService.ListByClusters(ctx) |
no test coverage detected