@@ -243,14 +243,16 @@ func (s *SQLSyncer) prepareQueryInputs(
243243 if err != nil {
244244 return nil , nil , err
245245 }
246- queryInputs ["password" ] = password
247- credentials ["password" ] = password
248- // Create plaintext data for return
249- passwordData := & v2.PlaintextData {
250- Name : "password" ,
251- Bytes : []byte (password ),
246+ if password != nil {
247+ queryInputs ["password" ] = password
248+ credentials ["password" ] = password
249+ // Create plaintext data for return
250+ passwordData := & v2.PlaintextData {
251+ Name : "password" ,
252+ Bytes : []byte (* password ),
253+ }
254+ plaintextDataList = append (plaintextDataList , passwordData )
252255 }
253- plaintextDataList = append (plaintextDataList , passwordData )
254256 }
255257
256258 // 3. Add namespaced access for advanced CEL expressions
@@ -269,26 +271,27 @@ func (s *SQLSyncer) prepareQueryInputs(
269271 return queryInputs , plaintextDataList , nil
270272}
271273
272- func generatePassword (ctx context.Context , credentialOptions * v2.LocalCredentialOptions ) (string , error ) {
274+ func generatePassword (ctx context.Context , credentialOptions * v2.LocalCredentialOptions ) (* string , error ) {
273275 if credentialOptions == nil {
274- return "" , errors .New ("credential options are required" )
276+ return nil , errors .New ("credential options are required" )
275277 }
276278
277279 var password string
278280 var err error
279281 switch credentialOptions .Options .(type ) {
280282 case * v2.LocalCredentialOptions_NoPassword_ :
283+ return nil , nil
281284 case * v2.LocalCredentialOptions_RandomPassword_ , * v2.LocalCredentialOptions_PlaintextPassword_ :
282285 password , err = crypto .GeneratePassword (ctx , credentialOptions )
283286 if err != nil {
284- return "" , fmt .Errorf ("failed to generate password: %w" , err )
287+ return nil , fmt .Errorf ("failed to generate password: %w" , err )
285288 }
286289
287290 default :
288- return "" , fmt .Errorf ("unsupported credential options: %v" , credentialOptions )
291+ return nil , fmt .Errorf ("unsupported credential options: %v" , credentialOptions )
289292 }
290293
291- return password , nil
294+ return & password , nil
292295}
293296
294297// validateAccountInfo validates that the required account information is provided.
0 commit comments