Merge pull request #14074 from ioito/hotfix/qx-apsara-credential-update

fix(region): apsara credential update
This commit is contained in:
Zexi Li
2022-04-19 16:21:24 +08:00
committed by GitHub
3 changed files with 26 additions and 5 deletions
+1
View File
@@ -79,6 +79,7 @@ func init() {
cmd.PerformWithKeyword("update-credential-aws", "update-credential", &options.SAWSCloudAccountUpdateCredentialOptions{})
cmd.PerformWithKeyword("update-credential-openstack", "update-credential", &options.SOpenStackCloudAccountUpdateCredentialOptions{})
cmd.PerformWithKeyword("update-credential-huawei", "update-credential", &options.SHuaweiCloudAccountUpdateCredentialOptions{})
cmd.PerformWithKeyword("update-credential-apsara", "update-credential", &options.SApsaraCloudAccountUpdateCredentialOptions{})
cmd.PerformWithKeyword("update-credential-hcso", "update-credential", &options.SHCSOAccountUpdateCredentialOptions{})
cmd.PerformWithKeyword("update-credential-ucloud", "update-credential", &options.SUcloudCloudAccountUpdateCredentialOptions{})
cmd.PerformWithKeyword("update-credential-zstack", "update-credential", &options.SZStackCloudAccountUpdateCredentialOptions{})
+16 -5
View File
@@ -680,12 +680,17 @@ func (self *SCloudaccount) PerformTestConnectivity(ctx context.Context, userCred
return nil, err
}
defaultRegion, _ := jsonutils.Marshal(self.Options).GetString("default_region")
_, _, err = cloudprovider.IsValidCloudAccount(cloudprovider.ProviderConfig{
URL: self.AccessUrl,
Vendor: self.Provider,
Account: account.Account,
Secret: account.Secret,
DefaultRegion: defaultRegion,
ReadOnly: self.ReadOnly,
ProxyFunc: self.proxyFunc(),
})
if err != nil {
@@ -755,12 +760,18 @@ func (self *SCloudaccount) PerformUpdateCredential(ctx context.Context, userCred
}
}
defaultRegion, _ := jsonutils.Marshal(self.Options).GetString("default_region")
_, accountId, err := cloudprovider.IsValidCloudAccount(cloudprovider.ProviderConfig{
Vendor: self.Provider,
URL: self.AccessUrl,
Account: account.Account,
Secret: account.Secret,
Options: self.Options,
Name: self.Name,
Vendor: self.Provider,
URL: self.AccessUrl,
Account: account.Account,
Secret: account.Secret,
Options: self.Options,
DefaultRegion: defaultRegion,
ReadOnly: self.ReadOnly,
ProxyFunc: self.proxyFunc(),
})
if err != nil {
+9
View File
@@ -432,6 +432,15 @@ func (opts *SAliyunCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSON
return jsonutils.Marshal(opts), nil
}
type SApsaraCloudAccountUpdateCredentialOptions struct {
SCloudAccountIdOptions
SAccessKeyCredential
}
func (opts *SApsaraCloudAccountUpdateCredentialOptions) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(opts), nil
}
type SAzureCloudAccountUpdateCredentialOptions struct {
SCloudAccountIdOptions
SAzureCredential