-
Notifications
You must be signed in to change notification settings - Fork 1
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
Assorted Cleanup #9
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5028762
remove term "provenance database"
devhawk 43a4a22
detect missing and expired cloud cred errors
devhawk e981578
order wf ids by created_at DESC
devhawk 81c299b
minor cleanup
devhawk 987a770
move cloud cli logic to separate file
devhawk 6ad1b91
fix file name convention
devhawk 770bb61
ProvenanceDatabaseConfig
devhawk 186e930
fix ssl setting in ProvenanceDatabase.connect
devhawk 67cb77b
readme
devhawk 41b6109
marked extension as preview in package.json
devhawk e5e3c72
don't include .github files in packed extension
devhawk bab4bbc
add current dbos logo to extension
devhawk fecd46f
update changelog and version for early adopter release
devhawk 6f81e41
update CHANGELOG
devhawk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import * as vscode from 'vscode'; | ||
import { spawn as cpSpawn } from "child_process"; | ||
import { execFile } from './utils'; | ||
import { logger } from './extension'; | ||
|
||
export interface DbosCloudApp { | ||
Name: string; | ||
ID: string; | ||
PostgresInstanceName: string; | ||
ApplicationDatabaseName: string; | ||
Status: string; | ||
Version: string; | ||
} | ||
|
||
export interface DbosCloudDatabase { | ||
PostgresInstanceName: string; | ||
HostName: string; | ||
Status: string; | ||
Port: number; | ||
AdminUsername: string; | ||
} | ||
|
||
async function dbos_cloud_cli<T>(folder: vscode.WorkspaceFolder, ...args: string[]): Promise<T> { | ||
const { stdout } = await execFile("npx", ["dbos-cloud", ...args, "--json"], { | ||
cwd: folder.uri.fsPath, | ||
}); | ||
return JSON.parse(stdout) as T; | ||
} | ||
|
||
export async function dbos_cloud_app_status(folder: vscode.WorkspaceFolder) { | ||
return dbos_cloud_cli<DbosCloudApp>(folder, "application", "status"); | ||
} | ||
|
||
export async function dbos_cloud_db_status(folder: vscode.WorkspaceFolder, databaseName: string) { | ||
return dbos_cloud_cli<DbosCloudDatabase>(folder, "database", "status", databaseName); | ||
} | ||
|
||
export async function dbos_cloud_login(folder: vscode.WorkspaceFolder) { | ||
logger.debug("dbos_cloud_login", { folder: folder.uri.fsPath }); | ||
|
||
const cts = new vscode.CancellationTokenSource(); | ||
const loginProc = cpSpawn("npx", ["dbos-cloud", "login"], { cwd: folder.uri.fsPath }); | ||
const userCodeEmitter = new vscode.EventEmitter<string>(); | ||
|
||
const regexLoginInfo = /Login URL: (http.*\/activate\?user_code=([A-Z][A-Z][A-Z][A-Z]-[A-Z][A-Z][A-Z][A-Z]))/; | ||
const regexSuccessfulLogin = /Successfully logged in as (.*)!/; | ||
devhawk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
try { | ||
const ctsPromise = new Promise<void>(resolve => { | ||
cts.token.onCancellationRequested(() => resolve()); | ||
}); | ||
|
||
loginProc.on('exit', (code) => { logger.debug("dbos_cloud_login on proc exit", { code }); cts.cancel(); }); | ||
loginProc.on('close', (code) => { logger.debug("dbos_cloud_login on proc close", { code }); cts.cancel(); }); | ||
loginProc.on('error', err => { logger.error("dbos_cloud_login on proc error", err); cts.cancel(); }); | ||
|
||
loginProc.stdout.on("data", async (buffer: Buffer) => { | ||
const data = buffer.toString().trim(); | ||
logger.debug("dbos_cloud_login on stdout data", { data }); | ||
|
||
const loginUrlMatch = regexLoginInfo.exec(data); | ||
if (loginUrlMatch && loginUrlMatch.length === 3) { | ||
const [, loginUrl, userCode] = loginUrlMatch; | ||
logger.info("dbos_cloud_login login info", { loginUri: loginUrl, userCode }); | ||
userCodeEmitter.fire(userCode); | ||
|
||
const openResult = await vscode.env.openExternal(vscode.Uri.parse(loginUrl)); | ||
if (!openResult) { | ||
logger.error("dbos_cloud_login openExternal failed", { loginUri: loginUrl, userCode }); | ||
cts.cancel(); | ||
} | ||
} | ||
|
||
const successfulLoginMatch = regexSuccessfulLogin.exec(data); | ||
if (successfulLoginMatch && successfulLoginMatch.length === 2) { | ||
const [, user] = successfulLoginMatch; | ||
logger.info("dbos-dbos_cloud_login successful login", { user }); | ||
vscode.window.showInformationMessage(`Successfully logged in to DBOS Cloud as ${user}`); | ||
} | ||
}); | ||
|
||
await vscode.window.withProgress({ | ||
cancellable: true, | ||
location: vscode.ProgressLocation.Notification, | ||
title: "Launching browser to log into DBOS Cloud" | ||
}, async (progress, token) => { | ||
userCodeEmitter.event(userCode => { | ||
progress.report({ message: `\nUser code: ${userCode}` }); | ||
}); | ||
|
||
token.onCancellationRequested(() => cts.cancel()); | ||
await ctsPromise; | ||
}); | ||
} finally { | ||
loginProc.stdout.removeAllListeners(); | ||
loginProc.stderr.removeAllListeners(); | ||
loginProc.removeAllListeners(); | ||
|
||
cts.dispose(); | ||
userCodeEmitter.dispose(); | ||
|
||
const killed = loginProc.killed; | ||
const killResult = loginProc.kill(); | ||
logger.debug("dbos_cloud_login exit", { killed, killResult }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe also mention that users can pick workflow IDs from the monitoring dashboard? Then we can have a pointer to the docs.
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.
I was going to update the readme once that work is in