diff --git a/src/main/java/kr/co/mcmp/api/manifest/YamlManifestController.java b/src/main/java/kr/co/mcmp/api/manifest/YamlManifestController.java index 6a03975..83caff8 100644 --- a/src/main/java/kr/co/mcmp/api/manifest/YamlManifestController.java +++ b/src/main/java/kr/co/mcmp/api/manifest/YamlManifestController.java @@ -22,40 +22,40 @@ public class YamlManifestController { @Operation(summary = "Deployments Yaml 생성") @PostMapping("/yaml/deployments") public ResponseEntity> generateYamlDeployments( - @RequestBody K8SDeploymentsDto deployments) { - manifestService.generateYamlDeployments(deployments); - return ResponseEntity.ok(new ResponseWrapper<>("Deployments Yaml Generated Successfully")); + @RequestBody K8SDeploymentDto deployments) { + String yaml = manifestService.generateYamlDeployments(deployments); + return ResponseEntity.ok(new ResponseWrapper<>(yaml)); } @Operation(summary = "Service Yaml 생성") @PostMapping("/yaml/service") public ResponseEntity> generateYamlService( @RequestBody K8SServiceDto service) { - manifestService.generateYamlService(service); - return ResponseEntity.ok(new ResponseWrapper<>("Service Yaml Generated Successfully")); + String yaml = manifestService.generateYamlService(service); + return ResponseEntity.ok(new ResponseWrapper<>(yaml)); } @Operation(summary = "ConfigMap Yaml 생성") @PostMapping("/yaml/configmap") public ResponseEntity> generateYamlConfigMap( @RequestBody K8SConfigMapDto configMap) { - manifestService.generateYamlConfigMap(configMap); - return ResponseEntity.ok(new ResponseWrapper<>("ConfigMap Yaml Generated Successfully")); + String yaml = manifestService.generateYamlConfigMap(configMap); + return ResponseEntity.ok(new ResponseWrapper<>(yaml)); } @Operation(summary = "Pod Yaml 생성") @PostMapping("/yaml/pod") public ResponseEntity> generateYamlPod( @RequestBody K8SPodDto pod) { - manifestService.generateYamlPod(pod); - return ResponseEntity.ok(new ResponseWrapper<>("Pod Yaml Generated Successfully")); + String yaml = manifestService.generateYamlPod(pod); + return ResponseEntity.ok(new ResponseWrapper<>(yaml)); } @Operation(summary = "Hpa Yaml 생성") @PostMapping("/yaml/hpa") public ResponseEntity> generateYamlHpa( @RequestBody K8SHpaDto hpa) { - manifestService.generateYamlHpa(hpa); - return ResponseEntity.ok(new ResponseWrapper<>("Hpa Yaml Generated Successfully")); + String yaml = manifestService.generateYamlHpa(hpa); + return ResponseEntity.ok(new ResponseWrapper<>(yaml)); } } diff --git a/src/main/java/kr/co/mcmp/api/manifest/YamlManifestService.java b/src/main/java/kr/co/mcmp/api/manifest/YamlManifestService.java index 6828fd4..7399c3b 100644 --- a/src/main/java/kr/co/mcmp/api/manifest/YamlManifestService.java +++ b/src/main/java/kr/co/mcmp/api/manifest/YamlManifestService.java @@ -17,7 +17,7 @@ public class YamlManifestService { private final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()) .setSerializationInclusion(JsonInclude.Include.NON_NULL); - public String generateYamlDeployments(K8SDeploymentsDto deployments) { + public String generateYamlDeployments(K8SDeploymentDto deployments) { return generateYaml(deployments); } diff --git a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SConfigMapDto.java b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SConfigMapDto.java index 10f81ac..f942336 100644 --- a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SConfigMapDto.java +++ b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SConfigMapDto.java @@ -15,14 +15,14 @@ public class K8SConfigMapDto { private final String apiVersion = "v1"; private final String kind = "ConfigMap"; - private MetadataDto metadata; + private ConfigMapMetadataDto metadata; private Map data = null; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class MetadataDto { + public static class ConfigMapMetadataDto { private String name; private String namespace; private Map labels = null; diff --git a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SDeploymentsDto.java b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SDeploymentDto.java similarity index 64% rename from src/main/java/kr/co/mcmp/api/manifest/k8s/K8SDeploymentsDto.java rename to src/main/java/kr/co/mcmp/api/manifest/k8s/K8SDeploymentDto.java index 101ead5..ece9ae4 100644 --- a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SDeploymentsDto.java +++ b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SDeploymentDto.java @@ -12,18 +12,18 @@ @Builder @NoArgsConstructor @AllArgsConstructor -public class K8SDeploymentsDto { +public class K8SDeploymentDto { private final String apiVersion = "apps/v1"; private final String kind = "Deployment"; - private MetadataDto metadata; - private SpecDto spec; + private DeploymentMetadataDto metadata; + private DeploymentSpecDto spec; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class MetadataDto { + public static class DeploymentMetadataDto { private String name; private String namespace; private Map labels = null; @@ -33,16 +33,16 @@ public static class MetadataDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class SpecDto { + public static class DeploymentSpecDto { private Integer replicas; - private SelectorDto selector; - private TemplateDto template; + private DeploymentSelectorDto selector; + private DeploymentTemplateDto template; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class SelectorDto { + public static class DeploymentSelectorDto { private Map matchLabels = null; } @@ -50,32 +50,32 @@ public static class SelectorDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class TemplateDto { - private MetadataDto metadata; - private PodSpecDto spec; + public static class DeploymentTemplateDto { + private DeploymentMetadataDto metadata; + private DeploymentPodSpecDto spec; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class PodSpecDto { - private List containers = null; + public static class DeploymentPodSpecDto { + private List containers = null; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class ContainerDto { + public static class DeploymentPodContainerDto { private String name; private String image; - private List env = null; - private List ports = null; + private List env = null; + private List ports = null; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class EnvDto { + public static class DeploymentPodEnvDto { private String name; private String value; } @@ -84,7 +84,7 @@ public static class EnvDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class PortDto { + public static class DeploymentPodPortDto { private Integer containerPort; } } diff --git a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SHpaDto.java b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SHpaDto.java index 019ebb6..2c5857f 100644 --- a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SHpaDto.java +++ b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SHpaDto.java @@ -15,14 +15,14 @@ public class K8SHpaDto { private final String apiVersion = "autoscaling/v1"; private final String kind = "HorizontalPodAutoscaler"; - private MetadataDto metadata; - private SpecDto spec; + private HpaMetadataDto metadata; + private HpaSpecDto spec; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class MetadataDto { + public static class HpaMetadataDto { private String name; private String namespace; private Map labels = null; @@ -32,8 +32,8 @@ public static class MetadataDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class SpecDto { - private ScaleTargetRefDto scaleTargetRef; + public static class HpaSpecDto { + private HpaScaleTargetRefDto scaleTargetRef; private Integer minReplicas; private Integer maxReplicas; private Integer targetCPUUtilizationPercentage; @@ -42,7 +42,7 @@ public static class SpecDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class ScaleTargetRefDto { + public static class HpaScaleTargetRefDto { private String apiVersion; private String kind; private String name; diff --git a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SPodDto.java b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SPodDto.java index 7d6c282..249e8a5 100644 --- a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SPodDto.java +++ b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SPodDto.java @@ -16,14 +16,14 @@ public class K8SPodDto { private final String apiVersion = "v1"; private final String kind = "Pod"; - private MetadataDto metadata; - private SpecDto spec; + private PodMetadataDto metadata; + private PodSpecDto spec; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class MetadataDto { + public static class PodMetadataDto { private String name; private String namespace; private Map labels = null; @@ -33,26 +33,26 @@ public static class MetadataDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class SpecDto { - private List containers = null; + public static class PodSpecDto { + private List containers = null; private String restartPolicy; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class ContainerDto { + public static class PodContainerDto { private String name; private String image; - private List env = null; - private List ports = null; - private ResourceDto resources; + private List env = null; + private List ports = null; + private PodResourceDto resources; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class EnvDto { + public static class PodEnvDto { private String name; private String value; } @@ -61,7 +61,7 @@ public static class EnvDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class PortDto { + public static class PodPortDto { private String name; private Integer containerPort; private Integer hostPort; @@ -72,7 +72,7 @@ public static class PortDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class ResourceDto { + public static class PodResourceDto { private Map limits = null; private Map requests = null; } diff --git a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SServiceDto.java b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SServiceDto.java index 9541271..252538a 100644 --- a/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SServiceDto.java +++ b/src/main/java/kr/co/mcmp/api/manifest/k8s/K8SServiceDto.java @@ -16,14 +16,14 @@ public class K8SServiceDto { private final String apiVersion = "v1"; private final String kind = "Service"; - private MetadataDto metadata; - private SpecDto spec; + private ServiceMetadataDto metadata; + private ServiceSpecDto spec; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class MetadataDto { + public static class ServiceMetadataDto { private String name; private String namespace; private Map labels = null; @@ -33,16 +33,16 @@ public static class MetadataDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class SpecDto { + public static class ServiceSpecDto { private Map selector = null; - private List ports = null; + private List ports = null; private String type; @Getter @Builder @NoArgsConstructor @AllArgsConstructor - public static class PortsDto { + public static class ServicePortsDto { private String protocol; private Integer port; private Integer targetPort;