mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
修正:aliyun在成功连接后,会缓存成功状态,导致更新错误账号信息后还是显示成功连接
This commit is contained in:
@@ -59,6 +59,16 @@ func jsonRequest(client *sdk.Client, apiName string, params map[string]string) (
|
||||
return body, nil
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) UpdateAccount(accessKey, secret string) error {
|
||||
if self.accessKey != accessKey || self.secret != secret {
|
||||
self.accessKey = accessKey
|
||||
self.secret = secret
|
||||
return self.fetchRegions()
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SAliyunClient) getDefaultClient() (*sdk.Client, error) {
|
||||
return sdk.NewClientWithAccessKey(ALIYUN_DEFAULT_REGION, self.accessKey, self.secret)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,12 @@ func (self *SAliyunProviderFactory) GetId() string {
|
||||
func (self *SAliyunProviderFactory) GetProvider(providerId, providerName, url, account, secret string) (cloudprovider.ICloudProvider, error) {
|
||||
provider, ok := self.providerTable[providerId]
|
||||
if ok {
|
||||
return provider, nil
|
||||
err := provider.client.UpdateAccount(account, secret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return provider, nil
|
||||
}
|
||||
}
|
||||
client, err := aliyun.NewAliyunClient(providerId, providerName, account, secret)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user