diff --git a/src/main/java/com/dgu/cap/kubernetes/PodController.java b/src/main/java/com/dgu/cap/kubernetes/PodController.java index 6adf399..df5fd2e 100644 --- a/src/main/java/com/dgu/cap/kubernetes/PodController.java +++ b/src/main/java/com/dgu/cap/kubernetes/PodController.java @@ -16,20 +16,28 @@ public class PodController { @GetMapping("/pods") public ResponseEntity> getPods( - @RequestParam(defaultValue = "default") String namespace) { + @RequestParam(required = false) String namespace) { + if (namespace == null || namespace.isBlank()) { + return ResponseEntity.ok(kubernetesService.getAllPods()); + } return ResponseEntity.ok(kubernetesService.getPods(namespace)); } @GetMapping("/pods/{podName}/events") public ResponseEntity> getPodEvents( @PathVariable String podName, - @RequestParam(defaultValue = "default") String namespace) { - return ResponseEntity.ok(kubernetesService.getPodEvents(podName, namespace)); + @RequestParam(required = false) String namespace) { + String ns = (namespace == null || namespace.isBlank()) ? "default" : namespace; + return ResponseEntity.ok(kubernetesService.getPodEvents(podName, ns)); } @GetMapping("/topology") public ResponseEntity> getTopology( - @RequestParam(defaultValue = "default") String namespace) { + @RequestParam(required = false) String namespace) { + if (namespace == null || namespace.isBlank()) { + List pods = kubernetesService.getAllPods(); + return ResponseEntity.ok(Map.of("pods", pods, "namespace", "all")); + } List pods = kubernetesService.getPods(namespace); return ResponseEntity.ok(Map.of("pods", pods, "namespace", namespace)); }