|
|
@@ -2,8 +2,10 @@ package com.ruoyi.platform.service.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.util.DateUtils; |
|
|
import com.alibaba.fastjson2.util.DateUtils; |
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
|
|
|
import com.ruoyi.platform.domain.DevEnvironment; |
|
|
import com.ruoyi.platform.domain.Image; |
|
|
import com.ruoyi.platform.domain.Image; |
|
|
import com.ruoyi.platform.domain.ImageVersion; |
|
|
import com.ruoyi.platform.domain.ImageVersion; |
|
|
|
|
|
import com.ruoyi.platform.mapper.DevEnvironmentDao; |
|
|
import com.ruoyi.platform.mapper.ImageDao; |
|
|
import com.ruoyi.platform.mapper.ImageDao; |
|
|
import com.ruoyi.platform.mapper.ImageVersionDao; |
|
|
import com.ruoyi.platform.mapper.ImageVersionDao; |
|
|
import com.ruoyi.platform.service.ImageService; |
|
|
import com.ruoyi.platform.service.ImageService; |
|
|
@@ -44,6 +46,8 @@ public class ImageServiceImpl implements ImageService { |
|
|
private ImageDao imageDao; |
|
|
private ImageDao imageDao; |
|
|
@Resource |
|
|
@Resource |
|
|
private ImageVersionDao imageVersionDao; |
|
|
private ImageVersionDao imageVersionDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private DevEnvironmentDao devEnvironmentDao; |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private ImageVersionService imageVersionService; |
|
|
private ImageVersionService imageVersionService; |
|
|
@@ -357,7 +361,6 @@ public class ImageServiceImpl implements ImageService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Async |
|
|
|
|
|
@Transactional |
|
|
@Transactional |
|
|
public String saveImage(ImageVo imageVo) { |
|
|
public String saveImage(ImageVo imageVo) { |
|
|
if(imageDao.getByName(imageVo.getName()) != null){ |
|
|
if(imageDao.getByName(imageVo.getName()) != null){ |
|
|
@@ -365,7 +368,7 @@ public class ImageServiceImpl implements ImageService { |
|
|
} |
|
|
} |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
String username = loginUser.getUsername().toLowerCase(); |
|
|
String username = loginUser.getUsername().toLowerCase(); |
|
|
String podName = username +"-editor-pod" + "-" + imageVo.getDevEnvironmentId(); |
|
|
|
|
|
|
|
|
String podName = username +"-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString(); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
String containerId = k8sClientUtil.getPodContainerId(podName, namespace); |
|
|
String containerId = k8sClientUtil.getPodContainerId(podName, namespace); |
|
|
@@ -397,6 +400,12 @@ public class ImageServiceImpl implements ImageService { |
|
|
imageVersion.setStatus("available"); |
|
|
imageVersion.setStatus("available"); |
|
|
imageVersionDao.insert(imageVersion); |
|
|
imageVersionDao.insert(imageVersion); |
|
|
|
|
|
|
|
|
|
|
|
//更新dev环境的镜像信息 |
|
|
|
|
|
DevEnvironment devEnvironment = new DevEnvironment(); |
|
|
|
|
|
devEnvironment.setId(imageVo.getDevEnvironmentId()); |
|
|
|
|
|
devEnvironment.setImage(resultMap.get("imageName")); |
|
|
|
|
|
devEnvironmentDao.update(devEnvironment); |
|
|
|
|
|
|
|
|
return "保存镜像成功"; |
|
|
return "保存镜像成功"; |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
throw new RuntimeException("保存镜像失败:" +e); |
|
|
throw new RuntimeException("保存镜像失败:" +e); |
|
|
|