package cn.reghao.bnt.web.devops.app.model.dto;

import cn.reghao.bnt.web.devops.app.model.constant.AppType;
import cn.reghao.jutil.jdk.web.validator.ValidEnum;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

/**
 * @author reghao
 * @date 2023-03-10 15:00:20
 */
@NoArgsConstructor
@Setter
@Getter
public class AppConfigDto {
    @Pattern(regexp = "^\\S*$", message = "应用 ID 不能包含空白符")
    @Length(max = 20, message = "应用 ID 的最大长度为 20 个字符")
    private String appId;
    @NotBlank(message = "应用名字不能为空白符")
    @Length(min = 2, max = 20, message = "应用名字的长度为 2 ～ 20 个字符")
    private String appName;
    @NotNull
    @ValidEnum(value = AppType.class, message = "请选择正确的应用类型")
    private String appType;
    @NotBlank(message = "必须指定应用环境")
    private String env;
    @NotBlank(message = "必须指定应用仓库")
    private String appRepo;
    @NotBlank(message = "必须指定仓库分支")
    private String repoBranch;
    private String appRootPath;
    private String bindPorts;

    // buildConfig
    @NotBlank(message = "必须指定仓库认证")
    private String repoAuthConfig;
    @NotBlank(message = "必须指定编译配置")
    private String compilerConfig;
    @NotBlank(message = "必须指定打包配置")
    private String packerConfig;
    private String dockerfile;
}
