mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
feat(region): allow to update account with provider vmware
This commit is contained in:
@@ -225,6 +225,8 @@ type ICloudProviderFactory interface {
|
||||
GetTTLRange(zoneType TDnsZoneType, productType TDnsProductType) TTlRange
|
||||
|
||||
IsSupportSAMLAuth() bool
|
||||
|
||||
GetAccountIdEqualizer() func(origin, now string) bool
|
||||
}
|
||||
|
||||
type ICloudProvider interface {
|
||||
@@ -711,6 +713,15 @@ func (factory *baseProviderFactory) GetTTLRange(zoneType TDnsZoneType, productTy
|
||||
return TTlRange{}
|
||||
}
|
||||
|
||||
func (factory *baseProviderFactory) GetAccountIdEqualizer() func(origin, now string) bool {
|
||||
return func(origin, now string) bool {
|
||||
if len(now) > 0 && now != origin {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
type SDnsCapability struct {
|
||||
ZoneTypes []TDnsZoneType
|
||||
DnsTypes map[TDnsZoneType][]TDnsType
|
||||
|
||||
@@ -713,8 +713,10 @@ func (self *SCloudaccount) PerformUpdateCredential(ctx context.Context, userCred
|
||||
if err != nil {
|
||||
return nil, httperrors.NewInputParameterError("invalid cloud account info error: %s", err.Error())
|
||||
}
|
||||
|
||||
isEqual := providerDriver.GetAccountIdEqualizer()
|
||||
// for backward compatibility
|
||||
if len(self.AccountId) > 0 && accountId != self.AccountId {
|
||||
if !isEqual(self.AccountId, accountId) {
|
||||
return nil, httperrors.NewConflictError("inconsistent account_id, previous '%s' and now '%s'", self.AccountId, accountId)
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,24 @@ func (self *SESXiProviderFactory) GetClientRC(info cloudprovider.SProviderInfo)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (self *SESXiProviderFactory) GetAccountIdEqualizer() func(origin, now string) bool {
|
||||
return func(origin, now string) bool {
|
||||
if len(now) == 0 {
|
||||
return true
|
||||
}
|
||||
originUserName, nowUserName := origin, now
|
||||
index1 := strings.Index(origin, "@")
|
||||
index2 := strings.Index(now, "@")
|
||||
if index1 != -1 {
|
||||
originUserName = originUserName[:index1]
|
||||
}
|
||||
if index2 != -1 {
|
||||
nowUserName = nowUserName[:index2]
|
||||
}
|
||||
return originUserName == nowUserName
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
factory := SESXiProviderFactory{}
|
||||
cloudprovider.RegisterFactory(&factory)
|
||||
|
||||
Reference in New Issue
Block a user