Skip to content

Commit 33b5e1c

Browse files
kyleconroylisitsky
authored andcommitted
feat(vet): Use new dbmanager client (sqlc-dev#3423)
1 parent 0e1d754 commit 33b5e1c

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

internal/cmd/vet.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
"google.golang.org/protobuf/encoding/protojson"
2323

2424
"github.com/sqlc-dev/sqlc/internal/config"
25+
"github.com/sqlc-dev/sqlc/internal/dbmanager"
2526
"github.com/sqlc-dev/sqlc/internal/debug"
2627
"github.com/sqlc-dev/sqlc/internal/migrations"
2728
"github.com/sqlc-dev/sqlc/internal/opts"
2829
"github.com/sqlc-dev/sqlc/internal/plugin"
2930
"github.com/sqlc-dev/sqlc/internal/quickdb"
30-
pb "github.com/sqlc-dev/sqlc/internal/quickdb/v1"
3131
"github.com/sqlc-dev/sqlc/internal/shfmt"
3232
"github.com/sqlc-dev/sqlc/internal/sql/sqlpath"
3333
"github.com/sqlc-dev/sqlc/internal/vet"
@@ -386,7 +386,7 @@ type checker struct {
386386
Env *cel.Env
387387
Stderr io.Writer
388388
OnlyManagedDB bool
389-
Client pb.QuickClient
389+
Client dbmanager.Client
390390
Replacer *shfmt.Replacer
391391
}
392392

@@ -405,10 +405,7 @@ func (c *checker) fetchDatabaseUri(ctx context.Context, s config.SQL) (string, f
405405

406406
if c.Client == nil {
407407
// FIXME: Eventual race condition
408-
client, err := quickdb.NewClientFromConfig(c.Conf.Cloud)
409-
if err != nil {
410-
return "", cleanup, fmt.Errorf("managed: client: %w", err)
411-
}
408+
client := dbmanager.NewClient(c.Conf.Servers)
412409
c.Client = client
413410
}
414411

@@ -425,22 +422,14 @@ func (c *checker) fetchDatabaseUri(ctx context.Context, s config.SQL) (string, f
425422
ddl = append(ddl, migrations.RemoveIgnoredStatements(string(contents)))
426423
}
427424

428-
resp, err := c.Client.CreateEphemeralDatabase(ctx, &pb.CreateEphemeralDatabaseRequest{
425+
resp, err := c.Client.CreateDatabase(ctx, &dbmanager.CreateDatabaseRequest{
429426
Engine: string(s.Engine),
430-
Region: quickdb.GetClosestRegion(),
431427
Migrations: ddl,
432428
})
433429
if err != nil {
434430
return "", cleanup, fmt.Errorf("managed: create database: %w", err)
435431
}
436432

437-
cleanup = func() error {
438-
_, err := c.Client.DropEphemeralDatabase(ctx, &pb.DropEphemeralDatabaseRequest{
439-
DatabaseId: resp.DatabaseId,
440-
})
441-
return err
442-
}
443-
444433
var uri string
445434
switch s.Engine {
446435
case config.EngineMySQL:

0 commit comments

Comments
 (0)