[go: nahoru, domu]

Skip to content
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

"Connect to Postgres" using ConfigureEmulator API #7262

Merged
merged 7 commits into from
Jun 4, 2024
Merged

Conversation

hlshen
Copy link
Contributor
@hlshen hlshen commented Jun 4, 2024
  • Add UI for Connect to Postgres, and displaying postgres connection after
  • Local endpoint is a class function in EmulatorController
  • Implement DataConnectEmulatorClient, and ConfigureEmulator api

@hlshen hlshen requested review from joehan and yuchenshi June 4, 2024 00:21
}

return (
"http://" + dataConnectEmulator.host + ":" + dataConnectEmulator.port
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please handle IPv6 quoting similar to

if (info.host.includes(":")) {
url.hostname = `[${info.host}]`; // IPv6 addresses need to be quoted.

Copy link
Member
@yuchenshi yuchenshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looking good but please address comments inline

src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
Copy link
Contributor
@joehan joehan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General approach looks good, but i think this won't behave as expected rn.

src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
src/emulator/dataconnectEmulator.ts Outdated Show resolved Hide resolved
* Autoconnect to postgres when not in VSCE

* Format

* Return values
@joehan
Copy link
Contributor
joehan commented Jun 4, 2024

Merged my PR onto yours to autoconnect when not in vscode

@hlshen hlshen requested review from joehan and yuchenshi June 4, 2024 18:44
Copy link
Contributor
@joehan joehan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after formatting

});

return connectionString;
}

private async connectToPostgres() {
const rc = firebaseRC.value?.tryReadValue;
const newConnectionString = await this.promptConnectionString(
rc?.getDataconnect()?.postgres.localConnectionString ||
"postgres://user:password@localhost:5432/dbname",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use switch the default string to point to the 'postgres' DB?

Suggested change
"postgres://user:password@localhost:5432/dbname",
"postgres://user:password@localhost:5432/postgres",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@@ -2,13 +2,17 @@ import * as childProcess from "child_process";

import { dataConnectLocalConnString } from "../api";
import { Constants } from "./constants";
import { getPID, start, stop, downloadIfNecessary } from "./downloadableEmulators";
import { getPID, start, stop, downloadIfNecessary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we just need to run 'npm run format'

@joehan joehan enabled auto-merge (squash) June 4, 2024 20:04
@joehan joehan merged commit c7b6485 into master Jun 4, 2024
39 checks passed
@hlshen hlshen deleted the hlshen/start branch June 4, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants