Skip to content

Commit

Permalink
debug: create client with fresh sts token
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayushi Sharma committed Dec 10, 2024
1 parent 80ce978 commit e6dc506
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions plugins/providers/maxcompute/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (
"slices"
"strings"
"sync"
"time"

openapi "github.com/alibabacloud-go/darabonba-openapi/client"
openapiv2 "github.com/alibabacloud-go/darabonba-openapi/v2/client"
maxcompute "github.com/alibabacloud-go/maxcompute-20220104/client"
sts "github.com/alibabacloud-go/sts-20150401/client"
"github.com/aliyun/aliyun-odps-go-sdk/odps"
"github.com/aliyun/aliyun-odps-go-sdk/odps/account"
"github.com/aliyun/aliyun-odps-go-sdk/odps/common"
"github.com/aliyun/aliyun-odps-go-sdk/odps/restclient"
"github.com/aliyun/aliyun-odps-go-sdk/odps/security"
pv "github.com/goto/guardian/core/provider"
Expand Down Expand Up @@ -412,13 +414,13 @@ func (p *provider) getRestClient(pc *domain.ProviderConfig) (*maxcompute.Client,

func (p *provider) getOdpsClient(pc *domain.ProviderConfig, overrideRAMRole string) (*odps.Odps, error) {
usingRAMRole := overrideRAMRole != ""
if usingRAMRole {
if client, ok := p.odpsClients[overrideRAMRole]; ok {
return client, nil
}
} else if client, ok := p.odpsClients[pc.URN]; ok {
return client, nil
}
// if usingRAMRole {
// if client, ok := p.odpsClients[overrideRAMRole]; ok {
// return client, nil
// }
// } else if client, ok := p.odpsClients[pc.URN]; ok {
// return client, nil
// }

creds, err := p.getCreds(pc)
if err != nil {
Expand All @@ -433,6 +435,11 @@ func (p *provider) getOdpsClient(pc *domain.ProviderConfig, overrideRAMRole stri
if err != nil {
return nil, err
}

fmt.Println("gmt location ", common.GMT)
gmtTime := time.Now().In(common.GMT).Format(time.RFC1123)
fmt.Println("gmtTime: ", gmtTime)

var acc account.Account
if creds.RAMRole != "" {
acc = account.NewStsAccount(*clientConfig.AccessKeyId, *clientConfig.AccessKeySecret, *clientConfig.SecurityToken)
Expand Down

0 comments on commit e6dc506

Please sign in to comment.