package cn.reghao.bnt.web.devops.app.model.po.log;

import cn.reghao.bnt.web.devops.app.model.po.config.AppConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;

/**
 * 对 BuildConfig 的一个 snapshot
 *
 * @author reghao
 * @date 2020-05-13 16:40:22
 */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Embeddable
public class BuildConfigSnapshot {
    private String repoType;
    private String repoName;
    private String repoAuthType;
    private String username;
    private String password;
    @Column(columnDefinition="text")
    private String rsaPrikey;

    private String compileType;
    private String compileName;
    private String compileScript;
    private String homePath;

    private String packType;
    private String packName;
    private String binDirname;
    private String targetPath;
    @Column(columnDefinition="text")
    private String dockerfile;

    public BuildConfigSnapshot(AppConfig appConfig) {
        this.repoType = appConfig.getRepoAuthConfig().getType();
        this.repoName = appConfig.getRepoAuthConfig().getName();
        this.repoAuthType = appConfig.getRepoAuthConfig().getAuthType();
        this.username = appConfig.getRepoAuthConfig().getUsername();
        this.password = appConfig.getRepoAuthConfig().getPassword();

        this.compileType = appConfig.getCompilerConfig().getType();
        this.compileName = appConfig.getCompilerConfig().getName();
        this.compileScript = appConfig.getCompilerConfig().getCompileCmd();
        this.homePath = appConfig.getCompilerConfig().getHomePath();

        this.packType = appConfig.getPackerConfig().getType();
        this.packName = appConfig.getPackerConfig().getName();
        this.binDirname = appConfig.getPackerConfig().getBinDirname();
        this.targetPath = appConfig.getPackerConfig().getTargetPath();
        this.dockerfile = appConfig.getDockerfile();
    }
}
