-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: support postgresql connection via individual flags #15379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9bc7b28
5deb4da
31b3b9b
8574592
bfa3cb2
f50963b
7e8573c
b3c396b
a15c797
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -395,6 +395,22 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. | |
|
|
||
| config := r.createConfig() | ||
|
|
||
| if vals.PostgresURL == "" && vals.PostgresHost != "" && vals.PostgresUsername != "" && vals.PostgresPassword != "" && vals.PostgresDatabase != "" { | ||
|
||
| pgURL := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?%s", | ||
|
||
| vals.PostgresUsername.String(), | ||
| vals.PostgresPassword.String(), | ||
| vals.PostgresHost.String(), | ||
| vals.PostgresPort.String(), | ||
| vals.PostgresDatabase.String(), | ||
| vals.PostgresOptions.String(), | ||
| ) | ||
| err = vals.PostgresURL.Set(pgURL) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| cliui.Infof(inv.Stdout, "Created PostgreSQL URL from provided flags") | ||
|
||
| } | ||
|
|
||
| builtinPostgres := false | ||
| // Only use built-in if PostgreSQL URL isn't specified! | ||
| if !vals.InMemoryDatabase && vals.PostgresURL == "" { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,10 +54,29 @@ OPTIONS: | |
| Type of auth to use when connecting to postgres. | ||
|
|
||
| --postgres-url string, $CODER_PG_CONNECTION_URL | ||
| URL of a PostgreSQL database. If empty, PostgreSQL binaries will be | ||
| downloaded from Maven (https://repo1.maven.org/maven2) and store all | ||
| data in the config root. Access the built-in database with "coder | ||
| server postgres-builtin-url". | ||
| URL of a PostgreSQL database. If empty and credentials are not | ||
| provided via other flags, PostgreSQL binaries will be downloaded from | ||
| Maven (https://repo1.maven.org/maven2) and store all data in the | ||
| config root. Access the built-in database with "coder server | ||
| postgres-builtin-url". | ||
|
||
|
|
||
| --postgres-database string, $CODER_PG_DATABASE | ||
| PostgreSQL database name. | ||
|
|
||
| --postgres-host string, $CODER_PG_HOST | ||
| PostgreSQL server hostname. | ||
|
|
||
| --postgres-options string, $CODER_PG_OPTIONS | ||
| PostgreSQL connection options (e.g. 'sslmode=require'). | ||
|
|
||
| --postgres-password string, $CODER_PG_PASSWORD | ||
| PostgreSQL password. | ||
|
|
||
| --postgres-port string, $CODER_PG_PORT (default: 5432) | ||
| PostgreSQL server port. | ||
|
|
||
| --postgres-username string, $CODER_PG_USERNAME | ||
| PostgreSQL username. | ||
|
|
||
| --ssh-keygen-algorithm string, $CODER_SSH_KEYGEN_ALGORITHM (default: ed25519) | ||
| The algorithm to use for generating ssh keys. Accepted values are | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably return an error if both connection URL and any other setting is provided. There's no good decision to make on which to prefer over the other so the user has to decide (hence the error) or we may introduce surprising behavior.