|
|
@@ -1,204 +0,0 @@
|
|
|
-package cn.reghao.autodop.dmaster.app.vo.orchestration;
|
|
|
-
|
|
|
-import cn.reghao.autodop.common.dagent.app.api.data.log.LogConfig;
|
|
|
-import cn.reghao.autodop.common.dagent.app.api.data.log.LogLevel;
|
|
|
-import cn.reghao.autodop.common.dagent.app.api.data.log.LogType;
|
|
|
-import cn.reghao.autodop.common.utils.serializer.JsonConverter;
|
|
|
-import cn.reghao.autodop.common.dagent.app.api.data.deploy.PackerType;
|
|
|
-import cn.reghao.autodop.dmaster.app.constant.build.CompileType;
|
|
|
-import cn.reghao.autodop.dmaster.app.constant.build.RepoAuthType;
|
|
|
-import cn.reghao.autodop.dmaster.app.constant.build.RepoType;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.build.BuildConfig;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.build.CompilerConfig;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.build.PackerConfig;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.build.RepoAuthConfig;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.AppOrchestration;
|
|
|
-import cn.reghao.autodop.dmaster.app.constant.AppType;
|
|
|
-import cn.reghao.autodop.dmaster.app.constant.EnvType;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.ProjOrchestration;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.deploy.DeployConfig;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.deploy.RunningConfig;
|
|
|
-import cn.reghao.autodop.dmaster.app.vo.BuildConfigVO;
|
|
|
-import cn.reghao.autodop.dmaster.auth.entity.Role;
|
|
|
-import lombok.Data;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author reghao
|
|
|
- * @date 2020-02-29 17:22:19
|
|
|
- */
|
|
|
-@Deprecated
|
|
|
-@Data
|
|
|
-public class AppVO {
|
|
|
- private String appId;
|
|
|
- private String env;
|
|
|
- private String description;
|
|
|
- private boolean alwaysBuild;
|
|
|
- private boolean enable;
|
|
|
-
|
|
|
- /* 构建配置 */
|
|
|
- private String appType;
|
|
|
- private String appRepo;
|
|
|
- private String branch;
|
|
|
- private String dirname;
|
|
|
- private String compileHome;
|
|
|
- private String dockerfile;
|
|
|
-
|
|
|
- private BuildConfigVO buildConfig;
|
|
|
- private String projId;
|
|
|
-
|
|
|
- /* 部署配置 */
|
|
|
- private List<DeployConfig> deployConfigs;
|
|
|
- /* 运行配置 */
|
|
|
- private RunningConfig runningConfig;
|
|
|
-
|
|
|
- private String notifier;
|
|
|
- private String role;
|
|
|
-
|
|
|
- public static AppVO from(AppOrchestration app) {
|
|
|
- AppVO vo = new AppVO();
|
|
|
- vo.appId = app.getAppId();
|
|
|
- vo.env = app.getEnv();
|
|
|
- vo.description = app.getDescription();
|
|
|
- vo.enable = app.getEnable();
|
|
|
-
|
|
|
- vo.appType = app.getAppType();
|
|
|
- vo.appRepo = app.getAppRepo();
|
|
|
- vo.branch = app.getBranch();
|
|
|
- vo.dirname = app.getDirname();
|
|
|
- vo.compileHome = app.getCompileHome();
|
|
|
- vo.dockerfile = app.getDockerfile();
|
|
|
-
|
|
|
- if (app.getBuildConfig() != null) {
|
|
|
- vo.buildConfig = BuildConfigVO.from(app.getBuildConfig());
|
|
|
- } else {
|
|
|
- vo.projId = app.getProj().getProjId();
|
|
|
- }
|
|
|
-
|
|
|
- vo.deployConfigs = app.getDeployConfigs();
|
|
|
- vo.runningConfig = app.getRunningConfig();
|
|
|
-
|
|
|
- /*if (app.getNotifyReceiver() != null) {
|
|
|
- vo.notifier = app.getNotifyReceiver().getName();
|
|
|
- }*/
|
|
|
-
|
|
|
- if (app.getRole() != null) {
|
|
|
- vo.role = app.getRole().getName();
|
|
|
- }
|
|
|
-
|
|
|
- return vo;
|
|
|
- }
|
|
|
-
|
|
|
- public static AppOrchestration to(AppVO vo) {
|
|
|
- AppOrchestration app = new AppOrchestration();
|
|
|
- app.setAppId(vo.appId);
|
|
|
- app.setEnv(vo.env);
|
|
|
- app.setDescription(vo.description);
|
|
|
- app.setEnable(vo.enable);
|
|
|
-
|
|
|
- app.setAppType(vo.appType);
|
|
|
- app.setAppRepo(vo.appRepo);
|
|
|
- app.setBranch(vo.branch);
|
|
|
- app.setDirname(vo.dirname);
|
|
|
- app.setCompileHome(vo.compileHome);
|
|
|
- app.setDockerfile(vo.getDockerfile());
|
|
|
-
|
|
|
- if (vo.getBuildConfig() != null) {
|
|
|
- app.setBuildConfig(BuildConfigVO.to(vo.getBuildConfig()));
|
|
|
- } else {
|
|
|
- app.setProj(new ProjOrchestration(vo.getProjId()));
|
|
|
- }
|
|
|
-
|
|
|
- app.setDeployConfigs(vo.getDeployConfigs());
|
|
|
- app.setRunningConfig(vo.getRunningConfig());
|
|
|
-
|
|
|
- String notifier = vo.getNotifier();
|
|
|
- /*if (notifier != null) {
|
|
|
- app.setNotifyReceiver(new NotifyReceiver(notifier));
|
|
|
- }*/
|
|
|
-
|
|
|
- String role = vo.getRole();
|
|
|
- if (role != null) {
|
|
|
- app.setRole(new Role());
|
|
|
- }
|
|
|
-
|
|
|
- return app;
|
|
|
- }
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- AppOrchestration app = new AppOrchestration();
|
|
|
- app.setAppId("content");
|
|
|
- app.setEnv(EnvType.test.name());
|
|
|
- app.setDescription("内容服务");
|
|
|
- app.setEnable(true);
|
|
|
- app.setAppType(AppType.dotnetCore.name());
|
|
|
- app.setAppRepo("https://codeup.aliyun.com/5f1f8daf6207a1a8b17f6742/background/ContentService.git");
|
|
|
- app.setBranch("develop");
|
|
|
- app.setDirname("ContentService");
|
|
|
- app.setCompileHome("");
|
|
|
-
|
|
|
- BuildConfig buildConfig = new BuildConfig();
|
|
|
- RepoAuthConfig repoAuthConfig = new RepoAuthConfig();
|
|
|
- repoAuthConfig.setName("git-codeup");
|
|
|
- repoAuthConfig.setType(RepoType.git.name());
|
|
|
- repoAuthConfig.setAuthType(RepoAuthType.ssh.name());
|
|
|
- repoAuthConfig.setRsaPrikey("rsa private key");
|
|
|
- buildConfig.setRepoAuthConfig(repoAuthConfig);
|
|
|
-
|
|
|
- CompilerConfig compilerConfig = new CompilerConfig();
|
|
|
- compilerConfig.setName("dotnet5-dev");
|
|
|
- compilerConfig.setType(CompileType.shell.name());
|
|
|
- /*compilerConfig.setHomePath("/home/reghao/dev/env/dotnet/dotnet-sdk-5.0.100-linux-x64");
|
|
|
- compilerConfig.setBinPath("/home/reghao/dev/env/dotnet/dotnet-sdk-5.0.100-linux-x64/dotnet");
|
|
|
- compilerConfig.setCompileCmd("dotnet publish");*/
|
|
|
- buildConfig.setCompilerConfig(compilerConfig);
|
|
|
-
|
|
|
- PackerConfig packerConfig = new PackerConfig();
|
|
|
- packerConfig.setName("docker-dev");
|
|
|
- packerConfig.setType(PackerType.docker.name());
|
|
|
- packerConfig.setTargetPath("docker.alpha.iquizoo.com/iq3x");
|
|
|
- buildConfig.setPackerConfig(packerConfig);
|
|
|
- app.setBuildConfig(buildConfig);
|
|
|
-
|
|
|
- List<DeployConfig> list = new ArrayList<>();
|
|
|
- DeployConfig deployConfig = new DeployConfig();
|
|
|
- deployConfig.setPackerType(PackerType.docker.name());
|
|
|
- deployConfig.setStartHome(null);
|
|
|
- deployConfig.setStartScript(null);
|
|
|
- deployConfig.setDockerConfig("{\"env\":[\"ASPNETCORE_ENVIRONMENT\\u003dProduction\",\"ASPNETCORE_URLS\\u003dhttp://172.16.45.67:8002;https://172.16.45.67:8102\"],\"hostConfig\":{\"networkMode\":\"host\",\"restartPolicy\":{\"name\":\"on-failure\",\"maximumRetryCount\":5}}}");
|
|
|
- list.add(deployConfig);
|
|
|
- app.setDeployConfigs(list);
|
|
|
-
|
|
|
- RunningConfig runningConfig = new RunningConfig();
|
|
|
- runningConfig.setHttpPort(8002);
|
|
|
- runningConfig.setHealthCheck("/health");
|
|
|
-
|
|
|
- List<LogConfig> logs = new ArrayList<>();
|
|
|
- LogConfig logConfig = new LogConfig();
|
|
|
- logConfig.setType(LogType.console.name());
|
|
|
- logConfig.setLevel(LogLevel.info.name());
|
|
|
- logConfig.setLogPath(null);
|
|
|
- logs.add(logConfig);
|
|
|
-
|
|
|
- LogConfig logConfig1 = new LogConfig();
|
|
|
- logConfig1.setType(LogType.file.name());
|
|
|
- logConfig1.setLevel(LogLevel.info.name());
|
|
|
- logConfig1.setLogPath("/Logs/Info");
|
|
|
- logs.add(logConfig);
|
|
|
- //runningConfig.setLogConfigs(logs);
|
|
|
- app.setRunningConfig(runningConfig);
|
|
|
-
|
|
|
- /*NotifyReceiver notifyReceiver = new NotifyReceiver();
|
|
|
- notifyReceiver.setName("ding-dev");
|
|
|
- notifyReceiver.setType(NotifyType.webhook.name());
|
|
|
- List<String> receivers = new ArrayList<>();
|
|
|
- receivers.add("https://oapi.dingtalk.com/robot/send?access_token=ba9cf0d846cff8c471168e0d2f91ec0c44645a086cf5e4e421697c9b0c606bd2");
|
|
|
- notifyReceiver.setReceivers(receivers);
|
|
|
- app.setNotifyReceiver(notifyReceiver);*/
|
|
|
-
|
|
|
- String json = JsonConverter.objectToJson(AppVO.from(app));
|
|
|
- System.out.println(json);
|
|
|
- }
|
|
|
-}
|