diff --git a/pkg/gordio/admin/admin.go b/pkg/gordio/admin/admin.go index 04255cb..bf90ac4 100644 --- a/pkg/gordio/admin/admin.go +++ b/pkg/gordio/admin/admin.go @@ -132,7 +132,7 @@ func addUserCommand(cfg *config.Config) *cobra.Command { Use: "add", Short: "adds a user", RunE: func(cmd *cobra.Command, args []string) error { - db, err := database.NewClient(cfg.DB) + db, err := database.NewClient(context.Background(), cfg.DB) if err != nil { return err } @@ -163,7 +163,7 @@ func passwdCommand(cfg *config.Config) *cobra.Command { Short: "changes password for a user", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - db, err := database.NewClient(cfg.DB) + db, err := database.NewClient(context.Background(), cfg.DB) if err != nil { return err } diff --git a/pkg/gordio/database/database.go b/pkg/gordio/database/database.go index 99c26fc..8aee6fd 100644 --- a/pkg/gordio/database/database.go +++ b/pkg/gordio/database/database.go @@ -22,7 +22,7 @@ type DB struct { } // NewClient creates a new DB using the provided config. -func NewClient(conf config.DB) (*DB, error) { +func NewClient(ctx context.Context, conf config.DB) (*DB, error) { dir, err := iofs.New(sqlembed.Migrations, "postgres/migrations") if err != nil { return nil, err @@ -40,7 +40,7 @@ func NewClient(conf config.DB) (*DB, error) { m.Close() - pool, err := pgxpool.New(context.Background(), conf.Connect) + pool, err := pgxpool.New(ctx, conf.Connect) if err != nil { return nil, err } diff --git a/pkg/gordio/gordio.go b/pkg/gordio/gordio.go index 528d9b8..e8f2c7b 100644 --- a/pkg/gordio/gordio.go +++ b/pkg/gordio/gordio.go @@ -58,7 +58,7 @@ func (o *ServeOptions) Execute() error { } }() - srv, err := server.New(o.cfg) + srv, err := server.New(ctx, o.cfg) if err != nil { return err } diff --git a/pkg/gordio/server/server.go b/pkg/gordio/server/server.go index 3782eb0..2868839 100644 --- a/pkg/gordio/server/server.go +++ b/pkg/gordio/server/server.go @@ -30,13 +30,13 @@ type Server struct { logger *Logger } -func New(cfg *config.Config) (*Server, error) { +func New(ctx context.Context, cfg *config.Config) (*Server, error) { logger, err := NewLogger(cfg) if err != nil { return nil, err } - db, err := database.NewClient(cfg.DB) + db, err := database.NewClient(ctx, cfg.DB) if err != nil { return nil, err }