From 73ac1a354dfb85a53e01b54e3d43cad39a1daf09 Mon Sep 17 00:00:00 2001 From: Ibrahim Serdar Acikgoz Date: Thu, 13 Jan 2022 12:41:56 +0300 Subject: [PATCH] Update morph dependecy to fix a data race (#19326) * Update morph dependecy to fix a data race * run go mod tidy --- go.mod | 2 +- go.sum | 8 ++------ .../go-morph/morph/drivers/mysql/mysql.go | 11 ++--------- .../go-morph/morph/drivers/mysql/utils.go | 11 +++++++++++ .../go-morph/morph/drivers/postgres/postgres.go | 13 +++---------- .../go-morph/morph/drivers/postgres/utils.go | 16 +++++++++++++++- vendor/github.com/go-morph/morph/morph.go | 8 +++----- vendor/modules.txt | 2 +- 8 files changed, 38 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index c700e4bc3c..a5407526eb 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/fsnotify/fsnotify v1.5.1 github.com/getsentry/sentry-go v0.11.0 github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect - github.com/go-morph/morph v0.2.1 + github.com/go-morph/morph v0.2.2 github.com/go-redis/redis/v8 v8.11.4 // indirect github.com/go-resty/resty/v2 v2.7.0 // indirect github.com/go-sql-driver/mysql v1.6.0 diff --git a/go.sum b/go.sum index 3e9f15f959..5a9529b0b3 100644 --- a/go.sum +++ b/go.sum @@ -527,12 +527,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/go-morph/morph v0.0.0-20211202070306-dbdc0736c17e h1:iS/jL0Xij+6O5d/VXrt+VOZfATHCTDIjBVVthVpHFY0= -github.com/go-morph/morph v0.0.0-20211202070306-dbdc0736c17e/go.mod h1:XQh5WcM351wOV3z3zEWRM8RaJ65E2p4P7WWbmFAi8x4= -github.com/go-morph/morph v0.0.0-20220110203813-7e65a95885ea h1:l2xnsVP6YW9DZet6HfUhMKtEOPyGg2QsRyDPLECnW1o= -github.com/go-morph/morph v0.0.0-20220110203813-7e65a95885ea/go.mod h1:XQh5WcM351wOV3z3zEWRM8RaJ65E2p4P7WWbmFAi8x4= -github.com/go-morph/morph v0.2.1 h1:Wo+TUt4+jCwKJh57mpuRBSMioYjA2TwjQD027hhOgro= -github.com/go-morph/morph v0.2.1/go.mod h1:XQh5WcM351wOV3z3zEWRM8RaJ65E2p4P7WWbmFAi8x4= +github.com/go-morph/morph v0.2.2 h1:f7/+VZ+1/eR+5SUoMKYo16QQISewuvS4hogX8x/uFnA= +github.com/go-morph/morph v0.2.2/go.mod h1:XQh5WcM351wOV3z3zEWRM8RaJ65E2p4P7WWbmFAi8x4= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= diff --git a/vendor/github.com/go-morph/morph/drivers/mysql/mysql.go b/vendor/github.com/go-morph/morph/drivers/mysql/mysql.go index d1d7e1deb3..860c185f32 100644 --- a/vendor/github.com/go-morph/morph/drivers/mysql/mysql.go +++ b/vendor/github.com/go-morph/morph/drivers/mysql/mysql.go @@ -16,13 +16,6 @@ import ( const driverName = "mysql" const defaultMigrationMaxSize = 10 * 1 << 20 // 10 MB -var defaultConfig = &Config{ - Config: drivers.Config{ - MigrationsTable: "db_migrations", - StatementTimeoutInSecs: 60, - MigrationMaxSize: defaultMigrationMaxSize, - }, -} // add here any custom driver configuration var configParams = []string{ @@ -44,7 +37,7 @@ type mysql struct { } func WithInstance(dbInstance *sql.DB, config *Config) (drivers.Driver, error) { - driverConfig := mergeConfigs(config, defaultConfig) + driverConfig := mergeConfigs(config, getDefaultConfig()) conn, err := dbInstance.Conn(context.Background()) if err != nil { @@ -69,7 +62,7 @@ func Open(connURL string) (drivers.Driver, error) { return nil, &drivers.AppError{Driver: driverName, OrigErr: err, Message: "failed to sanitize url from custom parameters"} } - driverConfig, err := mergeConfigWithParams(customParams, defaultConfig) + driverConfig, err := mergeConfigWithParams(customParams, getDefaultConfig()) if err != nil { return nil, &drivers.AppError{Driver: driverName, OrigErr: err, Message: "failed to merge custom params to driver config"} } diff --git a/vendor/github.com/go-morph/morph/drivers/mysql/utils.go b/vendor/github.com/go-morph/morph/drivers/mysql/utils.go index c4360cba90..d23be18008 100644 --- a/vendor/github.com/go-morph/morph/drivers/mysql/utils.go +++ b/vendor/github.com/go-morph/morph/drivers/mysql/utils.go @@ -1,6 +1,7 @@ package mysql import ( + "github.com/go-morph/morph/drivers" mysqlDriver "github.com/go-sql-driver/mysql" ) @@ -21,3 +22,13 @@ func extractDatabaseNameFromURL(conn string) (string, error) { return cfg.DBName, nil } + +func getDefaultConfig() *Config { + return &Config{ + Config: drivers.Config{ + MigrationsTable: "db_migrations", + StatementTimeoutInSecs: 60, + MigrationMaxSize: defaultMigrationMaxSize, + }, + } +} diff --git a/vendor/github.com/go-morph/morph/drivers/postgres/postgres.go b/vendor/github.com/go-morph/morph/drivers/postgres/postgres.go index 5aab6847d7..631f3e570e 100644 --- a/vendor/github.com/go-morph/morph/drivers/postgres/postgres.go +++ b/vendor/github.com/go-morph/morph/drivers/postgres/postgres.go @@ -14,14 +14,7 @@ import ( ) var ( - driverName = "postgres" - defaultConfig = &Config{ - Config: drivers.Config{ - MigrationsTable: "db_migrations", - StatementTimeoutInSecs: 60, - MigrationMaxSize: defaultMigrationMaxSize, - }, - } + driverName = "postgres" defaultMigrationMaxSize = 10 * 1 << 20 // 10 MB configParams = []string{ "x-migration-max-size", @@ -44,7 +37,7 @@ type postgres struct { } func WithInstance(dbInstance *sql.DB, config *Config) (drivers.Driver, error) { - driverConfig := mergeConfigs(config, defaultConfig) + driverConfig := mergeConfigs(config, getDefaultConfig()) conn, err := dbInstance.Conn(context.Background()) if err != nil { @@ -77,7 +70,7 @@ func Open(connURL string) (drivers.Driver, error) { return nil, &drivers.AppError{Driver: driverName, OrigErr: err, Message: "failed to sanitize url from custom parameters"} } - driverConfig, err := mergeConfigWithParams(customParams, defaultConfig) + driverConfig, err := mergeConfigWithParams(customParams, getDefaultConfig()) if err != nil { return nil, &drivers.AppError{Driver: driverName, OrigErr: err, Message: "failed to merge custom params to driver config"} } diff --git a/vendor/github.com/go-morph/morph/drivers/postgres/utils.go b/vendor/github.com/go-morph/morph/drivers/postgres/utils.go index f4f18fe519..7a686e9df4 100644 --- a/vendor/github.com/go-morph/morph/drivers/postgres/utils.go +++ b/vendor/github.com/go-morph/morph/drivers/postgres/utils.go @@ -1,6 +1,10 @@ package postgres -import "net/url" +import ( + "net/url" + + "github.com/go-morph/morph/drivers" +) func extractDatabaseNameFromURL(URL string) (string, error) { uri, err := url.Parse(URL) @@ -10,3 +14,13 @@ func extractDatabaseNameFromURL(URL string) (string, error) { return uri.Path[1:], nil } + +func getDefaultConfig() *Config { + return &Config{ + Config: drivers.Config{ + MigrationsTable: "db_migrations", + StatementTimeoutInSecs: 60, + MigrationMaxSize: defaultMigrationMaxSize, + }, + } +} diff --git a/vendor/github.com/go-morph/morph/morph.go b/vendor/github.com/go-morph/morph/morph.go index a8837a11ee..39ccb83fcc 100644 --- a/vendor/github.com/go-morph/morph/morph.go +++ b/vendor/github.com/go-morph/morph/morph.go @@ -42,10 +42,6 @@ type Config struct { type EngineOption func(*Morph) -var defaultConfig = &Config{ - Logger: log.New(os.Stderr, "", log.LstdFlags), // add default logger -} - func WithLogger(logger *log.Logger) EngineOption { return func(m *Morph) { m.config.Logger = logger @@ -82,7 +78,9 @@ func WithLock(key string) EngineOption { // New creates a new instance of the migrations engine from an existing db instance and a migrations source. func New(ctx context.Context, driver drivers.Driver, source sources.Source, options ...EngineOption) (*Morph, error) { engine := &Morph{ - config: defaultConfig, + config: &Config{ + Logger: log.New(os.Stderr, "", log.LstdFlags), // add default logger + }, source: source, driver: driver, } diff --git a/vendor/modules.txt b/vendor/modules.txt index f28999d747..a209388ced 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -214,7 +214,7 @@ github.com/gigawattio/window # github.com/go-asn1-ber/asn1-ber v1.5.3 ## explicit github.com/go-asn1-ber/asn1-ber -# github.com/go-morph/morph v0.2.1 +# github.com/go-morph/morph v0.2.2 ## explicit github.com/go-morph/morph github.com/go-morph/morph/drivers