refactor: clean code

This commit is contained in:
Fu Diwei
2026-07-31 13:58:18 +08:00
parent baceeb0996
commit 6a72a966be
9 changed files with 39 additions and 13 deletions

View File

@@ -190,8 +190,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
cfg.Region = region
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint
@@ -199,6 +200,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
cfg.BaseUrl = "https://" + endpoint
}
}
if region != "" {
cfg.Region = region
}
credential := auth.NewCredential()
credential.PrivateKey = privateKey

View File

@@ -187,7 +187,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint string) (*ucloud
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint

View File

@@ -241,7 +241,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint string) (*ucloud
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint

View File

@@ -317,8 +317,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
cfg.Region = region
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint
@@ -326,6 +327,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
cfg.BaseUrl = "https://" + endpoint
}
}
if region != "" {
cfg.Region = region
}
credential := auth.NewCredential()
credential.PrivateKey = privateKey

View File

@@ -134,7 +134,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint string) (*ucloud
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint

View File

@@ -263,8 +263,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
cfg.Region = region
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint
@@ -272,6 +273,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
cfg.BaseUrl = "https://" + endpoint
}
}
if region != "" {
cfg.Region = region
}
credential := auth.NewCredential()
credential.PrivateKey = privateKey

View File

@@ -107,7 +107,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint string) (*ucloud
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint

View File

@@ -122,7 +122,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint string) (*ucloud
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint

View File

@@ -124,8 +124,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
}
cfg := ucloud.NewConfig()
cfg.ProjectId = projectId
cfg.Region = region
if projectId != "" {
cfg.ProjectId = projectId
}
if endpoint != "" {
if strings.Contains(endpoint, "://") {
cfg.BaseUrl = endpoint
@@ -133,6 +134,9 @@ func createSDKClient(privateKey, publicKey, projectId, endpoint, region string)
cfg.BaseUrl = "https://" + endpoint
}
}
if region != "" {
cfg.Region = region
}
credential := auth.NewCredential()
credential.PrivateKey = privateKey