Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba268a7

Browse files
author
Claude
committed
fix: fix formatting with gofmt (remove trailing whitespace)
1 parent 997e601 commit ba268a7

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

cli/server.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -420,40 +420,40 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
420420
config := r.createConfig()
421421

422422
builtinPostgres := false
423-
423+
424424
// Check if we have individual PostgreSQL connection parameters
425-
hasIndividualParams := len(vals.PostgresHost.String()) > 0 &&
426-
len(vals.PostgresUsername.String()) > 0 &&
427-
len(vals.PostgresPassword.String()) > 0 &&
425+
hasIndividualParams := len(vals.PostgresHost.String()) > 0 &&
426+
len(vals.PostgresUsername.String()) > 0 &&
427+
len(vals.PostgresPassword.String()) > 0 &&
428428
len(vals.PostgresDatabase.String()) > 0
429-
429+
430430
// Build a connection URL from individual components if provided and no connection URL exists
431431
if !vals.InMemoryDatabase.Value() && vals.PostgresURL == "" && hasIndividualParams {
432432
port := vals.PostgresPort.String()
433433
if port == "" {
434434
port = "5432" // Default PostgreSQL port
435435
}
436-
436+
437437
// Build the base connection string
438-
connURL := fmt.Sprintf("postgres://%s:%s@%s:%s/%s",
438+
connURL := fmt.Sprintf("postgres://%s:%s@%s:%s/%s",
439439
vals.PostgresUsername.String(),
440440
vals.PostgresPassword.String(),
441441
vals.PostgresHost.String(),
442442
port,
443443
vals.PostgresDatabase.String())
444-
444+
445445
// Add options if provided
446446
if len(vals.PostgresOptions.String()) > 0 {
447447
connURL = connURL + "?" + vals.PostgresOptions.String()
448448
}
449-
449+
450450
logger.Debug(ctx, "using individual PostgreSQL connection parameters")
451451
err = vals.PostgresURL.Set(connURL)
452452
if err != nil {
453453
return xerrors.Errorf("set postgres url from components: %w", err)
454454
}
455455
}
456-
456+
457457
// Only use built-in if PostgreSQL URL and individual parameters aren't specified!
458458
if !vals.InMemoryDatabase.Value() && vals.PostgresURL == "" && !hasIndividualParams {
459459
var closeFunc func() error
@@ -2770,7 +2770,7 @@ func getAndMigratePostgresDB(ctx context.Context, logger slog.Logger, postgresUR
27702770
// The postgresURL is constructed earlier by caller from either the
27712771
// CODER_PG_CONNECTION_URL or the individual components (host, port, etc.)
27722772
// So we just validate it here and don't need to reconstruct it
2773-
2773+
27742774
dbURL, err := escapePostgresURLUserInfo(postgresURL)
27752775
if err != nil {
27762776
return nil, "", xerrors.Errorf("escaping postgres URL: %w", err)

cli/server_test.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,24 @@ func TestServer(t *testing.T) {
180180
return err == nil && rawURL != ""
181181
}, superDuperLong, testutil.IntervalFast, "failed to get access URL")
182182
})
183-
183+
184184
t.Run("PostgresConnectionParams", func(t *testing.T) {
185185
if testing.Short() {
186186
t.SkipNow()
187187
}
188188
t.Parallel()
189-
189+
190190
// Use URL of built-in test database
191191
dbURL, err := dbtestutil.Open(t)
192192
require.NoError(t, err)
193-
194-
// Rather than testing individual parameters directly (which would require access to
193+
194+
// Rather than testing individual parameters directly (which would require access to
195195
// unexported struct fields), test the CLI flags with the actual server
196-
196+
197197
// Parse the URL to extract components
198198
u, err := url.Parse(dbURL)
199199
require.NoError(t, err, "Failed to parse database URL")
200-
200+
201201
// Extract components
202202
username := u.User.Username()
203203
password, _ := u.User.Password()
@@ -207,11 +207,11 @@ func TestServer(t *testing.T) {
207207
port = "5432" // Use default PostgreSQL port
208208
}
209209
database := strings.TrimPrefix(u.Path, "/")
210-
210+
211211
// Test with CLI flags
212212
t.Run("WithFlags", func(t *testing.T) {
213213
t.Parallel()
214-
214+
215215
inv, cfg := clitest.New(t,
216216
"server",
217217
"--http-address", ":0",
@@ -223,40 +223,40 @@ func TestServer(t *testing.T) {
223223
"--postgres-database", database,
224224
"--postgres-options", "sslmode=disable",
225225
)
226-
226+
227227
const longTimeout = testutil.WaitLong * 3
228228
ctx := testutil.Context(t, longTimeout)
229229
clitest.Start(t, inv.WithContext(ctx))
230-
230+
231231
//nolint:gocritic // Test server takes a while to start
232232
require.Eventually(t, func() bool {
233233
rawURL, err := cfg.URL().Read()
234234
return err == nil && rawURL != ""
235235
}, longTimeout, testutil.IntervalFast, "failed to get access URL with individual PostgreSQL parameters")
236236
})
237-
237+
238238
// Test with environment variables
239239
t.Run("WithEnvironmentVariables", func(t *testing.T) {
240240
t.Parallel()
241-
241+
242242
inv, cfg := clitest.New(t,
243243
"server",
244244
"--http-address", ":0",
245245
"--access-url", "http://example.com",
246246
)
247-
247+
248248
// Set environment variables
249249
inv.Environ.Set("CODER_PG_HOST", host)
250250
inv.Environ.Set("CODER_PG_PORT", port)
251251
inv.Environ.Set("CODER_PG_USERNAME", username)
252252
inv.Environ.Set("CODER_PG_PASSWORD", password)
253253
inv.Environ.Set("CODER_PG_DATABASE", database)
254254
inv.Environ.Set("CODER_PG_OPTIONS", "sslmode=disable")
255-
255+
256256
const longTimeout = testutil.WaitLong * 3
257257
ctx := testutil.Context(t, longTimeout)
258258
clitest.Start(t, inv.WithContext(ctx))
259-
259+
260260
//nolint:gocritic // Test server takes a while to start
261261
require.Eventually(t, func() bool {
262262
rawURL, err := cfg.URL().Read()

0 commit comments

Comments
 (0)