refactor: normalize providers constructors

This commit is contained in:
Fu Diwei
2025-02-20 00:16:26 +08:00
parent 72896e052c
commit 0e1f720419
48 changed files with 139 additions and 139 deletions

View File

@@ -16,21 +16,21 @@ import (
"github.com/usual2970/certimate/internal/pkg/utils/certs"
)
type ByteplusCDNUploaderConfig struct {
type UploaderConfig struct {
// BytePlus AccessKey。
AccessKey string `json:"accessKey"`
// BytePlus SecretKey。
SecretKey string `json:"secretKey"`
}
type ByteplusCDNUploader struct {
config *ByteplusCDNUploaderConfig
type UploaderProvider struct {
config *UploaderConfig
sdkClient *bpCdn.CDN
}
var _ uploader.Uploader = (*ByteplusCDNUploader)(nil)
var _ uploader.Uploader = (*UploaderProvider)(nil)
func New(config *ByteplusCDNUploaderConfig) (*ByteplusCDNUploader, error) {
func NewUploader(config *UploaderConfig) (*UploaderProvider, error) {
if config == nil {
panic("config is nil")
}
@@ -39,13 +39,13 @@ func New(config *ByteplusCDNUploaderConfig) (*ByteplusCDNUploader, error) {
client.Client.SetAccessKey(config.AccessKey)
client.Client.SetSecretKey(config.SecretKey)
return &ByteplusCDNUploader{
return &UploaderProvider{
config: config,
sdkClient: client,
}, nil
}
func (u *ByteplusCDNUploader) Upload(ctx context.Context, certPem string, privkeyPem string) (res *uploader.UploadResult, err error) {
func (u *UploaderProvider) Upload(ctx context.Context, certPem string, privkeyPem string) (res *uploader.UploadResult, err error) {
// 解析证书内容
certX509, err := certs.ParseCertificateFromPEM(certPem)
if err != nil {