Skip to content

Commit 2aa7700

Browse files
chore: lint
1 parent 122e4c1 commit 2aa7700

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

flow/connectors/postgres/pgdump_schema.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func pipeCommand(
4040
psqlCmd.Env = append(os.Environ(), "PGPASSWORD="+dstConfig.Password)
4141

4242
// handle TLS env vars
43-
appendTLSEnv(srcCmd, srcConfig)
44-
appendTLSEnv(psqlCmd, dstConfig)
43+
appendTLSEnv(ctx, srcCmd, srcConfig)
44+
appendTLSEnv(ctx, psqlCmd, dstConfig)
4545

4646
// pipe source command stdout -> psql stdin
4747
pipe, err := srcCmd.StdoutPipe()
@@ -118,19 +118,19 @@ func buildPsqlArgs(config *protos.PostgresConfig) []string {
118118
return args
119119
}
120120

121-
func appendTLSEnv(cmd *exec.Cmd, config *protos.PostgresConfig) {
121+
func appendTLSEnv(ctx context.Context, cmd *exec.Cmd, config *protos.PostgresConfig) {
122122
if config.RequireTls {
123123
cmd.Env = append(cmd.Env, "PGSSLMODE=require")
124124

125125
if config.RootCa != nil && *config.RootCa != "" {
126126
// write root CA to a temp file
127127
tmpFile, err := os.CreateTemp("", "peerdb-root-ca-*.pem")
128128
if err != nil {
129-
slog.Warn("failed to create temp file for root CA, skipping sslrootcert", slog.Any("error", err))
129+
slog.WarnContext(ctx, "failed to create temp file for root CA, skipping sslrootcert", slog.Any("error", err))
130130
return
131131
}
132132
if _, err := tmpFile.WriteString(*config.RootCa); err != nil {
133-
slog.Warn("failed to write root CA to temp file", slog.Any("error", err))
133+
slog.WarnContext(ctx, "failed to write root CA to temp file", slog.Any("error", err))
134134
tmpFile.Close()
135135
os.Remove(tmpFile.Name())
136136
return

flow/e2e/pg_schema_dump_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,13 @@ func (s PeerFlowE2ETestSuitePG) Test_PG_Schema_Dump_And_CDC() {
220220
EnvWaitFor(s.t, env, 3*time.Minute, "initial load parent", func() bool {
221221
var count int64
222222
err := dstConn.QueryRow(s.t.Context(),
223-
fmt.Sprintf("SELECT COUNT(*) FROM %s", dstParent)).Scan(&count)
223+
"SELECT COUNT(*) FROM " + dstParent).Scan(&count)
224224
return err == nil && count == 5
225225
})
226226
EnvWaitFor(s.t, env, 3*time.Minute, "initial load child", func() bool {
227227
var count int64
228228
err := dstConn.QueryRow(s.t.Context(),
229-
fmt.Sprintf("SELECT COUNT(*) FROM %s", dstChild)).Scan(&count)
229+
"SELECT COUNT(*) FROM " + dstChild).Scan(&count)
230230
return err == nil && count == 10
231231
})
232232

@@ -306,29 +306,29 @@ func (s PeerFlowE2ETestSuitePG) Test_PG_Schema_Dump_And_CDC() {
306306
EnvWaitFor(s.t, env, 3*time.Minute, "cdc parent rows", func() bool {
307307
var count int64
308308
err := dstConn.QueryRow(s.t.Context(),
309-
fmt.Sprintf("SELECT COUNT(*) FROM %s", dstParent)).Scan(&count)
309+
"SELECT COUNT(*) FROM " + dstParent).Scan(&count)
310310
return err == nil && count == 8
311311
})
312312
EnvWaitFor(s.t, env, 3*time.Minute, "cdc child rows", func() bool {
313313
var count int64
314314
err := dstConn.QueryRow(s.t.Context(),
315-
fmt.Sprintf("SELECT COUNT(*) FROM %s", dstChild)).Scan(&count)
315+
"SELECT COUNT(*) FROM " + dstChild).Scan(&count)
316316
return err == nil && count == 15
317317
})
318318

319319
// verify data integrity: compare actual row content
320320
// query source and destination and compare
321321
var srcParentCount, dstParentCount int64
322-
err = srcConn.QueryRow(s.t.Context(), fmt.Sprintf("SELECT COUNT(*) FROM %s", srcParent)).Scan(&srcParentCount)
322+
err = srcConn.QueryRow(s.t.Context(), "SELECT COUNT(*) FROM " + srcParent).Scan(&srcParentCount)
323323
require.NoError(s.t, err)
324-
err = dstConn.QueryRow(s.t.Context(), fmt.Sprintf("SELECT COUNT(*) FROM %s", dstParent)).Scan(&dstParentCount)
324+
err = dstConn.QueryRow(s.t.Context(), "SELECT COUNT(*) FROM " + dstParent).Scan(&dstParentCount)
325325
require.NoError(s.t, err)
326326
require.Equal(s.t, srcParentCount, dstParentCount, "parent table row counts should match")
327327

328328
var srcChildCount, dstChildCount int64
329-
err = srcConn.QueryRow(s.t.Context(), fmt.Sprintf("SELECT COUNT(*) FROM %s", srcChild)).Scan(&srcChildCount)
329+
err = srcConn.QueryRow(s.t.Context(), "SELECT COUNT(*) FROM " + srcChild).Scan(&srcChildCount)
330330
require.NoError(s.t, err)
331-
err = dstConn.QueryRow(s.t.Context(), fmt.Sprintf("SELECT COUNT(*) FROM %s", dstChild)).Scan(&dstChildCount)
331+
err = dstConn.QueryRow(s.t.Context(), "SELECT COUNT(*) FROM " + dstChild).Scan(&dstChildCount)
332332
require.NoError(s.t, err)
333333
require.Equal(s.t, srcChildCount, dstChildCount, "child table row counts should match")
334334

@@ -358,7 +358,8 @@ func (s PeerFlowE2ETestSuitePG) Test_PG_Schema_Dump_No_Owner_No_Privileges() {
358358
dstConnStr := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s",
359359
dstCfg.Host, dstCfg.Port, dstCfg.User, dstCfg.Password, dstCfg.Database)
360360
dstConn, err := pgx.Connect(s.t.Context(), dstConnStr)
361-
require.NoError(s.t, err, "failed to connect to secondary postgres on %s:%d (is the postgres2 tilt resource running?)", dstCfg.Host, dstCfg.Port)
361+
require.NoError(s.t, err, "failed to connect to secondary postgres on %s:%d (postgres2 tilt resource running?)",
362+
dstCfg.Host, dstCfg.Port)
362363
s.t.Cleanup(func() { dstConn.Close(s.t.Context()) })
363364

364365
// sanity: role must not exist on destination
@@ -436,7 +437,7 @@ func (s PeerFlowE2ETestSuitePG) Test_PG_Schema_Dump_No_Owner_No_Privileges() {
436437
EnvWaitFor(s.t, env, 3*time.Minute, "initial load owned_tbl", func() bool {
437438
var count int64
438439
err := dstConn.QueryRow(s.t.Context(),
439-
fmt.Sprintf("SELECT COUNT(*) FROM %s", qualified)).Scan(&count)
440+
"SELECT COUNT(*) FROM " + qualified).Scan(&count)
440441
return err == nil && count == 5
441442
})
442443

@@ -451,7 +452,7 @@ func (s PeerFlowE2ETestSuitePG) Test_PG_Schema_Dump_No_Owner_No_Privileges() {
451452
EnvWaitFor(s.t, env, 3*time.Minute, "cdc owned_tbl", func() bool {
452453
var count int64
453454
err := dstConn.QueryRow(s.t.Context(),
454-
fmt.Sprintf("SELECT COUNT(*) FROM %s", qualified)).Scan(&count)
455+
"SELECT COUNT(*) FROM " + qualified).Scan(&count)
455456
return err == nil && count == 10
456457
})
457458

0 commit comments

Comments
 (0)