Arc - Enable Postgres dashboard (#12439)

* get overview, conn strings, properties pages working

* hook up password reset, azure link, scale configuration

* fix comments

* enable opening postgres dashboard from controller dashboard

* minor fixes

Co-authored-by: Brian Bergeron <brberger@microsoft.com>
Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
Brian Bergeron
2020-09-18 08:49:54 -07:00
committed by GitHub
parent 19566e0d9a
commit c50067b6d2
11 changed files with 144 additions and 123 deletions

View File

@@ -101,21 +101,23 @@ export class AzdataTool implements IAzdataTool {
show: async (name: string) => {
return this.executeCommand<azdataExt.PostgresServerShowResult>(['arc', 'postgres', 'server', 'show', '-n', name]);
},
edit: async (args: {
edit: async (
name: string,
adminPassword?: boolean,
coresLimit?: string,
coresRequest?: string,
engineSettings?: string,
extensions?: string,
memoryLimit?: string,
memoryRequest?: string,
noWait?: boolean,
port?: number,
replaceEngineSettings?: boolean,
workers?: number
}) => {
const argsArray = ['arc', 'postgres', 'server', 'edit', '-n', args.name];
args: {
adminPassword?: boolean,
coresLimit?: string,
coresRequest?: string,
engineSettings?: string,
extensions?: string,
memoryLimit?: string,
memoryRequest?: string,
noWait?: boolean,
port?: number,
replaceEngineSettings?: boolean,
workers?: number
},
additionalEnvVars?: { [key: string]: string }) => {
const argsArray = ['arc', 'postgres', 'server', 'edit', '-n', name];
if (args.adminPassword) { argsArray.push('--admin-password'); }
if (args.coresLimit !== undefined) { argsArray.push('--cores-limit', args.coresLimit); }
if (args.coresRequest !== undefined) { argsArray.push('--cores-request', args.coresRequest); }
@@ -127,7 +129,7 @@ export class AzdataTool implements IAzdataTool {
if (args.port !== undefined) { argsArray.push('--port', args.port.toString()); }
if (args.replaceEngineSettings) { argsArray.push('--replace-engine-settings'); }
if (args.workers !== undefined) { argsArray.push('--workers', args.workers.toString()); }
return this.executeCommand<void>(argsArray);
return this.executeCommand<void>(argsArray, additionalEnvVars);
}
}
},
@@ -182,18 +184,18 @@ export class AzdataTool implements IAzdataTool {
// ERROR: { stderr: '...' }
// so we also need to trim off the start that isn't a valid JSON blob
err.stderr = JSON.parse(err.stderr.substring(err.stderr.indexOf('{'), err.stderr.indexOf('}') + 1)).stderr;
} catch (err) {
} catch {
// it means this was probably some other generic error (such as command not being found)
// check if azdata still exists if it does then rethrow the original error if not then emit a new specific error.
try {
await fs.promises.access(this._path);
//this.path exists
throw err; // rethrow the error
} catch (e) {
// this.path does not exist
await vscode.commands.executeCommand('setContext', azdataFound, false);
throw (loc.noAzdata);
}
throw err; // rethrow the original error
}
}

View File

@@ -86,7 +86,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<azdata
postgres: {
server: {
delete: async (name: string) => {
await throwIfNoAzdataOrEulaNotAccepted();
throwIfNoAzdataOrEulaNotAccepted();
return localAzdata!.arc.postgres.server.delete(name);
},
list: async () => {
@@ -97,22 +97,24 @@ export async function activate(context: vscode.ExtensionContext): Promise<azdata
throwIfNoAzdataOrEulaNotAccepted();
return localAzdata!.arc.postgres.server.show(name);
},
edit: async (args: {
edit: async (
name: string,
adminPassword?: boolean,
coresLimit?: string,
coresRequest?: string,
engineSettings?: string,
extensions?: string,
memoryLimit?: string,
memoryRequest?: string,
noWait?: boolean,
port?: number,
replaceEngineSettings?: boolean,
workers?: number
}) => {
await throwIfNoAzdataOrEulaNotAccepted();
return localAzdata!.arc.postgres.server.edit(args);
args: {
adminPassword?: boolean,
coresLimit?: string,
coresRequest?: string,
engineSettings?: string,
extensions?: string,
memoryLimit?: string,
memoryRequest?: string,
noWait?: boolean,
port?: number,
replaceEngineSettings?: boolean,
workers?: number
},
additionalEnvVars?: { [key: string]: string }) => {
throwIfNoAzdataOrEulaNotAccepted();
return localAzdata!.arc.postgres.server.edit(name, args, additionalEnvVars);
}
}
},

View File

@@ -162,7 +162,7 @@ declare module 'azdata-ext' {
name: string // "citus"
}[],
settings: {
default: { } // { "max_connections": "101", "work_mem": "4MB" }
default: { [key: string]: string } // { "max_connections": "101", "work_mem": "4MB" }
}
},
scale: {
@@ -233,20 +233,22 @@ declare module 'azdata-ext' {
delete(name: string): Promise<AzdataOutput<void>>,
list(): Promise<AzdataOutput<PostgresServerListResult[]>>,
show(name: string): Promise<AzdataOutput<PostgresServerShowResult>>,
edit(args: {
edit(
name: string,
adminPassword?: boolean,
coresLimit?: string,
coresRequest?: string,
engineSettings?: string,
extensions?: string,
memoryLimit?: string,
memoryRequest?: string,
noWait?: boolean,
port?: number,
replaceEngineSettings?: boolean,
workers?: number
}): Promise<AzdataOutput<void>>
args: {
adminPassword?: boolean,
coresLimit?: string,
coresRequest?: string,
engineSettings?: string,
extensions?: string,
memoryLimit?: string,
memoryRequest?: string,
noWait?: boolean,
port?: number,
replaceEngineSettings?: boolean,
workers?: number
},
additionalEnvVars?: { [key: string]: string }): Promise<AzdataOutput<void>>
}
},
sql: {