Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
remove tls override from mysql dsn normalizing (pressly#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Feb 22, 2023
1 parent 2a6d7c0 commit 60610d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ Options:
-allow-missing
applies missing (out-of-order) migrations
-certfile string
file path to root CA's certificates in pem format (only support on mysql)
file path to root CA's certificates in pem format (only supported on mysql)
-dir string
directory with migration files (default ".")
-h print help
-no-versioning
apply migration commands with no versioning, in file order, from directory pointed to
-s use sequential numbering for new migrations
-ssl-cert string
file path to SSL certificates in pem format (only support on mysql)
file path to SSL certificates in pem format (only supported on mysql)
-ssl-key string
file path to SSL key in pem format (only support on mysql)
file path to SSL key in pem format (only supported on mysql)
-table string
migrations table name (default "goose_db_version")
-v enable verbose mode
Expand Down
8 changes: 1 addition & 7 deletions cmd/goose/driver_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"log"
"os"
"regexp"

"github.com/go-sql-driver/mysql"
_ "github.com/ziutek/mymysql/godrv"
Expand All @@ -21,7 +20,7 @@ import (
// type.
func normalizeDBString(driver string, str string, certfile string, sslcert string, sslkey string) string {
if driver == "mysql" {
var isTLS = certfile != ""
isTLS := certfile != ""
if isTLS {
if err := registerTLSConfig(certfile, sslcert, sslkey); err != nil {
log.Fatalf("goose run: %v", err)
Expand All @@ -38,12 +37,7 @@ func normalizeDBString(driver string, str string, certfile string, sslcert strin

const tlsConfigKey = "custom"

var tlsReg = regexp.MustCompile(`(\?|&)tls=[^&]*(?:&|$)`)

func normalizeMySQLDSN(dsn string, tls bool) (string, error) {
// If we are sharing a DSN in a different environment, it may contain a TLS
// setting key with a value name that is not "custom," so clear it.
dsn = tlsReg.ReplaceAllString(dsn, `$1`)
config, err := mysql.ParseDSN(dsn)
if err != nil {
return "", err
Expand Down

0 comments on commit 60610d3

Please sign in to comment.