Skip to content

Commit

Permalink
Exported variablee for MySQL as well
Browse files Browse the repository at this point in the history
  • Loading branch information
shinji62 committed Aug 14, 2024
1 parent 4b26678 commit d862d0b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/database/mysql/connection_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type mySQLConnectionProducer struct {
Password string `json:"password" mapstructure:"password" structs:"password"`
AuthType string `json:"auth_type" mapstructure:"auth_type" structs:"auth_type"`
ServiceAccountJSON string `json:"service_account_json" mapstructure:"service_account_json" structs:"service_account_json"`
UsePrivateIP bool `json:"use_private_ip" mapstructure:"use_private_ip" structs:"use_private_ip"`
UsePSC bool `json:"use_psc" mapstructure:"use_psc" structs:"use_psc"`

TLSCertificateKeyData []byte `json:"tls_certificate_key" mapstructure:"tls_certificate_key" structs:"-"`
TLSCAData []byte `json:"tls_ca" mapstructure:"tls_ca" structs:"-"`
Expand Down Expand Up @@ -140,7 +142,7 @@ func (c *mySQLConnectionProducer) Init(ctx context.Context, conf map[string]inte
// however, the driver might store a credentials file, in which case the state stored by the driver is in
// fact critical to the proper function of the connection. So it needs to be registered here inside the
// ConnectionProducer init.
dialerCleanup, err := registerDriverMySQL(c.cloudDriverName, c.ServiceAccountJSON)
dialerCleanup, err := registerDriverMySQL(c.cloudDriverName, c.ServiceAccountJSON, c.UsePrivateIP, c.UsePSC)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -321,8 +323,8 @@ func (c *mySQLConnectionProducer) rewriteProtocolForGCP(inDSN string) (string, e
return config.FormatDSN(), nil
}

func registerDriverMySQL(driverName, credentials string) (cleanup func() error, err error) {
opts, err := connutil.GetCloudSQLAuthOptions(credentials, false)
func registerDriverMySQL(driverName, credentials string, usePrivateIP bool, usePSC bool) (cleanup func() error, err error) {
opts, err := connutil.GetCloudSQLAuthOptions(credentials, usePrivateIP, usePSC)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit d862d0b

Please sign in to comment.