diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/DevEnvironment.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/DevEnvironment.java index 8acca733..24476a83 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/DevEnvironment.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/DevEnvironment.java @@ -63,7 +63,7 @@ public class DevEnvironment implements Serializable { /** * 备用字段2 */ - private String codePath; + private String codeConfig; /** * 创建者 */ diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java index 925437df..368f8f4b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DevEnvironmentServiceImpl.java @@ -1,6 +1,6 @@ package com.ruoyi.platform.service.impl; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.bean.BeanUtil; import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.platform.domain.CodeConfig; @@ -10,8 +10,8 @@ import com.ruoyi.platform.mapper.DevEnvironmentDao; import com.ruoyi.platform.service.*; import com.ruoyi.platform.utils.DVCUtils; import com.ruoyi.platform.utils.JacksonUtil; +import com.ruoyi.platform.utils.JsonUtils; import com.ruoyi.platform.vo.DevEnvironmentVo; -import com.ruoyi.platform.vo.GitProjectVo; import com.ruoyi.platform.vo.PodStatusVo; import com.ruoyi.system.api.constant.Constant; import com.ruoyi.system.api.model.LoginUser; @@ -120,7 +120,8 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { //插入预备,此时不需要判断版本重复 DevEnvironment devEnvironment = new DevEnvironment(); LoginUser loginUser = SecurityUtils.getLoginUser(); - String localPath = cloneCode(devEnvironmentVo.getCodeConfigId()); + Map codeConfig = devEnvironmentVo.getCodeConfig(); + cloneCodePath(codeConfig); devEnvironment.setName(devEnvironmentVo.getName()); //状态先设为未知 devEnvironment.setStatus(Constant.Unknown); @@ -140,7 +141,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { devEnvironment.setUpdateTime(new Date()); devEnvironment.setCreateTime(new Date()); devEnvironment.setState(Constant.State_valid); - devEnvironment.setCodePath(localPath); + devEnvironment.setCodeConfig(JsonUtils.mapToJson(codeConfig)); this.devEnvironmentDao.insert(devEnvironment); return devEnvironment; } @@ -198,32 +199,26 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { /** * 保存代码数据并返回保存路径 - * @param codeConfigId + * + * @param codeMap * @return */ - private String cloneCode(Long codeConfigId) { - String localPath = null; - try { - CodeConfig codeConfig = codeConfigService.queryById(codeConfigId); - if (ObjectUtil.isEmpty(codeConfig)) { - log.info("[returnCodeConfig error,codeConfigId={}]", codeConfigId); - return localPath; - } - - LoginUser loginUser = SecurityUtils.getLoginUser(); - String gitLinkUsername = loginUser.getSysUser().getUserName(); - String ci4sUsername = Boolean.TRUE.equals(codeConfig.getIsPublic()) ? Constant.Item_Public : loginUser.getUsername(); + private void cloneCodePath(Map codeMap) { + CodeConfig codeConfig = BeanUtil.copyProperties(codeMap, CodeConfig.class); + LoginUser loginUser = SecurityUtils.getLoginUser(); + String gitLinkUsername = loginUser.getSysUser().getUserName(); + String ci4sUsername = Boolean.TRUE.equals(codeConfig.getIsPublic()) ? Constant.Item_Public : loginUser.getUsername(); - String gitLinkPassword = decrypt(loginUser.getSysUser().getOriginPassword()); - String repositoryName = ci4sUsername + "_code_" + DateUtils.dateTimeNow(); + String gitLinkPassword = decrypt(loginUser.getSysUser().getOriginPassword()); + String repositoryName = ci4sUsername + "_code_" + DateUtils.dateTimeNow(); - String relatePath = ci4sUsername + "/code/" + repositoryName + "/" + codeConfig.getGitBranch(); - localPath = localPathlocal + relatePath; + String relatePath = ci4sUsername + "/code/" + repositoryName + "/" + codeConfig.getGitBranch(); + String localPath = localPathlocal + relatePath; + try { dvcUtils.gitClone(localPath, codeConfig.getGitUrl(), codeConfig.getGitBranch(), gitLinkUsername, gitLinkPassword); - } catch (Exception e) { - log.error("[returnCodeConfig error,e={},codeConfigId={}]",e.getMessage(),codeConfigId); + log.error("[returnCodeConfig error,e={},codeConfigId={}]", e.getMessage(), codeConfig.getId()); } - return localPath; + codeMap.put("path", localPath); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java index e79f2139..0c2a0919 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java @@ -97,6 +97,10 @@ public class JupyterServiceImpl implements JupyterService { // String modelPath = "argo-workflow" + "/" + model.get("path"); String modelPath = (String) model.get("path"); + Map code = JacksonUtil.parseJSONStr2Map(devEnvironment.getCodeConfig()); +// String modelPath = "argo-workflow" + "/" + model.get("path"); + String codePath = (String) code.get("path"); + //构造pod名称 String podName = devEnvironment.getCreateBy() + "-editor-pod" + "-" + id; //新建编辑器的pvc @@ -105,7 +109,7 @@ public class JupyterServiceImpl implements JupyterService { // 调用修改后的 createPod 方法,传入额外的参数 // Integer podPort = k8sClientUtil.createConfiguredPod(podName, namespace, port, mountPath, pvc, devEnvironment, minioPvcName, datasetPath, modelPath); - Integer podPort = k8sClientUtil.createConfiguredPod(podName, namespace, port, mountPath, null, devEnvironment, minioPvcName, datasetPath, modelPath,devEnvironment.getCodePath()); + Integer podPort = k8sClientUtil.createConfiguredPod(podName, namespace, port, mountPath, null, devEnvironment, minioPvcName, datasetPath, modelPath,codePath); String url = masterIp + ":" + podPort; redisService.setCacheObject(podName, masterIp + ":" + podPort); devEnvironment.setStatus(Constant.Pending); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/DevEnvironmentVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/DevEnvironmentVo.java index 0cce7d79..b7e0db91 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/DevEnvironmentVo.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/DevEnvironmentVo.java @@ -32,10 +32,6 @@ public class DevEnvironmentVo implements Serializable { */ private String envVariable; - /** - * 代码配置ID - */ - private Long codeConfigId; /** * 所用镜像 */ @@ -49,4 +45,9 @@ public class DevEnvironmentVo implements Serializable { */ private Map model; + /** + * 代码配置 + */ + private Map codeConfig; + } diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml index 71a0de1f..5dfc773d 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/DevEnvironmentDaoMapper.xml @@ -4,7 +4,7 @@ @@ -12,7 +12,7 @@