(env cliconfig.Environment)
| 335 | } |
| 336 | |
| 337 | func getAPIsByEnv(env cliconfig.Environment) (string, error) { |
| 338 | apisRes, err := cluster.GetAPIs(MustGetOperatorConfig(env.Name)) |
| 339 | if err != nil { |
| 340 | return "", err |
| 341 | } |
| 342 | |
| 343 | var bytes []byte |
| 344 | if _flagOutput == flags.JSONOutputType { |
| 345 | bytes, err = libjson.Marshal(apisRes) |
| 346 | } else if _flagOutput == flags.YAMLOutputType { |
| 347 | bytes, err = yaml.Marshal(apisRes) |
| 348 | } |
| 349 | if err != nil { |
| 350 | return "", err |
| 351 | } |
| 352 | if _flagOutput == flags.JSONOutputType || _flagOutput == flags.YAMLOutputType { |
| 353 | return string(bytes), nil |
| 354 | } |
| 355 | |
| 356 | var allRealtimeAPIs []schema.APIResponse |
| 357 | var allAsyncAPIs []schema.APIResponse |
| 358 | var allBatchAPIs []schema.APIResponse |
| 359 | var allTaskAPIs []schema.APIResponse |
| 360 | var allTrafficSplitters []schema.APIResponse |
| 361 | |
| 362 | for _, api := range apisRes { |
| 363 | switch api.Metadata.Kind { |
| 364 | case userconfig.BatchAPIKind: |
| 365 | allBatchAPIs = append(allBatchAPIs, api) |
| 366 | case userconfig.TaskAPIKind: |
| 367 | allTaskAPIs = append(allTaskAPIs, api) |
| 368 | case userconfig.RealtimeAPIKind: |
| 369 | allRealtimeAPIs = append(allRealtimeAPIs, api) |
| 370 | case userconfig.AsyncAPIKind: |
| 371 | allAsyncAPIs = append(allAsyncAPIs, api) |
| 372 | case userconfig.TrafficSplitterKind: |
| 373 | allTrafficSplitters = append(allTrafficSplitters, api) |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | if len(allRealtimeAPIs) == 0 && len(allAsyncAPIs) == 0 && len(allBatchAPIs) == 0 && len(allTaskAPIs) == 0 && len(allTrafficSplitters) == 0 { |
| 378 | return console.Bold("no apis are deployed"), nil |
| 379 | } |
| 380 | |
| 381 | out := "" |
| 382 | |
| 383 | if len(allBatchAPIs) > 0 { |
| 384 | envNames := []string{} |
| 385 | for range allBatchAPIs { |
| 386 | envNames = append(envNames, env.Name) |
| 387 | } |
| 388 | |
| 389 | t := batchAPIsTable(allBatchAPIs, envNames) |
| 390 | t.FindHeaderByTitle(_titleEnvironment).Hidden = true |
| 391 | |
| 392 | out += t.MustFormat() |
| 393 | } |
| 394 |
no test coverage detected