Skip to content

Commit

Permalink
Merge pull request #17944 from gouqi11/acceptCreateProjectForProvider
Browse files Browse the repository at this point in the history
fix(region): project mapping support inputProject
  • Loading branch information
zexi authored Sep 6, 2023
2 parents 6170fae + f0a4d33 commit 147e872
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/compute/models/cloudaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3085,22 +3085,14 @@ func (account *SCloudaccount) PerformProjectMapping(ctx context.Context, userCre
if len(input.ProjectId) == 0 && !input.AutoCreateProjectForProvider {
return nil, errors.Wrap(httperrors.ErrInputParameter, "empty project_id")
}
if input.AutoCreateProject {
if input.AutoCreateProject || input.AutoCreateProjectForProvider {
t, err := db.TenantCacheManager.FetchTenantByIdOrNameInDomain(ctx, input.ProjectId, account.DomainId)
if err != nil {
return nil, errors.Wrap(err, "FetchTenantByIdOrNameInDomain")
}
input.ProjectId = t.Id
}

if input.AutoCreateProjectForProvider {
t, err := db.TenantCacheManager.FetchTenantByIdOrNameInDomain(ctx, "system", account.DomainId)
if err != nil {
return nil, errors.Wrap(err, "FetchTenantByIdOrNameInDomain")
}
input.ProjectId = t.Id
}

_, err := db.Update(account, func() error {
account.ProjectId = input.ProjectId
account.AutoCreateProject = input.AutoCreateProject
Expand Down

0 comments on commit 147e872

Please sign in to comment.