mirror of
https://github.com/usual2970/certimate.git
synced 2025-07-25 22:08:33 +00:00
init
This commit is contained in:
49
internal/deployer/deployer.go
Normal file
49
internal/deployer/deployer.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package deployer
|
||||
|
||||
import (
|
||||
"certimate/internal/applicant"
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
const (
|
||||
configTypeAliyun = "aliyun"
|
||||
)
|
||||
|
||||
type DeployerOption struct {
|
||||
Domain string `json:"domain"`
|
||||
Product string `json:"product"`
|
||||
Access string `json:"access"`
|
||||
Certificate applicant.Certificate `json:"certificate"`
|
||||
}
|
||||
|
||||
type Deployer interface {
|
||||
Deploy(ctx context.Context) error
|
||||
}
|
||||
|
||||
func Get(record *models.Record) (Deployer, error) {
|
||||
access := record.ExpandedOne("targetAccess")
|
||||
switch access.GetString("configType") {
|
||||
case configTypeAliyun:
|
||||
option := &DeployerOption{
|
||||
Domain: record.GetString("domain"),
|
||||
Product: getProduct(record),
|
||||
Access: access.GetString("config"),
|
||||
Certificate: applicant.Certificate{
|
||||
Certificate: record.GetString("certificate"),
|
||||
PrivateKey: record.GetString("privateKey"),
|
||||
},
|
||||
}
|
||||
return NewAliyun(option)
|
||||
}
|
||||
return nil, errors.New("not implemented")
|
||||
}
|
||||
|
||||
func getProduct(record *models.Record) string {
|
||||
targetType := record.GetString("targetType")
|
||||
rs := strings.Split(targetType, "-")
|
||||
return rs[1]
|
||||
}
|
Reference in New Issue
Block a user