Skip to content

Commit

Permalink
enhance: Support Tencent myqcloud as OSS source
Browse files Browse the repository at this point in the history
Add tencent myqcloud support with `tke` & `cvm` credential

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia committed Aug 22, 2024
1 parent 6692403 commit d1aaf91
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
9 changes: 6 additions & 3 deletions oss/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func NewMinioClient(ctx context.Context, p MinioClientParam) (*MinioClient, erro
}
endpoint := fmt.Sprintf("%s:%s", p.Addr, p.Port)

var err error
switch p.CloudProvider {
case CloudProviderAWS:
processMinioAwsOptions(p, opts)
Expand All @@ -59,15 +60,17 @@ func NewMinioClient(ctx context.Context, p MinioClientParam) (*MinioClient, erro
case CloudProviderAliyun:
processMinioAliyunOptions(p, opts)
case CloudProviderTencent:
// processMinioTencentOptions(p, opts)
// cos address issue WIP
fallthrough
err = processMinioTencentOptions(p, opts)
case CloudProviderAzure:
// TODO support azure
fallthrough
default:
return nil, errors.Newf("Cloud provider %s not supported yet", p.CloudProvider)
}
if err != nil {
return nil, err
}

fmt.Printf("Start to connect to oss endpoind: %s\n", endpoint)
client, err := minio.New(endpoint, opts)
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions oss/tencent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ type TencentCredentialProvider struct {
}

func NewTencentCredentialProvider() (minioCred.Provider, error) {
provider, err := common.DefaultTkeOIDCRoleArnProvider()
if err != nil {
return nil, errors.Wrap(err, "failed to create tencent credential provider")
var provider interface {
GetCredential() (common.CredentialIface, error)
}
var err error
provider, err = common.DefaultTkeOIDCRoleArnProvider()
if err != nil {
// try cvm role provider
provider = common.DefaultCvmRoleProvider()

Check failure on line 42 in oss/tencent.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
}
cred, err := provider.GetCredential()
if err != nil {
return nil, errors.Wrap(err, "failed to get tencent credential")
Expand Down
3 changes: 2 additions & 1 deletion states/scan_binlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (s *InstanceState) ScanBinlogCommand(ctx context.Context, p *ScanBinlogPara
minioClient, bucketName, rootPath, err := s.GetMinioClientFromCfg(ctx, p.MinioAddress)
if err != nil {
fmt.Println("Failed to create folder,", err.Error())
return err
}

fmt.Printf("=== start to execute \"%s\" task with filter expresion: \"%s\" ===\n", p.Action, p.Expr)
Expand Down Expand Up @@ -161,7 +162,7 @@ func (s *InstanceState) ScanBinlogCommand(ctx context.Context, p *ScanBinlogPara

switch strings.ToLower(p.Action) {
case "count":
fmt.Printf("Total %d entries found", count)
fmt.Printf("Total %d entries found\n", count)
case "dedup":
total := len(dedupResult)
fmt.Printf("%d duplicated entries found\n", total)
Expand Down

0 comments on commit d1aaf91

Please sign in to comment.