From bf5e0c93ebb323f8eb1270f0d98517f145a539a5 Mon Sep 17 00:00:00 2001 From: zepatrik Date: Tue, 8 Oct 2024 10:32:02 +0200 Subject: [PATCH] fix: use non-problematic filesystem merge lib --- cmd/migrate/sql.go | 1 - driver/registry.go | 8 -------- driver/registry_default.go | 2 +- go.mod | 2 +- go.sum | 1 - internal/client-go/go.sum | 1 + persistence/sql/persister.go | 27 ++++++--------------------- 7 files changed, 9 insertions(+), 33 deletions(-) diff --git a/cmd/migrate/sql.go b/cmd/migrate/sql.go index a1e940235304..e09c698966e6 100644 --- a/cmd/migrate/sql.go +++ b/cmd/migrate/sql.go @@ -11,7 +11,6 @@ import ( "github.com/ory/x/configx" ) -// migrateSqlCmd represents the sql command func NewMigrateSQLCmd(opts ...driver.RegistryOption) *cobra.Command { c := &cobra.Command{ Use: "sql ", diff --git a/driver/registry.go b/driver/registry.go index dc31f7305633..a90e7d71db28 100644 --- a/driver/registry.go +++ b/driver/registry.go @@ -5,7 +5,6 @@ package driver import ( "context" - "io/fs" "github.com/ory/kratos/selfservice/sessiontokenexchange" "github.com/ory/x/contextx" @@ -185,7 +184,6 @@ type options struct { replaceTracer func(*otelx.Tracer) *otelx.Tracer replaceIdentitySchemaProvider func(Registry) schema.IdentitySchemaProvider inspect func(Registry) error - extraMigrations []fs.FS replacementStrategies []NewStrategy extraHooks map[string]func(config.SelfServiceHook) any disableMigrationLogging bool @@ -245,12 +243,6 @@ func Inspect(f func(reg Registry) error) RegistryOption { } } -func WithExtraMigrations(m ...fs.FS) RegistryOption { - return func(o *options) { - o.extraMigrations = append(o.extraMigrations, m...) - } -} - func WithDisabledMigrationLogging() RegistryOption { return func(o *options) { o.disableMigrationLogging = true diff --git a/driver/registry_default.go b/driver/registry_default.go index 9f88c7375dd0..01582a590856 100644 --- a/driver/registry_default.go +++ b/driver/registry_default.go @@ -672,7 +672,7 @@ func (m *RegistryDefault) Init(ctx context.Context, ctxer contextx.Contextualize m.Logger().WithError(err).Warnf("Unable to open database, retrying.") return errors.WithStack(err) } - p, err := sql.NewPersister(ctx, m, c, sql.WithExtraMigrations(o.extraMigrations...), sql.WithDisabledLogging(o.disableMigrationLogging)) + p, err := sql.NewPersister(ctx, m, c, sql.WithDisabledLogging(o.disableMigrationLogging)) if err != nil { m.Logger().WithError(err).Warnf("Unable to initialize persister, retrying.") return err diff --git a/go.mod b/go.mod index ac36ab25892a..61009dc01832 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/jmoiron/sqlx v1.4.0 github.com/julienschmidt/httprouter v1.3.0 github.com/knadh/koanf/parsers/json v0.1.0 - github.com/laher/mergefs v0.1.2-0.20230223191438-d16611b2f4e7 + github.com/laher/mergefs v0.1.2-0.20230223191438-d16611b2f4e7 // indirect github.com/lestrrat-go/jwx/v2 v2.1.1 github.com/luna-duclos/instrumentedsql v1.1.3 github.com/mailhog/MailHog v1.0.1 diff --git a/go.sum b/go.sum index e33a12499ae0..8036e25d5bec 100644 --- a/go.sum +++ b/go.sum @@ -551,7 +551,6 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/markbates/pkger v0.17.1 h1:/MKEtWqtc0mZvu9OinB9UzVN9iYCwLWuyUv4Bw+PCno= github.com/markbates/pkger v0.17.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQDXbLhiuI= -github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= diff --git a/internal/client-go/go.sum b/internal/client-go/go.sum index c966c8ddfd0d..6cc3f5911d11 100644 --- a/internal/client-go/go.sum +++ b/internal/client-go/go.sum @@ -4,6 +4,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/persistence/sql/persister.go b/persistence/sql/persister.go index 85bcdf7466c8..3b23da75dd61 100644 --- a/persistence/sql/persister.go +++ b/persistence/sql/persister.go @@ -6,12 +6,10 @@ package sql import ( "context" "embed" - "io/fs" "time" "github.com/gobuffalo/pop/v6" "github.com/gofrs/uuid" - "github.com/laher/mergefs" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -24,6 +22,7 @@ import ( "github.com/ory/kratos/session" "github.com/ory/kratos/x" "github.com/ory/x/contextx" + "github.com/ory/x/fsx" "github.com/ory/x/networkx" "github.com/ory/x/otelx" "github.com/ory/x/popx" @@ -57,25 +56,18 @@ type ( ) type persisterOptions struct { - extraMigrations []fs.FS - disableLogging bool + disableLogging bool } -type persisterOption func(o *persisterOptions) +type PersisterOption func(o *persisterOptions) -func WithExtraMigrations(fss ...fs.FS) persisterOption { - return func(o *persisterOptions) { - o.extraMigrations = fss - } -} - -func WithDisabledLogging(v bool) persisterOption { +func WithDisabledLogging(v bool) PersisterOption { return func(o *persisterOptions) { o.disableLogging = v } } -func NewPersister(ctx context.Context, r persisterDependencies, c *pop.Connection, opts ...persisterOption) (*Persister, error) { +func NewPersister(ctx context.Context, r persisterDependencies, c *pop.Connection, opts ...PersisterOption) (*Persister, error) { o := &persisterOptions{} for _, f := range opts { f(o) @@ -85,14 +77,7 @@ func NewPersister(ctx context.Context, r persisterDependencies, c *pop.Connectio logger.Logrus().SetLevel(logrus.WarnLevel) } m, err := popx.NewMigrationBox( - mergefs.Merge( - append( - []fs.FS{ - migrations, networkx.Migrations, - }, - o.extraMigrations..., - )..., - ), + fsx.Merge(migrations, networkx.Migrations), popx.NewMigrator(c, logger, r.Tracer(ctx), 0), ) if err != nil {