|
|
@@ -1,24 +1,13 @@
|
|
|
package cn.reghao.devops.mgr.ops.build.model.po;
|
|
|
|
|
|
import cn.reghao.devops.common.docker.model.DockerAuth;
|
|
|
-import cn.reghao.devops.common.msg.constant.PackType;
|
|
|
import cn.reghao.devops.mgr.ops.aliyun.model.po.AliyunAccount;
|
|
|
-import cn.reghao.devops.mgr.ops.build.model.provider.PackerConfigGroupSequenceProvider;
|
|
|
+import cn.reghao.devops.mgr.ops.build.model.dto.PackerConfigDto;
|
|
|
import cn.reghao.devops.mgr.ops.builder.model.dto.PackerDto;
|
|
|
import cn.reghao.devops.mgr.util.BaseEntity;
|
|
|
-import cn.reghao.jutil.jdk.web.validator.ValidEnum;
|
|
|
-import lombok.Getter;
|
|
|
+import jakarta.persistence.*;
|
|
|
+import lombok.Data;
|
|
|
import lombok.NoArgsConstructor;
|
|
|
-import lombok.Setter;
|
|
|
-import org.hibernate.validator.constraints.Length;
|
|
|
-import org.hibernate.validator.group.GroupSequenceProvider;
|
|
|
-
|
|
|
-import jakarta.persistence.Column;
|
|
|
-import jakarta.persistence.Entity;
|
|
|
-import jakarta.persistence.OneToOne;
|
|
|
-import jakarta.persistence.Table;
|
|
|
-import jakarta.validation.constraints.NotBlank;
|
|
|
-import jakarta.validation.constraints.NotNull;
|
|
|
|
|
|
/**
|
|
|
* 打包方式配置
|
|
|
@@ -26,48 +15,43 @@ import jakarta.validation.constraints.NotNull;
|
|
|
* @author reghao
|
|
|
* @date 2020-05-13 16:40:22
|
|
|
*/
|
|
|
-@GroupSequenceProvider(PackerConfigGroupSequenceProvider.class)
|
|
|
@NoArgsConstructor
|
|
|
-@Getter
|
|
|
-@Setter
|
|
|
+@Data
|
|
|
@Entity
|
|
|
@Table(name = "devops_packer_config")
|
|
|
public class PackerConfig extends BaseEntity {
|
|
|
- @ValidEnum(value = PackType.class, message = "请选择正确的打包类型")
|
|
|
private String type;
|
|
|
- @NotBlank(message = "打包名字不能包含空白符")
|
|
|
- @Length(max = 255, message = "打包名字的最大长度不能超过 255 个字符")
|
|
|
@Column(nullable = false, unique = true)
|
|
|
private String name;
|
|
|
// 构建生成的可执行文件及配置文件, 脚本文件等所在的目录路径(相对于源码根目录)
|
|
|
- @NotBlank(groups = { ZipPacker.class }, message = "构建产物路径不能为空")
|
|
|
private String artifactPath;
|
|
|
- @NotNull(groups = { DockerPacker.class }, message = "dockerRegistry 不能为 null")
|
|
|
- @OneToOne
|
|
|
- private DockerRegistry dockerRegistry;
|
|
|
- @NotNull(groups = { OssStaticPacker.class }, message = "ossEndpoint 不能为 null")
|
|
|
- @OneToOne
|
|
|
- private AliyunAccount ossEndpoint;
|
|
|
- // 打包后的应用存放的位置,可以是一个本地目录,也可以是一个网络位置
|
|
|
- // 根据打包类型来确定
|
|
|
- @NotBlank(groups = { ZipPacker.class }, message = "可执行包的存放位置不能为空白字符串")
|
|
|
- private String targetPath;
|
|
|
-
|
|
|
- public interface DockerPacker {
|
|
|
- }
|
|
|
|
|
|
- public interface OssStaticPacker {
|
|
|
- }
|
|
|
+ @ManyToOne(cascade = CascadeType.REFRESH)
|
|
|
+ @JoinColumn(name = "docker_registry_id")
|
|
|
+ private DockerRegistry targetPathDocker;
|
|
|
|
|
|
- public interface ZipPacker {
|
|
|
+ @ManyToOne(cascade = CascadeType.REFRESH)
|
|
|
+ @JoinColumn(name = "aliyun_account_id")
|
|
|
+ private AliyunAccount targetPathOss;
|
|
|
+ // 打包后的应用存放的位置,可以是一个本地目录,也可以是一个网络位置
|
|
|
+ // 根据打包类型来确定
|
|
|
+ private String targetPathLocal;
|
|
|
+
|
|
|
+ public PackerConfig(PackerConfigDto packerConfigDto, DockerRegistry dockerRegistry, AliyunAccount ossEndpoint) {
|
|
|
+ this.type = packerConfigDto.getType();
|
|
|
+ this.name = packerConfigDto.getName();
|
|
|
+ this.artifactPath = packerConfigDto.getArtifactPath();
|
|
|
+ this.targetPathDocker = dockerRegistry;
|
|
|
+ this.targetPathOss = ossEndpoint;
|
|
|
+ this.targetPathLocal = packerConfigDto.getTargetPath();
|
|
|
}
|
|
|
|
|
|
public PackerDto getPackerDto() {
|
|
|
- return new PackerDto(this.type, this.name, this.targetPath, this.artifactPath);
|
|
|
+ return new PackerDto(this.type, this.name, this.targetPathLocal, this.artifactPath);
|
|
|
}
|
|
|
|
|
|
public DockerAuth getDockerAuth() {
|
|
|
- DockerRegistry registry = this.dockerRegistry;
|
|
|
+ DockerRegistry registry = this.targetPathDocker;
|
|
|
if (registry != null) {
|
|
|
String username = registry.getRepoAuthConfig().getUsername();
|
|
|
String password = registry.getRepoAuthConfig().getPassword();
|