@@ -73,9 +73,9 @@ func (m *AtlasRepository) EnableExtension(ctx context.Context, name string) erro
7373}
7474
7575func (m * AtlasRepository ) doesUserExist (ctx context.Context , database string , username string ) (bool , error ) {
76- user , _ , err := m .atlas .DatabaseUsers .Get (ctx , database , m .groupId , username )
77- if user = = nil {
78- return false , err
76+ _ , _ , err := m .atlas .DatabaseUsers .Get (ctx , database , m .groupId , username )
77+ if err ! = nil {
78+ return false , nil
7979 }
8080
8181 return true , err
@@ -93,13 +93,13 @@ func (m *AtlasRepository) getRoles(database string, roles []infrav1beta1.Role) [
9393 rs := make ([]mongodbatlas.Role , 0 )
9494 for _ , r := range roles {
9595 db := r .Db
96- if db == nil {
97- db = & database
96+ if db == "" {
97+ db = database
9898 }
9999
100100 rs = append (rs , mongodbatlas.Role {
101101 RoleName : r .Name ,
102- DatabaseName : * db ,
102+ DatabaseName : db ,
103103 })
104104 }
105105
@@ -108,9 +108,10 @@ func (m *AtlasRepository) getRoles(database string, roles []infrav1beta1.Role) [
108108
109109func (m * AtlasRepository ) createUser (ctx context.Context , database string , username string , password string , roles []infrav1beta1.Role ) error {
110110 user := & mongodbatlas.DatabaseUser {
111- Username : username ,
112- Password : password ,
113- Roles : m .getRoles (database , roles ),
111+ Username : username ,
112+ Password : password ,
113+ DatabaseName : database ,
114+ Roles : m .getRoles (database , roles ),
114115 }
115116
116117 _ , _ , err := m .atlas .DatabaseUsers .Create (ctx , m .groupId , user )
0 commit comments