mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-13 07:59:52 +00:00
Merge branch 'main' into feat/cloud-load-balance
This commit is contained in:
parent
896b5d3a13
commit
8d41a9aae7
@ -10,8 +10,8 @@ import (
|
|||||||
scmModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/model"
|
scmModel "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/model"
|
||||||
scmRegion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/region"
|
scmRegion "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/region"
|
||||||
|
|
||||||
"certimate/internal/pkg/core/uploader"
|
"github.com/usual2970/certimate/internal/pkg/core/uploader"
|
||||||
"certimate/internal/pkg/utils/x509"
|
"github.com/usual2970/certimate/internal/pkg/utils/x509"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HuaweiCloudSCMUploaderConfig struct {
|
type HuaweiCloudSCMUploaderConfig struct {
|
||||||
@ -49,15 +49,10 @@ func (u *HuaweiCloudSCMUploader) Upload(ctx context.Context, certPem string, pri
|
|||||||
listCertificatesOffset := int32(0)
|
listCertificatesOffset := int32(0)
|
||||||
for {
|
for {
|
||||||
listCertificatesReq := &scmModel.ListCertificatesRequest{
|
listCertificatesReq := &scmModel.ListCertificatesRequest{
|
||||||
<<<<<<< HEAD
|
|
||||||
Limit: int32Ptr(listCertificatesLimit),
|
Limit: int32Ptr(listCertificatesLimit),
|
||||||
Offset: int32Ptr(listCertificatesOffset),
|
Offset: int32Ptr(listCertificatesOffset),
|
||||||
SortDir: stringPtr("DESC"),
|
SortDir: stringPtr("DESC"),
|
||||||
SortKey: stringPtr("certExpiredTime"),
|
SortKey: stringPtr("certExpiredTime"),
|
||||||
=======
|
|
||||||
Limit: int32Ptr(listCertificatesLimit),
|
|
||||||
Offset: int32Ptr(listCertificatesOffset),
|
|
||||||
>>>>>>> 1ff10bf989afaa505a3fc2fda668ffcded815d09
|
|
||||||
}
|
}
|
||||||
listCertificatesResp, err := u.client.ListCertificates(listCertificatesReq)
|
listCertificatesResp, err := u.client.ListCertificates(listCertificatesReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -77,7 +72,6 @@ func (u *HuaweiCloudSCMUploader) Upload(ctx context.Context, certPem string, pri
|
|||||||
return nil, fmt.Errorf("failed to execute request 'scm.ExportCertificate': %w", err)
|
return nil, fmt.Errorf("failed to execute request 'scm.ExportCertificate': %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
var isSameCert bool
|
var isSameCert bool
|
||||||
if *exportCertificateResp.Certificate == certPem {
|
if *exportCertificateResp.Certificate == certPem {
|
||||||
isSameCert = true
|
isSameCert = true
|
||||||
@ -92,15 +86,6 @@ func (u *HuaweiCloudSCMUploader) Upload(ctx context.Context, certPem string, pri
|
|||||||
|
|
||||||
// 如果已存在相同证书,直接返回已有的证书信息
|
// 如果已存在相同证书,直接返回已有的证书信息
|
||||||
if isSameCert {
|
if isSameCert {
|
||||||
=======
|
|
||||||
cert, err := x509.ParseCertificateFromPEM(*exportCertificateResp.Certificate)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if x509.EqualCertificate(cert, newCert) {
|
|
||||||
// 如果已存在相同证书,直接返回已有的证书信息
|
|
||||||
>>>>>>> 1ff10bf989afaa505a3fc2fda668ffcded815d09
|
|
||||||
return &uploader.UploadResult{
|
return &uploader.UploadResult{
|
||||||
CertId: certDetail.Id,
|
CertId: certDetail.Id,
|
||||||
CertName: certDetail.Name,
|
CertName: certDetail.Name,
|
||||||
@ -114,12 +99,9 @@ func (u *HuaweiCloudSCMUploader) Upload(ctx context.Context, certPem string, pri
|
|||||||
}
|
}
|
||||||
|
|
||||||
listCertificatesOffset += listCertificatesLimit
|
listCertificatesOffset += listCertificatesLimit
|
||||||
<<<<<<< HEAD
|
|
||||||
if listCertificatesOffset >= 999 { // 避免无限获取
|
if listCertificatesOffset >= 999 { // 避免无限获取
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
>>>>>>> 1ff10bf989afaa505a3fc2fda668ffcded815d09
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成证书名(需符合华为云命名规则)
|
// 生成证书名(需符合华为云命名规则)
|
||||||
@ -180,10 +162,7 @@ func createClient(region, accessKeyId, secretAccessKey string) (*scm.ScmClient,
|
|||||||
func int32Ptr(i int32) *int32 {
|
func int32Ptr(i int32) *int32 {
|
||||||
return &i
|
return &i
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
func stringPtr(s string) *string {
|
func stringPtr(s string) *string {
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
>>>>>>> 1ff10bf989afaa505a3fc2fda668ffcded815d09
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user