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

@@ -11,21 +11,21 @@ import (
"github.com/usual2970/certimate/internal/pkg/core/uploader"
)
type TencentCloudSSLUploaderConfig struct {
type UploaderConfig struct {
// 腾讯云 SecretId。
SecretId string `json:"secretId"`
// 腾讯云 SecretKey。
SecretKey string `json:"secretKey"`
}
type TencentCloudSSLUploader struct {
config *TencentCloudSSLUploaderConfig
type UploaderProvider struct {
config *UploaderConfig
sdkClient *tcSsl.Client
}
var _ uploader.Uploader = (*TencentCloudSSLUploader)(nil)
var _ uploader.Uploader = (*UploaderProvider)(nil)
func New(config *TencentCloudSSLUploaderConfig) (*TencentCloudSSLUploader, error) {
func NewUploader(config *UploaderConfig) (*UploaderProvider, error) {
if config == nil {
panic("config is nil")
}
@@ -38,13 +38,13 @@ func New(config *TencentCloudSSLUploaderConfig) (*TencentCloudSSLUploader, error
return nil, xerrors.Wrap(err, "failed to create sdk client")
}
return &TencentCloudSSLUploader{
return &UploaderProvider{
config: config,
sdkClient: client,
}, nil
}
func (u *TencentCloudSSLUploader) 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) {
// 上传新证书
// REF: https://cloud.tencent.com/document/product/400/41665
uploadCertificateReq := tcSsl.NewUploadCertificateRequest()