Bump morph dependency (#19569)

```release-note
NONE
```
This commit is contained in:
Agniva De Sarker
2022-02-16 22:30:41 +05:30
committed by GitHub
parent 678c7d3b8c
commit 9640962428
5 changed files with 28 additions and 10 deletions

2
go.mod
View File

@@ -27,7 +27,7 @@ require (
github.com/fsnotify/fsnotify v1.5.1
github.com/getsentry/sentry-go v0.12.0
github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect
github.com/go-morph/morph v0.2.3-0.20220126093237-74bffc135498
github.com/go-morph/morph v0.2.3-0.20220215130848-76392b135ee5
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

4
go.sum
View File

@@ -540,8 +540,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.2.3-0.20220126093237-74bffc135498 h1:DTTRQXU9VOPKjn8iN67Gt6htfiIGyUYoF+0ndDzDbAo=
github.com/go-morph/morph v0.2.3-0.20220126093237-74bffc135498/go.mod h1:XQh5WcM351wOV3z3zEWRM8RaJ65E2p4P7WWbmFAi8x4=
github.com/go-morph/morph v0.2.3-0.20220215130848-76392b135ee5 h1:yEZQApe5XfUURfPJW4AB1WgHbmK67d3B1ag44gmycYg=
github.com/go-morph/morph v0.2.3-0.20220215130848-76392b135ee5/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=

View File

@@ -1,6 +1,8 @@
package morph
import (
"log"
"github.com/fatih/color"
)
@@ -16,3 +18,19 @@ type Logger interface {
Printf(format string, v ...interface{})
Println(v ...interface{})
}
type colorLogger struct {
log *log.Logger
}
func newColorLogger(log *log.Logger) *colorLogger {
return &colorLogger{log: log}
}
func (l *colorLogger) Printf(format string, v ...interface{}) {
l.log.Println(InfoLoggerLight.Sprintf(format, v...))
}
func (l *colorLogger) Println(v ...interface{}) {
l.log.Println(InfoLoggerLight.Sprint(v...))
}

View File

@@ -42,7 +42,7 @@ type Config struct {
type EngineOption func(*Morph)
func WithLogger(logger *log.Logger) EngineOption {
func WithLogger(logger Logger) EngineOption {
return func(m *Morph) {
m.config.Logger = logger
}
@@ -80,7 +80,7 @@ func WithLock(key string) EngineOption {
func New(ctx context.Context, driver drivers.Driver, source sources.Source, options ...EngineOption) (*Morph, error) {
engine := &Morph{
config: &Config{
Logger: log.New(os.Stderr, "", log.LstdFlags), // add default logger
Logger: newColorLogger(log.New(os.Stderr, "", log.LstdFlags)), // add default logger
},
source: source,
driver: driver,
@@ -164,14 +164,14 @@ func (m *Morph) Apply(limit int) (int, error) {
for i := 0; i < steps; i++ {
start := time.Now()
migrationName := migrations[i].Name
m.config.Logger.Println(InfoLoggerLight.Sprint(formatProgress(fmt.Sprintf(migrationProgressStart, migrationName))))
m.config.Logger.Println(formatProgress(fmt.Sprintf(migrationProgressStart, migrationName)))
if err := m.driver.Apply(migrations[i], true); err != nil {
return applied, err
}
applied++
elapsed := time.Since(start)
m.config.Logger.Println(InfoLoggerLight.Sprint(formatProgress(fmt.Sprintf(migrationProgressFinished, migrationName, fmt.Sprintf("%.4fs", elapsed.Seconds())))))
m.config.Logger.Println(formatProgress(fmt.Sprintf(migrationProgressFinished, migrationName, fmt.Sprintf("%.4fs", elapsed.Seconds()))))
}
return applied, nil
@@ -204,7 +204,7 @@ func (m *Morph) ApplyDown(limit int) (int, error) {
for i := 0; i < steps; i++ {
start := time.Now()
migrationName := sortedMigrations[i].Name
m.config.Logger.Println(InfoLoggerLight.Sprint(formatProgress(fmt.Sprintf(migrationProgressStart, migrationName))))
m.config.Logger.Println(formatProgress(fmt.Sprintf(migrationProgressStart, migrationName)))
down := downMigrations[migrationName]
if err := m.driver.Apply(down, true); err != nil {
@@ -213,7 +213,7 @@ func (m *Morph) ApplyDown(limit int) (int, error) {
applied++
elapsed := time.Since(start)
m.config.Logger.Println(InfoLoggerLight.Sprint(formatProgress(fmt.Sprintf(migrationProgressFinished, migrationName, fmt.Sprintf("%.4fs", elapsed.Seconds())))))
m.config.Logger.Println(formatProgress(fmt.Sprintf(migrationProgressFinished, migrationName, fmt.Sprintf("%.4fs", elapsed.Seconds()))))
}
return applied, nil

2
vendor/modules.txt vendored
View File

@@ -215,7 +215,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.3-0.20220126093237-74bffc135498
# github.com/go-morph/morph v0.2.3-0.20220215130848-76392b135ee5
## explicit
github.com/go-morph/morph
github.com/go-morph/morph/drivers