fix(region): huawei region id with project name

This commit is contained in:
Qu Xuan
2021-09-10 15:02:35 +08:00
parent 7fa1c7ef49
commit 121d024ef4
2 changed files with 10 additions and 7 deletions
+8 -4
View File
@@ -206,17 +206,21 @@ func (self *SHuaweiClient) fetchRegions() error {
regionId := strings.Split(project.Name, "_")[0]
for _, region := range self.regions {
if region.ID == regionId {
if region.ID == regionId || project.Name == region.ID {
filtedRegions = append(filtedRegions, region)
}
}
if regionId == project.Name {
self.isMainProject = true
if project.Name == region.ID {
self.isMainProject = true
}
}
} else {
filtedRegions = self.regions
}
if len(filtedRegions) == 0 {
return errors.Wrapf(cloudprovider.ErrNotFound, "empty regions")
}
self.iregions = make([]cloudprovider.ICloudRegion, len(filtedRegions))
for i := 0; i < len(filtedRegions); i += 1 {
filtedRegions[i].client = self
+2 -3
View File
@@ -74,9 +74,8 @@ func (self *SRegion) getECSClient() (*client.Client, error) {
}
regionId := strings.Split(project.Name, "_")[0]
if regionId != self.ID {
// log.Debugf("project %s not in region %s", self.client.projectId, self.ID)
return nil, errors.Error("region and project mismatch")
if regionId != self.ID && project.Name != self.ID {
return nil, errors.Errorf("region %s and project %s mismatch", self.ID, project.Name)
}
}