Skip to content

Commit

Permalink
fix(oss): fixed ram role generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayushi Sharma committed Mar 7, 2025
1 parent 8762570 commit 14b1118
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/providers/oss/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,13 @@ func (p *provider) getCreds(pc *domain.ProviderConfig) (*Credentials, error) {
return creds, nil
}

func (p *provider) getOSSClient(pc *domain.ProviderConfig, ramRole string) (*oss.Client, error) {
func (p *provider) getOSSClient(pc *domain.ProviderConfig, overrideRamRole string) (*oss.Client, error) {
creds, err := p.getCreds(pc)
if err != nil {
return nil, err
}

ramRole := overrideRamRole
if ramRole == "" {
ramRole = creds.RAMRole
}
Expand All @@ -393,6 +394,7 @@ func (p *provider) getOSSClient(pc *domain.ProviderConfig, ramRole string) (*oss
// Check cache for existing client
if cachedClient, exists := p.ossClients[cachedClientKey]; exists {
if cachedClient.authConfig.IsConfigValid() {
fmt.Println("Using cached OSS client")
return cachedClient.client, nil
}
p.mu.Lock()
Expand All @@ -410,7 +412,7 @@ func (p *provider) getOSSClient(pc *domain.ProviderConfig, ramRole string) (*oss
p.mu.Lock()
defer p.mu.Unlock()
p.ossClients[cachedClientKey] = OSSClient{client: client, authConfig: authConfig}

fmt.Println("Created new OSS client")
return client, nil
}

Expand Down Expand Up @@ -443,7 +445,7 @@ func getRAMRole(g domain.Grant) (string, error) {
if err != nil {
return "", err
}
return fmt.Sprintf("acs:ram::%s:role/guardian.bot", resourceAccountID), nil
return fmt.Sprintf("acs:ram::%s:role/guardian-bot", resourceAccountID), nil
}

func getAccountIDFromResource(resource *domain.Resource) (string, error) {
Expand Down

0 comments on commit 14b1118

Please sign in to comment.