Skip to content

Commit

Permalink
fix: add a user check before creating (#7632)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuriwuyun authored Jun 26, 2024
1 parent ab3d419 commit 1c80b9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions controllers/apps/component_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ var mockLorryClient = func(mock func(*lorry.MockClientMockRecorder)) {
var mockLorryClientDefault = func() {
mockLorryClient(func(recorder *lorry.MockClientMockRecorder) {
recorder.CreateUser(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
recorder.DescribeUser(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
recorder.GrantUserRole(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
})
}
Expand Down
4 changes: 4 additions & 0 deletions controllers/apps/transformer_component_account_provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ func (t *componentAccountProvisionTransformer) provisionAccount(transCtx *compon
return nil
}

userInfo, err := lorryCli.DescribeUser(transCtx, string(username))
if err == nil && len(userInfo) != 0 {
return nil
}
// TODO: re-define the role
return lorryCli.CreateUser(transCtx.Context, string(username), string(password), string(lorryModel.SuperUserRole))
}
Expand Down

0 comments on commit 1c80b9c

Please sign in to comment.