package cn.reghao.autodop.dmaster.app.model.po.config;

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Lob;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 应用部署配置
 *
 * @author reghao
 * @date 2020-05-13 16:59:20
 */
@NoArgsConstructor
@Data
@Embeddable
public class DeployConfig {
    @NotBlank(message = "machineId 不能为空白字符串")
    private String machineId;
    @NotNull
    private String machineIpv4;
    @NotNull
    private String packType;
    // packType 是 docker 时 startScript 的内容是 cn.reghao.autodop.common.dockerc.pojo.Config 序列化为 JSON 后的字符串
    // 具体参照 https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate 的 reqeust body
    @Lob
    @Column(columnDefinition="text")
    @NotBlank(message = "startScript 不能为空白字符串")
    private String startScript;
    @Lob
    @Column(columnDefinition="text")
    private String unpackScript;
    private String startHome;

    public DeployConfig(String machineId, String machineIpv4, String packType, String startScript) {
        this.machineId = machineId;
        this.machineIpv4 = machineIpv4;
        this.packType = packType;
        this.startScript = startScript;
    }
}
