@@ -245,15 +245,15 @@ func (c *external) Create(ctx context.Context, mg resource.Managed) (managed.Ext
245
245
ro := resourceOptionsToClauses (cr .Spec .ForProvider .ResourceOptions )
246
246
binlog := cr .Spec .ForProvider .BinLog
247
247
248
- var authplugin string
248
+ var authplugin string
249
+
249
250
if cr .Spec .ForProvider .AuthPlugin != "" {
250
251
authplugin = cr .Spec .ForProvider .AuthPlugin
251
- } else {
252
- authplugin = "mysql_native_password"
253
252
}
254
253
var pw string
255
254
256
- if authplugin == "mysql_native_password" {
255
+ switch authplugin {
256
+ case "" :
257
257
var err error
258
258
pw , _ , err = c .getPassword (ctx , cr )
259
259
if err != nil {
@@ -266,11 +266,11 @@ func (c *external) Create(ctx context.Context, mg resource.Managed) (managed.Ext
266
266
return managed.ExternalCreation {}, err
267
267
}
268
268
}
269
- auth = fmt .Sprintf ("%s BY %s" , authplugin , mysql .QuoteValue (pw ))
270
- } else if authplugin == "AWSAuthenticationPlugin" {
271
- auth = fmt .Sprintf ("%s AS %s" , authplugin , mysql .QuoteValue ("RDS" ))
272
- } else {
273
- return managed.ExternalCreation {}, errors .New (errAuthPluginNotSupported )
269
+ auth = fmt .Sprintf ("BY %s" , mysql .QuoteValue (pw ))
270
+ case "AWSAuthenticationPlugin" :
271
+ auth = fmt .Sprintf ("WITH %s AS %s" , authplugin , mysql .QuoteValue ("RDS" ))
272
+ default :
273
+ return managed.ExternalCreation {}, errors .New (errAuthPluginNotSupported )
274
274
}
275
275
276
276
if err := c .executeCreateUserQuery (ctx , username , host , ro , auth , binlog ); err != nil {
@@ -293,13 +293,12 @@ func (c *external) executeCreateUserQuery(ctx context.Context, username string,
293
293
}
294
294
295
295
query := fmt .Sprintf (
296
- "CREATE USER %s@%s IDENTIFIED WITH %s%s" ,
296
+ "CREATE USER %s@%s IDENTIFIED %s%s" ,
297
297
mysql .QuoteValue (username ),
298
298
mysql .QuoteValue (host ),
299
299
auth ,
300
300
resourceOptions ,
301
301
)
302
- fmt .Println (query )
303
302
304
303
if err := mysql .ExecWithBinlogAndFlush (ctx , c .db , mysql.ExecQuery {Query : query , ErrorValue : errCreateUser }, mysql.ExecOptions {Binlog : binlog }); err != nil {
305
304
return err
0 commit comments