| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package cn.seecoder.paas.service.model.vo;
- import cn.seecoder.paas.util.enums.ConfigBelongsToType;
- import com.fasterxml.jackson.annotation.JsonIgnore;
- import com.fasterxml.jackson.annotation.JsonProperty;
- import lombok.AllArgsConstructor;
- import lombok.Data;
- import lombok.NoArgsConstructor;
- import java.util.Collections;
- import java.util.HashMap;
- import java.util.Map;
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- public class ConfigVO {
- private Integer id;
- private ConfigBelongsToType configBelongs;
- private Integer entityId;
- private ConfigContent config;
- private static final ConfigContent EMPTY_CONFIG_CONTENT;
- static {
- EMPTY_CONFIG_CONTENT = new ConfigContent(null, null, Collections.emptyMap(), null, null, Collections.emptyMap(), Collections.emptyMap(), null, null, Collections.emptyMap(), Collections.emptyMap());
- }
- public static ConfigVO getEmptyConfigVO(ConfigBelongsToType configBelongs, Integer entityId) {
- ConfigVO configVO = new ConfigVO();
- configVO.setEntityId(entityId);
- configVO.setConfigBelongs(configBelongs);
- configVO.setConfig(EMPTY_CONFIG_CONTENT);
- return configVO;
- }
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
- public static class ConfigContent {
- @JsonIgnore
- public static final String PATH_DELIMITER = "-spdelimiter-";
- /**
- * 服务端口
- */
- @JsonProperty("servicePort")
- private String servicePort;
- /**
- * 服务端口
- */
- @JsonProperty("ingressPort")
- private String ingressPort;
- /**
- * 环境变量配置
- */
- @JsonProperty("envs")
- private Map<String, String> envs;
- /**
- * 启动参数配置 CMD space split
- */
- @JsonProperty("runArgs")
- private String runArgs;
- /**
- * 运行命令配置 ENTRYPOINT space split
- */
- @JsonProperty("runCommands")
- private String runCommands;
- /**
- * 挂载文件配置
- */
- @JsonProperty("mounts")
- private Map<String, String> mounts;
- /**
- * key:hostPath
- * value:mountPath
- */
- @JsonProperty("hostPath")
- private Map<String, String> hostPath;
- @JsonProperty("hostPrefix")
- private String hostPrefix;
- @JsonProperty("replicas")
- private Integer replicas;
- @JsonProperty("ingressAnnotations")
- private Map<String, Map<String, String>> ingressAnnotations;
- /**
- * key:pvcName
- * value:pvcValue
- */
- @JsonProperty("pvcPaths")
- private Map<String, String> pvcPaths;
- @JsonIgnore()
- public boolean isValid() {
- return servicePort != null && hostPrefix != null;
- }
- @JsonIgnore()
- public Map<String, String> getMountsConfigMaps() {
- if (this.mounts == null) {
- return Collections.emptyMap();
- }
- Map<String, String> maps = new HashMap<>();
- for (String key : this.mounts.keySet()) {
- maps.put(key.replaceAll("/", PATH_DELIMITER), this.mounts.get(key));
- }
- return maps;
- }
- }
- }
|