mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
cloudprovider: use ProviderConfig
This commit is contained in:
@@ -148,6 +148,8 @@ type SCloudaccount struct {
|
||||
IsPublic bool `default:"false" nullable:"false"`
|
||||
// add share_mode field to indicate the share range of this account
|
||||
ShareMode string `width:"32" charset:"ascii" nullable:"true" list:"domain"`
|
||||
|
||||
ProxySettingId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional" default:"default"`
|
||||
}
|
||||
|
||||
func (self *SCloudaccountManager) AllowListItems(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
@@ -362,7 +364,12 @@ func (manager *SCloudaccountManager) ValidateCreateData(ctx context.Context, use
|
||||
return input, httperrors.NewConflictError("The account has been registered")
|
||||
}
|
||||
|
||||
accountId, err := cloudprovider.IsValidCloudAccount(input.AccessUrl, input.Account, input.Secret, input.Provider)
|
||||
accountId, err := cloudprovider.IsValidCloudAccount(cloudprovider.ProviderConfig{
|
||||
Vendor: input.Provider,
|
||||
URL: input.AccessUrl,
|
||||
Account: input.Account,
|
||||
Secret: input.Secret,
|
||||
})
|
||||
if err != nil {
|
||||
if err == cloudprovider.ErrNoSuchProvder {
|
||||
return input, httperrors.NewResourceNotFoundError("no such provider %s", input.Provider)
|
||||
@@ -516,7 +523,12 @@ func (self *SCloudaccount) PerformUpdateCredential(ctx context.Context, userCred
|
||||
|
||||
originSecret, _ := self.getPassword()
|
||||
|
||||
accountId, err := cloudprovider.IsValidCloudAccount(self.AccessUrl, account.Account, account.Secret, self.Provider)
|
||||
accountId, err := cloudprovider.IsValidCloudAccount(cloudprovider.ProviderConfig{
|
||||
Vendor: self.Provider,
|
||||
URL: self.AccessUrl,
|
||||
Account: account.Account,
|
||||
Secret: account.Secret,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, httperrors.NewInputParameterError("invalid cloud account info error: %s", err.Error())
|
||||
}
|
||||
@@ -673,7 +685,14 @@ func (self *SCloudaccount) getProviderInternal() (cloudprovider.ICloudProvider,
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Invalid password %s", err)
|
||||
}
|
||||
return cloudprovider.GetProvider(self.Id, self.Name, self.AccessUrl, self.Account, secret, self.Provider)
|
||||
return cloudprovider.GetProvider(cloudprovider.ProviderConfig{
|
||||
Id: self.Id,
|
||||
Name: self.Name,
|
||||
Vendor: self.Provider,
|
||||
URL: self.AccessUrl,
|
||||
Account: self.Account,
|
||||
Secret: secret,
|
||||
})
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) GetSubAccounts() ([]cloudprovider.SSubAccount, error) {
|
||||
|
||||
@@ -737,7 +737,14 @@ func (self *SCloudprovider) GetProvider() (cloudprovider.ICloudProvider, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cloudprovider.GetProvider(self.Id, self.Name, accessUrl, self.Account, passwd, self.Provider)
|
||||
return cloudprovider.GetProvider(cloudprovider.ProviderConfig{
|
||||
Id: self.Id,
|
||||
Name: self.Name,
|
||||
Vendor: self.Provider,
|
||||
URL: accessUrl,
|
||||
Account: self.Account,
|
||||
Secret: passwd,
|
||||
})
|
||||
}
|
||||
|
||||
func (self *SCloudprovider) savePassword(secret string) error {
|
||||
|
||||
Reference in New Issue
Block a user