(ctx context.Context, connCfg db.ConnectionConfig)
| 252 | } |
| 253 | |
| 254 | func getCloudSQLConnection(ctx context.Context, connCfg db.ConnectionConfig) (string, error) { |
| 255 | d, err := util.GetGCPConnectionConfig(ctx, connCfg) |
| 256 | if err != nil { |
| 257 | return "", errors.Wrap(err, "load gcp config failed") |
| 258 | } |
| 259 | |
| 260 | mysql.RegisterDialContext("cloudsqlconn", |
| 261 | func(ctx context.Context, _ string) (net.Conn, error) { |
| 262 | return d.Dial(ctx, connCfg.DataSource.Host) |
| 263 | }) |
| 264 | |
| 265 | return fmt.Sprintf("%s:empty@cloudsqlconn(localhost:3306)/%s?parseTime=true&multiStatements=true&maxAllowedPacket=0", |
| 266 | connCfg.DataSource.Username, connCfg.ConnectionContext.DatabaseName), nil |
| 267 | } |
| 268 | |
| 269 | // Close closes the driver. |
| 270 | func (d *Driver) Close(context.Context) error { |
no test coverage detected