diff --git a/microservices-modules/microservices-modules-mon/src/main/java/com/microservices/mon/k8s/service/impl/K8SDashboardServiceImpl.java b/microservices-modules/microservices-modules-mon/src/main/java/com/microservices/mon/k8s/service/impl/K8SDashboardServiceImpl.java index 5e5bce71d..c2f78d9ee 100644 --- a/microservices-modules/microservices-modules-mon/src/main/java/com/microservices/mon/k8s/service/impl/K8SDashboardServiceImpl.java +++ b/microservices-modules/microservices-modules-mon/src/main/java/com/microservices/mon/k8s/service/impl/K8SDashboardServiceImpl.java @@ -247,6 +247,15 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo JSONObject applicationJson = remoteRancherService.getK8sApplicationDetail(cluster_id, K8sApplication.getApplicationFullKind(kind), namespace, applicationName, SecurityContextHolder.getUserKey()); RancherApplicationVo rancherApplicationVo = applicationJson.toJavaObject(RancherApplicationVo.class); if (rancherApplicationVo != null && rancherApplicationVo.getMetadata() != null && rancherApplicationVo.getMetadata().getLabels() != null) { + // 所有应用添加启停管理功能 + ApplicationFunction applicationFunction = new ApplicationFunction(); + applicationFunction.setKeyAndName(ApplicationFunctionType.START_AND_STOP_MANAGEMENT); + // 使用命名空间和应用名称作为搜索条件 + JSONObject functionVariables = new JSONObject(); + functionVariables.put("namespace", namespace); + functionVariables.put("applicationName", applicationName); + applicationFunction.setVariables(functionVariables); + applicationFunctionsList.add(applicationFunction); JSONObject LabelsJson = rancherApplicationVo.getMetadata().getLabels(); for (String key : LabelsJson.keySet()) { String k8sLabelValue = LabelsJson.getString(key); @@ -264,9 +273,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo for (int i = 0; i < skywalkingServicesArray.size(); i++) { JSONObject skywalkingService = skywalkingServicesArray.getJSONObject(i); if (k8sLabelValue.equals(skywalkingService.getString("shortName"))) { - ApplicationFunction applicationFunction = new ApplicationFunction(); + applicationFunction = new ApplicationFunction(); applicationFunction.setKeyAndName(applicationFunctionType); - JSONObject functionVariables = new JSONObject(); + functionVariables = new JSONObject(); functionVariables.put("serviceId", skywalkingService.getString("id")); applicationFunction.setVariables(functionVariables); applicationFunctionsList.add(applicationFunction); @@ -282,9 +291,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo for (int i = 0; i < sentinelAppListArray.size(); i++) { JSONObject sentinelApp = sentinelAppListArray.getJSONObject(i); if (k8sLabelValue.equals(sentinelApp.getString("app"))) { - ApplicationFunction applicationFunction = new ApplicationFunction(); + applicationFunction = new ApplicationFunction(); applicationFunction.setKeyAndName(applicationFunctionType); - JSONObject functionVariables = new JSONObject(); + functionVariables = new JSONObject(); functionVariables.put("app", k8sLabelValue); functionVariables.put("appType", sentinelApp.getLongValue("appType")); applicationFunction.setVariables(functionVariables); @@ -301,9 +310,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo for (int i = 0; i < nacosServiceListArray.size(); i++) { JSONObject nacosService = nacosServiceListArray.getJSONObject(i); if (k8sLabelValue.equals(nacosService.getString("name"))) { - ApplicationFunction applicationFunction = new ApplicationFunction(); + applicationFunction = new ApplicationFunction(); applicationFunction.setKeyAndName(applicationFunctionType); - JSONObject functionVariables = new JSONObject(); + functionVariables = new JSONObject(); functionVariables.put("name", k8sLabelValue); applicationFunction.setVariables(functionVariables); applicationFunctionsList.add(applicationFunction); @@ -320,9 +329,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo JSONObject nacosService = nacosConfigListJSONArray.getJSONObject(i); String dataId = nacosService.getString("dataId"); if (StringUtils.isNotEmpty(dataId) && dataId.contains(k8sLabelValue)) { - ApplicationFunction applicationFunction = new ApplicationFunction(); + applicationFunction = new ApplicationFunction(); applicationFunction.setKeyAndName(applicationFunctionType); - JSONObject functionVariables = new JSONObject(); + functionVariables = new JSONObject(); functionVariables.put("dataId", dataId); applicationFunction.setVariables(functionVariables); applicationFunctionsList.add(applicationFunction);