🎨 Format
This commit is contained in:
parent
16a5627b39
commit
e165df6076
18
pom.xml
18
pom.xml
@ -163,6 +163,24 @@
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>2.29.0</version>
|
||||
<configuration>
|
||||
<configFile>https://git.dinauer.dev/andreas.dinauer/formatter/raw/branch/main/format.xml</configFile>
|
||||
<lineEnding>LF</lineEnding>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>validate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.revelc.code</groupId>
|
||||
<artifactId>impsort-maven-plugin</artifactId>
|
||||
|
||||
@ -27,7 +27,7 @@ public class IngressResource
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public List<Ingress> getIngresses(@QueryParam("namespace") String namespace)
|
||||
{
|
||||
if(namespace != null)
|
||||
if (namespace != null)
|
||||
{
|
||||
ingressService.findByNamespace(namespace);
|
||||
}
|
||||
|
||||
@ -47,10 +47,10 @@ public class ProcessRunner
|
||||
List<String> text = new ArrayList<>();
|
||||
Process process = processBuilder.start();
|
||||
executor.submit(() -> {
|
||||
try(BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())))
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())))
|
||||
{
|
||||
String line;
|
||||
while((line = br.readLine()) != null)
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
text.add(line);
|
||||
}
|
||||
@ -65,7 +65,7 @@ public class ProcessRunner
|
||||
process.destroyForcibly();
|
||||
if (endedInTime)
|
||||
{
|
||||
if(exitCode == 0)
|
||||
if (exitCode == 0)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class ResourceResource
|
||||
{
|
||||
if (ResourceType.DEPLOYMENT.equals(resourceType))
|
||||
{
|
||||
if(namespace != null && !namespace.isBlank() && name != null && !name.isBlank() && replicaCount != null && replicaCount > 0)
|
||||
if (namespace != null && !namespace.isBlank() && name != null && !name.isBlank() && replicaCount != null && replicaCount > 0)
|
||||
{
|
||||
deploymentService.rescale(namespace, name, replicaCount);
|
||||
}
|
||||
@ -101,44 +101,34 @@ public class ResourceResource
|
||||
{
|
||||
switch (resourceType)
|
||||
{
|
||||
case ResourceType.STATEFUL_SET ->
|
||||
{
|
||||
case ResourceType.STATEFUL_SET -> {
|
||||
return statefulSetService;
|
||||
}
|
||||
case ResourceType.DEPLOYMENT ->
|
||||
{
|
||||
case ResourceType.DEPLOYMENT -> {
|
||||
return deploymentService;
|
||||
}
|
||||
case ResourceType.SERVICE ->
|
||||
{
|
||||
case ResourceType.SERVICE -> {
|
||||
return serviceService;
|
||||
}
|
||||
case ResourceType.INGRESS ->
|
||||
{
|
||||
case ResourceType.INGRESS -> {
|
||||
return ingressService;
|
||||
}
|
||||
case ResourceType.POD ->
|
||||
{
|
||||
case ResourceType.POD -> {
|
||||
return podService;
|
||||
}
|
||||
case ResourceType.CUSTOM_RESOURCE_DEFINITION ->
|
||||
{
|
||||
case ResourceType.CUSTOM_RESOURCE_DEFINITION -> {
|
||||
return customResourceDefinitionService;
|
||||
}
|
||||
case ResourceType.NODE ->
|
||||
{
|
||||
case ResourceType.NODE -> {
|
||||
return nodeService;
|
||||
}
|
||||
case ResourceType.SECRET ->
|
||||
{
|
||||
case ResourceType.SECRET -> {
|
||||
return secretService;
|
||||
}
|
||||
case ResourceType.CONFIG_MAP ->
|
||||
{
|
||||
case ResourceType.CONFIG_MAP -> {
|
||||
return configMapService;
|
||||
}
|
||||
default ->
|
||||
{
|
||||
default -> {
|
||||
LOG.errorf("Invalid resource type %s.", resourceType);
|
||||
throw new BadRequestException();
|
||||
}
|
||||
|
||||
@ -3,36 +3,33 @@ package dev.dinauer;
|
||||
public enum ResourceType
|
||||
{
|
||||
// Cluster Resources
|
||||
NODE("nodes"),
|
||||
NAMESPACE("namespaces"),
|
||||
CUSTOM_RESOURCE_DEFINITION("custom-resource-definitions"),
|
||||
NODE("nodes"), NAMESPACE("namespaces"), CUSTOM_RESOURCE_DEFINITION("custom-resource-definitions"),
|
||||
|
||||
// Workloads
|
||||
STATEFUL_SET("stateful-sets"),
|
||||
DEPLOYMENT("deployments"),
|
||||
POD("pods"),
|
||||
STATEFUL_SET("stateful-sets"), DEPLOYMENT("deployments"), POD("pods"),
|
||||
|
||||
// Networking
|
||||
SERVICE("services"),
|
||||
INGRESS("ingresses"),
|
||||
SERVICE("services"), INGRESS("ingresses"),
|
||||
|
||||
// Config
|
||||
SECRET("secrets"),
|
||||
CONFIG_MAP("config-maps"),
|
||||
SECRET("secrets"), CONFIG_MAP("config-maps"),
|
||||
|
||||
// Storage
|
||||
PVC("pvcs"),
|
||||
PV("pvs");
|
||||
PVC("pvcs"), PV("pvs");
|
||||
|
||||
private final String value;
|
||||
|
||||
ResourceType(String value) {
|
||||
ResourceType(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static ResourceType fromString(String text) {
|
||||
for (ResourceType type : ResourceType.values()) {
|
||||
if (type.value.equalsIgnoreCase(text)) {
|
||||
public static ResourceType fromString(String text)
|
||||
{
|
||||
for (ResourceType type : ResourceType.values())
|
||||
{
|
||||
if (type.value.equalsIgnoreCase(text))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@ -40,7 +37,8 @@ public enum ResourceType
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ public class ServiceResource
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public List<Service> getServices(@QueryParam("namespace") String namespace)
|
||||
{
|
||||
if(namespace != null && !namespace.isBlank())
|
||||
if (namespace != null && !namespace.isBlank())
|
||||
{
|
||||
return serviceService.findByNamespace(namespace);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class LogWebsocket
|
||||
LogWatch watch = clientProvider.getClient().pods().inNamespace(namespace).withName(name).usingTimestamps().tailingLines(0).watchLog();
|
||||
sessions.put(session, watch);
|
||||
|
||||
try(BufferedReader reader = new BufferedReader(new InputStreamReader(watch.getOutput())))
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(watch.getOutput())))
|
||||
{
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null && !Thread.currentThread().isInterrupted())
|
||||
|
||||
@ -49,8 +49,7 @@ public class ResourceWebsocket
|
||||
ResourceType resourceType = ResourceType.fromString(rawResourceType);
|
||||
if (tokenService.validateTokenByQueryString(session.getQueryString()))
|
||||
{
|
||||
executor.submit(() ->
|
||||
{
|
||||
executor.submit(() -> {
|
||||
ResourceService<?> service = serviceFactory.getService(resourceType);
|
||||
send(session, EventType.INIT, service.findByNamespace(namespace));
|
||||
sessions.put(session, service.watch(namespace, getWatcher(session)));
|
||||
|
||||
@ -55,55 +55,55 @@ public class ServiceFactory
|
||||
{
|
||||
switch (resourceType)
|
||||
{
|
||||
case ResourceType.STATEFUL_SET ->
|
||||
case ResourceType.STATEFUL_SET:
|
||||
{
|
||||
return statefulSetService;
|
||||
}
|
||||
case ResourceType.DEPLOYMENT ->
|
||||
case ResourceType.DEPLOYMENT:
|
||||
{
|
||||
return deploymentService;
|
||||
}
|
||||
case ResourceType.SERVICE ->
|
||||
case ResourceType.SERVICE:
|
||||
{
|
||||
return serviceService;
|
||||
}
|
||||
case ResourceType.INGRESS ->
|
||||
case ResourceType.INGRESS:
|
||||
{
|
||||
return ingressService;
|
||||
}
|
||||
case ResourceType.POD ->
|
||||
case ResourceType.POD:
|
||||
{
|
||||
return podService;
|
||||
}
|
||||
case ResourceType.CUSTOM_RESOURCE_DEFINITION ->
|
||||
case ResourceType.CUSTOM_RESOURCE_DEFINITION:
|
||||
{
|
||||
return customResourceDefinitionService;
|
||||
}
|
||||
case ResourceType.NODE ->
|
||||
case ResourceType.NODE:
|
||||
{
|
||||
return nodeService;
|
||||
}
|
||||
case ResourceType.SECRET ->
|
||||
case ResourceType.SECRET:
|
||||
{
|
||||
return secretService;
|
||||
}
|
||||
case ResourceType.CONFIG_MAP ->
|
||||
case ResourceType.CONFIG_MAP:
|
||||
{
|
||||
return configMapService;
|
||||
}
|
||||
case ResourceType.PVC ->
|
||||
case ResourceType.PVC:
|
||||
{
|
||||
return pvcService;
|
||||
}
|
||||
case ResourceType.PV ->
|
||||
case ResourceType.PV:
|
||||
{
|
||||
return pvService;
|
||||
}
|
||||
case ResourceType.NAMESPACE ->
|
||||
case ResourceType.NAMESPACE:
|
||||
{
|
||||
return namespaceService;
|
||||
}
|
||||
default ->
|
||||
default :
|
||||
{
|
||||
LOG.errorf("Invalid resource type %s.", resourceType);
|
||||
throw new BadRequestException();
|
||||
|
||||
@ -30,16 +30,12 @@ public class LoginResource
|
||||
public String login(Login login)
|
||||
{
|
||||
Optional<UserEntity> userOptional = userRepo.findOptionalByUsername(login.username());
|
||||
if(userOptional.isPresent())
|
||||
if (userOptional.isPresent())
|
||||
{
|
||||
UserEntity user = userOptional.get();
|
||||
if(BcryptUtil.matches(login.password(), user.getPassword()))
|
||||
if (BcryptUtil.matches(login.password(), user.getPassword()))
|
||||
{
|
||||
return Jwt
|
||||
.upn(user.getId())
|
||||
.expiresAt(ZonedDateTime.now().plusDays(15).toInstant())
|
||||
.groups(user.getRoles())
|
||||
.sign();
|
||||
return Jwt.upn(user.getId()).expiresAt(ZonedDateTime.now().plusDays(15).toInstant()).groups(user.getRoles()).sign();
|
||||
}
|
||||
LOG.info("Cannot access user. Forbidden");
|
||||
throw new ForbiddenException(Response.status(403).type(MediaType.TEXT_PLAIN).entity("wrong_password").build());
|
||||
|
||||
@ -52,7 +52,8 @@ public class UserResource
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Transactional
|
||||
@RolesAllowed({"ADMIN", "OWNER"})
|
||||
@RolesAllowed(
|
||||
{"ADMIN", "OWNER"})
|
||||
public void createUser(UserCreation user)
|
||||
{
|
||||
if (List.of("ADMIN", "USER").contains(user.role()))
|
||||
@ -78,10 +79,10 @@ public class UserResource
|
||||
public void changePassword(@PathParam("username") String username, String password)
|
||||
{
|
||||
Optional<UserEntity> persistentUserOptional = userRepo.findOptionalByUsername(username);
|
||||
if(persistentUserOptional.isPresent() && password != null && !password.isBlank())
|
||||
if (persistentUserOptional.isPresent() && password != null && !password.isBlank())
|
||||
{
|
||||
UserEntity persistentUser = persistentUserOptional.get();
|
||||
if(securityIdentity.getPrincipal().getName().equals(persistentUser.getId()))
|
||||
if (securityIdentity.getPrincipal().getName().equals(persistentUser.getId()))
|
||||
{
|
||||
persistentUser.setPassword(BcryptUtil.bcryptHash(password));
|
||||
userRepo.persist(persistentUser);
|
||||
|
||||
@ -91,14 +91,17 @@ public class MonitoringJobRunner
|
||||
LOG.infof("Running %s %s monitoring.", config.getConfigName(), config.getType().toString().toLowerCase());
|
||||
switch (config.getType())
|
||||
{
|
||||
case VOLUME ->
|
||||
case VOLUME:
|
||||
{
|
||||
volumeMonitoringJobRunner.run(config);
|
||||
return;
|
||||
}
|
||||
case WORKLOAD ->
|
||||
case WORKLOAD:
|
||||
{
|
||||
memoryMonitoringJobRunner.run(config);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class MonitoringResource
|
||||
|
||||
switch (configCreation.type())
|
||||
{
|
||||
case MonitoringType.VOLUME ->
|
||||
case MonitoringType.VOLUME:
|
||||
{
|
||||
VolumeConfig volumeConfig = new VolumeConfig();
|
||||
volumeConfig.setId(UUID.randomUUID().toString());
|
||||
|
||||
@ -24,12 +24,10 @@ public class MonitoringService
|
||||
TargetConfig targetConfig = config.getTargetConfig();
|
||||
switch (targetConfig.getType())
|
||||
{
|
||||
case LABEL ->
|
||||
{
|
||||
case LABEL -> {
|
||||
return podService.findByNamespaceAndLabels(targetConfig.getNamespace(), targetConfig.getLabels()).stream().filter(pod -> pod.getStatus().getPhase().equals("Running")).toList();
|
||||
}
|
||||
case DEPLOYMENT, STATEFUL_SET ->
|
||||
{
|
||||
case DEPLOYMENT, STATEFUL_SET -> {
|
||||
throw new NotImplementedYet();
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,10 +38,10 @@ public class TopNodesService
|
||||
List<String> stats = runTopNodesCommand();
|
||||
Map<String, Integer> podsOnNodes = countPods();
|
||||
Map<String, NodeDiskMetrics> nodeDiskMetrics = nodeDiskService.getDiskMetrics();
|
||||
for(String nodeName : stats)
|
||||
for (String nodeName : stats)
|
||||
{
|
||||
String[] parts = nodeName.split("\\s+");
|
||||
if(parts.length == 5)
|
||||
if (parts.length == 5)
|
||||
{
|
||||
String name = parts[0];
|
||||
Node node = clientProvider.getClient().nodes().withName(name).get();
|
||||
@ -92,15 +92,15 @@ public class TopNodesService
|
||||
|
||||
private Integer extractMemory(String input)
|
||||
{
|
||||
if(input.contains("Ki"))
|
||||
if (input.contains("Ki"))
|
||||
{
|
||||
return Integer.parseInt(input.replace("Ki", ""));
|
||||
}
|
||||
if(input.contains("Mi"))
|
||||
if (input.contains("Mi"))
|
||||
{
|
||||
return Integer.parseInt(input.replace("Mi", "")) * 1024;
|
||||
}
|
||||
if(input.contains("Gi"))
|
||||
if (input.contains("Gi"))
|
||||
{
|
||||
return Integer.parseInt(input.replace("Gi", "")) * 1024 * 1024;
|
||||
}
|
||||
|
||||
@ -2,7 +2,5 @@ package dev.dinauer.monitoring.entity;
|
||||
|
||||
public enum MonitoringTargetType
|
||||
{
|
||||
DEPLOYMENT,
|
||||
STATEFUL_SET,
|
||||
LABEL
|
||||
DEPLOYMENT, STATEFUL_SET, LABEL
|
||||
}
|
||||
|
||||
@ -97,7 +97,9 @@ public class TargetConfig
|
||||
{
|
||||
try
|
||||
{
|
||||
return OBJECT_MAPPER.readValue(labels, new TypeReference<Map<String, String>>() {});
|
||||
return OBJECT_MAPPER.readValue(labels, new TypeReference<Map<String, String>>()
|
||||
{
|
||||
});
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
|
||||
@ -2,10 +2,6 @@ package dev.dinauer.monitoring.entity.creation;
|
||||
|
||||
import dev.dinauer.monitoring.entity.MonitoringType;
|
||||
|
||||
public record MonitoringConfigCreation(
|
||||
String configName,
|
||||
MonitoringType type,
|
||||
String interval,
|
||||
VolumeConfigCreation volumeConfig,
|
||||
MonitoringTargetConfigCreation targetConfig
|
||||
) {}
|
||||
public record MonitoringConfigCreation(String configName, MonitoringType type, String interval, VolumeConfigCreation volumeConfig, MonitoringTargetConfigCreation targetConfig)
|
||||
{
|
||||
}
|
||||
@ -2,11 +2,6 @@ package dev.dinauer.monitoring.entity.creation;
|
||||
|
||||
import dev.dinauer.monitoring.entity.MonitoringTargetType;
|
||||
|
||||
public record MonitoringTargetConfigCreation(
|
||||
MonitoringTargetType type,
|
||||
String namespace,
|
||||
String deploymentName,
|
||||
String statefulSetName,
|
||||
String labelKey,
|
||||
String labelValue
|
||||
) {}
|
||||
public record MonitoringTargetConfigCreation(MonitoringTargetType type, String namespace, String deploymentName, String statefulSetName, String labelKey, String labelValue)
|
||||
{
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
package dev.dinauer.monitoring.entity.creation;
|
||||
|
||||
public record VolumeConfigCreation(
|
||||
String mountPath,
|
||||
String containerName
|
||||
) {}
|
||||
public record VolumeConfigCreation(String mountPath, String containerName)
|
||||
{
|
||||
}
|
||||
|
||||
@ -28,15 +28,7 @@ public class NodeMonitoringService
|
||||
for (MonitoredNode node : nodes)
|
||||
{
|
||||
NodeMetrics nodeMetrics = node.getMetrics();
|
||||
Map<String, Number> metrics = Stream.of(
|
||||
new AbstractMap.SimpleEntry<>("RELATIVE_CPU", nodeMetrics.relativeCpuUsage()),
|
||||
new AbstractMap.SimpleEntry<>("RELATIVE_MEMORY", nodeMetrics.relativeMemory()),
|
||||
new AbstractMap.SimpleEntry<>("ABSOLUTE_MEMORY", nodeMetrics.absoluteMemory()),
|
||||
new AbstractMap.SimpleEntry<>("ABSOLUTE_CPU", nodeMetrics.absoluteCpuUsage()),
|
||||
new AbstractMap.SimpleEntry<>("RELATIVE_DISK_SPACE", nodeMetrics.relativeDiskUsage()),
|
||||
new AbstractMap.SimpleEntry<>("TOTAL_DISK_SPACE", nodeMetrics.totalDiskSpace()))
|
||||
.filter(entry -> entry.getValue() != null)
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
Map<String, Number> metrics = Stream.of(new AbstractMap.SimpleEntry<>("RELATIVE_CPU", nodeMetrics.relativeCpuUsage()), new AbstractMap.SimpleEntry<>("RELATIVE_MEMORY", nodeMetrics.relativeMemory()), new AbstractMap.SimpleEntry<>("ABSOLUTE_MEMORY", nodeMetrics.absoluteMemory()), new AbstractMap.SimpleEntry<>("ABSOLUTE_CPU", nodeMetrics.absoluteCpuUsage()), new AbstractMap.SimpleEntry<>("RELATIVE_DISK_SPACE", nodeMetrics.relativeDiskUsage()), new AbstractMap.SimpleEntry<>("TOTAL_DISK_SPACE", nodeMetrics.totalDiskSpace())).filter(entry -> entry.getValue() != null).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
bigBucketService.index(String.format("NODE-%s", node.getMetadata().getUid()), "NODE_METRICS", metrics);
|
||||
}
|
||||
|
||||
@ -10,20 +10,16 @@ public class Duration
|
||||
long value = Long.parseLong(input.substring(0, input.length() - 1));
|
||||
switch (unit)
|
||||
{
|
||||
case 's' ->
|
||||
{
|
||||
case 's' -> {
|
||||
return value;
|
||||
}
|
||||
case 'm' ->
|
||||
{
|
||||
case 'm' -> {
|
||||
return value * 60;
|
||||
}
|
||||
case 'h' ->
|
||||
{
|
||||
case 'h' -> {
|
||||
return value * 60 * 60;
|
||||
}
|
||||
default ->
|
||||
{
|
||||
default -> {
|
||||
throw new IllegalArgumentException(String.format("Invalid unit %s", unit));
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class DeploymentService implements ResourceService<Deployment>
|
||||
@Override
|
||||
public List<Deployment> findByNamespace(String namespace)
|
||||
{
|
||||
try(AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
{
|
||||
if (namespace.equals("_all"))
|
||||
{
|
||||
@ -48,7 +48,7 @@ public class DeploymentService implements ResourceService<Deployment>
|
||||
|
||||
public List<Deployment> findAll()
|
||||
{
|
||||
try(AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
{
|
||||
return dsl.deployments().inAnyNamespace().list().getItems();
|
||||
}
|
||||
@ -63,7 +63,8 @@ public class DeploymentService implements ResourceService<Deployment>
|
||||
@Override
|
||||
public Watch watch(String namespace, Watcher<Deployment> watcher)
|
||||
{
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps()) {
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
{
|
||||
String version = dsl.deployments().inAnyNamespace().list().getMetadata().getResourceVersion();
|
||||
if (namespace.equals("_all"))
|
||||
{
|
||||
@ -75,7 +76,7 @@ public class DeploymentService implements ResourceService<Deployment>
|
||||
|
||||
public void rescale(String namespace, String name, int replicaCount)
|
||||
{
|
||||
try(AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
{
|
||||
dsl.deployments().inNamespace(namespace).withName(name).scale(replicaCount);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public class IngressService implements ResourceService<Ingress>
|
||||
@Override
|
||||
public Ingress findByNameAndNamespace(String name, String namespace)
|
||||
{
|
||||
try(NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
try (NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
{
|
||||
List<Ingress> ingresses = dsl.v1().ingresses().list().getItems();
|
||||
for (Ingress ingress : ingresses)
|
||||
@ -48,7 +48,7 @@ public class IngressService implements ResourceService<Ingress>
|
||||
|
||||
public List<Ingress> findByNamespace(String namespace)
|
||||
{
|
||||
try(NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
try (NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
{
|
||||
if (namespace.equals("_all"))
|
||||
{
|
||||
@ -60,7 +60,7 @@ public class IngressService implements ResourceService<Ingress>
|
||||
|
||||
public List<Ingress> findAll()
|
||||
{
|
||||
try(NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
try (NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
{
|
||||
return dsl.v1().ingresses().inAnyNamespace().list().getItems();
|
||||
}
|
||||
@ -75,7 +75,7 @@ public class IngressService implements ResourceService<Ingress>
|
||||
@Override
|
||||
public Watch watch(String namespace, Watcher<Ingress> watcher)
|
||||
{
|
||||
try(NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
try (NetworkAPIGroupDSL dsl = clientProvider.getClient().network())
|
||||
{
|
||||
String version = dsl.v1().ingresses().inAnyNamespace().list().getMetadata().getResourceVersion();
|
||||
if (namespace.equals("_all"))
|
||||
|
||||
@ -25,14 +25,10 @@ public class PodService implements ResourceService<Pod>
|
||||
public void delete(String name, String namespace)
|
||||
{
|
||||
Optional<Pod> podOptional = findOptionalByNameAndNamespace(name, namespace);
|
||||
if(podOptional.isPresent())
|
||||
if (podOptional.isPresent())
|
||||
{
|
||||
Pod pod = podOptional.get();
|
||||
clientProvider.getClient()
|
||||
.pods()
|
||||
.inNamespace(pod.getMetadata().getNamespace())
|
||||
.withName(pod.getMetadata().getName())
|
||||
.delete();
|
||||
clientProvider.getClient().pods().inNamespace(pod.getMetadata().getNamespace()).withName(pod.getMetadata().getName()).delete();
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +49,7 @@ public class PodService implements ResourceService<Pod>
|
||||
|
||||
public List<Pod> findByStatefulSet(String name, String namespace)
|
||||
{
|
||||
try(AppsAPIGroupDSL apps = clientProvider.getClient().apps())
|
||||
try (AppsAPIGroupDSL apps = clientProvider.getClient().apps())
|
||||
{
|
||||
StatefulSet set = apps.statefulSets().inNamespace(namespace).withName(name).get();
|
||||
if (set != null)
|
||||
@ -98,9 +94,9 @@ public class PodService implements ResourceService<Pod>
|
||||
|
||||
public Optional<Pod> findPodById(String id)
|
||||
{
|
||||
for(Pod pod : clientProvider.getClient().pods().inAnyNamespace().list().getItems())
|
||||
for (Pod pod : clientProvider.getClient().pods().inAnyNamespace().list().getItems())
|
||||
{
|
||||
if(pod.getMetadata().getUid().equals(id))
|
||||
if (pod.getMetadata().getUid().equals(id))
|
||||
{
|
||||
return Optional.of(pod);
|
||||
}
|
||||
|
||||
@ -65,9 +65,9 @@ public class ServiceService implements ResourceService<Service>
|
||||
|
||||
public Optional<Service> findById(String id)
|
||||
{
|
||||
for(Service service : clientProvider.getClient().services().list().getItems())
|
||||
for (Service service : clientProvider.getClient().services().list().getItems())
|
||||
{
|
||||
if(service.getMetadata().getUid().equals(id))
|
||||
if (service.getMetadata().getUid().equals(id))
|
||||
{
|
||||
return Optional.of(service);
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public class StatefulSetService implements ResourceService<StatefulSet>
|
||||
@Override
|
||||
public List<StatefulSet> findByNamespace(String namespace)
|
||||
{
|
||||
try(AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
{
|
||||
if (namespace.equals("_all"))
|
||||
{
|
||||
@ -62,7 +62,8 @@ public class StatefulSetService implements ResourceService<StatefulSet>
|
||||
@Override
|
||||
public Watch watch(String namespace, Watcher<StatefulSet> watcher)
|
||||
{
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps()) {
|
||||
try (AppsAPIGroupDSL dsl = clientProvider.getClient().apps())
|
||||
{
|
||||
String version = dsl.statefulSets().inAnyNamespace().list().getMetadata().getResourceVersion();
|
||||
if (namespace.equals("_all"))
|
||||
{
|
||||
|
||||
@ -31,7 +31,7 @@ public class StartupService
|
||||
@PostConstruct
|
||||
public void init()
|
||||
{
|
||||
if(userRepo.findOptionalByUsername(INITIAL_USERNAME).isEmpty())
|
||||
if (userRepo.findOptionalByUsername(INITIAL_USERNAME).isEmpty())
|
||||
{
|
||||
QuarkusTransaction.begin();
|
||||
userRepo.persist(buildInitialUser());
|
||||
|
||||
@ -10,9 +10,9 @@ public class ByteExtractorTest
|
||||
void test()
|
||||
{
|
||||
String input = """
|
||||
NAME CPU(cores) MEMORY(bytes)
|
||||
postgres-cluster-1 13m 50Mi
|
||||
""";
|
||||
NAME CPU(cores) MEMORY(bytes)
|
||||
postgres-cluster-1 13m 50Mi
|
||||
""";
|
||||
|
||||
long bytes = ByteExtractor.extractBytes(input);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user