@@ -492,17 +492,15 @@ func (s *Agent) DSN(service *Service, dsnParams DSNParams, tdp *DelimiterPair) s
492
492
}
493
493
q .Set ("sslmode" , sslmode )
494
494
495
- if s .PostgreSQLOptions != nil {
496
- if files := s .Files (); len (files ) != 0 {
497
- for key := range files {
498
- switch key {
499
- case caFilePlaceholder :
500
- q .Add ("sslrootcert" , tdp .Left + ".TextFiles." + caFilePlaceholder + tdp .Right )
501
- case certificateFilePlaceholder :
502
- q .Add ("sslcert" , tdp .Left + ".TextFiles." + certificateFilePlaceholder + tdp .Right )
503
- case certificateKeyFilePlaceholder :
504
- q .Add ("sslkey" , tdp .Left + ".TextFiles." + certificateKeyFilePlaceholder + tdp .Right )
505
- }
495
+ if files := s .Files (); len (files ) != 0 {
496
+ for key := range files {
497
+ switch key {
498
+ case caFilePlaceholder :
499
+ q .Add ("sslrootcert" , tdp .Left + ".TextFiles." + caFilePlaceholder + tdp .Right )
500
+ case certificateFilePlaceholder :
501
+ q .Add ("sslcert" , tdp .Left + ".TextFiles." + certificateFilePlaceholder + tdp .Right )
502
+ case certificateKeyFilePlaceholder :
503
+ q .Add ("sslkey" , tdp .Left + ".TextFiles." + certificateKeyFilePlaceholder + tdp .Right )
506
504
}
507
505
}
508
506
}
@@ -609,30 +607,47 @@ func (s Agent) Files() map[string]string {
609
607
switch s .AgentType {
610
608
case MySQLdExporterType , QANMySQLPerfSchemaAgentType , QANMySQLSlowlogAgentType :
611
609
if s .MySQLOptions != nil {
612
- return map [string ]string {
613
- "tlsCa" : s .MySQLOptions .TLSCa ,
614
- "tlsCert" : s .MySQLOptions .TLSCert ,
615
- "tlsKey" : s .MySQLOptions .TLSKey ,
610
+ files := make (map [string ]string )
611
+ if s .MySQLOptions .TLSCa != "" {
612
+ files ["tlsCa" ] = s .MySQLOptions .TLSCa
613
+ }
614
+ if s .MySQLOptions .TLSCert != "" {
615
+ files ["tlsCert" ] = s .MySQLOptions .TLSCert
616
+ }
617
+ if s .MySQLOptions .TLSKey != "" {
618
+ files ["tlsKey" ] = s .MySQLOptions .TLSKey
616
619
}
620
+ return files
617
621
}
618
622
return nil
619
623
case ProxySQLExporterType :
620
624
return nil
621
625
case QANMongoDBProfilerAgentType , MongoDBExporterType :
622
626
if s .MongoDBOptions != nil {
623
- return map [string ]string {
624
- caFilePlaceholder : s .MongoDBOptions .TLSCa ,
625
- certificateKeyFilePlaceholder : s .MongoDBOptions .TLSCertificateKey ,
627
+ files := make ( map [string ]string )
628
+ if s .MongoDBOptions .TLSCa != "" {
629
+ files [ caFilePlaceholder ] = s .MongoDBOptions .TLSCa
626
630
}
631
+ if s .MongoDBOptions .TLSCertificateKey != "" {
632
+ files [certificateKeyFilePlaceholder ] = s .MongoDBOptions .TLSCertificateKey
633
+ }
634
+ return files
627
635
}
628
636
return nil
629
637
case PostgresExporterType , QANPostgreSQLPgStatementsAgentType , QANPostgreSQLPgStatMonitorAgentType :
630
638
if s .PostgreSQLOptions != nil {
631
- return map [string ]string {
632
- caFilePlaceholder : s .PostgreSQLOptions .SSLCa ,
633
- certificateFilePlaceholder : s .PostgreSQLOptions .SSLCert ,
634
- certificateKeyFilePlaceholder : s .PostgreSQLOptions .SSLKey ,
639
+ files := make (map [string ]string )
640
+
641
+ if s .PostgreSQLOptions .SSLCa != "" {
642
+ files [caFilePlaceholder ] = s .PostgreSQLOptions .SSLCa
643
+ }
644
+ if s .PostgreSQLOptions .SSLCert != "" {
645
+ files [certificateFilePlaceholder ] = s .PostgreSQLOptions .SSLCert
646
+ }
647
+ if s .PostgreSQLOptions .SSLKey != "" {
648
+ files [certificateKeyFilePlaceholder ] = s .PostgreSQLOptions .SSLKey
635
649
}
650
+ return files
636
651
}
637
652
return nil
638
653
default :
0 commit comments