优化结构

This commit is contained in:
Yvan
2026-08-24 13:25:16 +08:00
parent 7a9a738c6a
commit 0b6b8ddf1a
72 changed files with 2475 additions and 1443 deletions
@@ -11,7 +11,7 @@ import (
"strings"
"time"
"kra/internal/conf"
"kra/internal/config"
cos "github.com/tencentyun/cos-go-sdk-v5"
)
@@ -21,7 +21,7 @@ type tencentStorage struct {
baseURL, prefix string
}
func newTencentStorage(config *conf.AdminBackend_ObjectStore) (system.FileStorage, error) {
func newTencentStorage(config *config.ObjectStore) (system.FileStorage, error) {
if config == nil || config.Bucket == "" || config.Region == "" || config.AccessKey == "" || config.SecretKey == "" {
return nil, fmt.Errorf("tencent-cos storage configuration is incomplete")
}
@@ -29,7 +29,7 @@ func newTencentStorage(config *conf.AdminBackend_ObjectStore) (system.FileStorag
if endpoint == "" {
endpoint = fmt.Sprintf("https://%s.cos.%s.myqcloud.com", config.Bucket, config.Region)
} else if !strings.HasPrefix(endpoint, "http://") && !strings.HasPrefix(endpoint, "https://") {
if config.UseSsl {
if config.UseSSL {
endpoint = "https://" + endpoint
} else {
endpoint = "http://" + endpoint
@@ -40,7 +40,7 @@ func newTencentStorage(config *conf.AdminBackend_ObjectStore) (system.FileStorag
return nil, err
}
client := cos.NewClient(&cos.BaseURL{BucketURL: bucketURL}, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: config.AccessKey, SecretKey: config.SecretKey}})
return &tencentStorage{client: client, baseURL: strings.TrimSuffix(config.BaseUrl, "/"), prefix: strings.Trim(config.PathPrefix, "/")}, nil
return &tencentStorage{client: client, baseURL: strings.TrimSuffix(config.BaseURL, "/"), prefix: strings.Trim(config.PathPrefix, "/")}, nil
}
func (s *tencentStorage) key(name string) string {
if s.prefix == "" {