added some optimizations

This commit is contained in:
yoan
2024-08-23 11:33:43 +08:00
parent a5beb26d9d
commit f394e34861
13 changed files with 192 additions and 69 deletions

View File

@@ -31,18 +31,23 @@ type Deployer interface {
Deploy(ctx context.Context) error
}
func Get(record *models.Record) (Deployer, error) {
func Get(record *models.Record, cert *applicant.Certificate) (Deployer, error) {
access := record.ExpandedOne("targetAccess")
option := &DeployerOption{
DomainId: record.Id,
Domain: record.GetString("domain"),
Product: getProduct(record),
Access: access.GetString("config"),
Certificate: applicant.Certificate{
}
if cert != nil {
option.Certificate = *cert
} else {
option.Certificate = applicant.Certificate{
Certificate: record.GetString("certificate"),
PrivateKey: record.GetString("privateKey"),
},
}
}
switch record.GetString("targetType") {
case targetAliyunOss:
return NewAliyun(option)