mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
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:
@@ -96,7 +96,7 @@
|
|||||||
"view/item/context": [
|
"view/item/context": [
|
||||||
{
|
{
|
||||||
"command": "arc.openDashboard",
|
"command": "arc.openDashboard",
|
||||||
"when": "view == azureArc && viewItem && viewItem != postgresInstances)",
|
"when": "view == azureArc && viewItem",
|
||||||
"group": "navigation@1"
|
"group": "navigation@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export type Registration = {
|
|||||||
export class ControllerModel {
|
export class ControllerModel {
|
||||||
private readonly _azdataApi: azdataExt.IExtension;
|
private readonly _azdataApi: azdataExt.IExtension;
|
||||||
private _endpoints: azdataExt.DcEndpointListResult[] = [];
|
private _endpoints: azdataExt.DcEndpointListResult[] = [];
|
||||||
private _namespace: string = '';
|
|
||||||
private _registrations: Registration[] = [];
|
private _registrations: Registration[] = [];
|
||||||
private _controllerConfig: azdataExt.DcConfigShowResult | undefined = undefined;
|
private _controllerConfig: azdataExt.DcConfigShowResult | undefined = undefined;
|
||||||
|
|
||||||
@@ -158,10 +157,6 @@ export class ControllerModel {
|
|||||||
return this._endpoints.find(e => e.name === name);
|
return this._endpoints.find(e => e.name === name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get namespace(): string {
|
|
||||||
return this._namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get registrations(): Registration[] {
|
public get registrations(): Registration[] {
|
||||||
return this._registrations;
|
return this._registrations;
|
||||||
}
|
}
|
||||||
@@ -176,15 +171,6 @@ export class ControllerModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteRegistration(_type: ResourceType, _name: string) {
|
|
||||||
/* TODO chgagnon
|
|
||||||
if (r && !r.isDeleted && r.customObjectName) {
|
|
||||||
const r = this.getRegistration(type, name);
|
|
||||||
await this._registrationRouter.apiV1RegistrationNsNameIsDeletedDelete(this._namespace, r.customObjectName, true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* property to for use a display label for this controller
|
* property to for use a display label for this controller
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import { ResourceInfo } from 'arc';
|
import { ResourceInfo } from 'arc';
|
||||||
import * as azdataExt from 'azdata-ext';
|
import * as azdataExt from 'azdata-ext';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
import * as loc from '../localizedConstants';
|
||||||
import { ControllerModel, Registration } from './controllerModel';
|
import { ControllerModel, Registration } from './controllerModel';
|
||||||
import { ResourceModel } from './resourceModel';
|
import { ResourceModel } from './resourceModel';
|
||||||
import { parseIpAndPort } from '../common/utils';
|
import { parseIpAndPort } from '../common/utils';
|
||||||
@@ -23,20 +24,56 @@ export class PostgresModel extends ResourceModel {
|
|||||||
this._azdataApi = <azdataExt.IExtension>vscode.extensions.getExtension(azdataExt.extension.name)?.exports;
|
this._azdataApi = <azdataExt.IExtension>vscode.extensions.getExtension(azdataExt.extension.name)?.exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the configuration of Postgres */
|
||||||
public get config(): azdataExt.PostgresServerShowResult | undefined {
|
public get config(): azdataExt.PostgresServerShowResult | undefined {
|
||||||
return this._config;
|
return this._config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the IP address and port of the server */
|
/** Returns the major version of Postgres */
|
||||||
public get endpoint(): { ip: string, port: string } {
|
public get engineVersion(): string | undefined {
|
||||||
return this._config
|
const kind = this._config?.kind;
|
||||||
? parseIpAndPort(this._config.status.externalEndpoint)
|
return kind
|
||||||
: { ip: '', port: '' };
|
? kind.substring(kind.lastIndexOf('-') + 1)
|
||||||
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the server's configuration e.g. '3 nodes, 1.5 vCores, 1GiB RAM, 2GiB storage per node' */
|
/** Returns the IP address and port of Postgres */
|
||||||
public get configuration(): string {
|
public get endpoint(): { ip: string, port: string } | undefined {
|
||||||
return ''; // TODO
|
return this._config?.status.externalEndpoint
|
||||||
|
? parseIpAndPort(this._config.status.externalEndpoint)
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the scale configuration of Postgres e.g. '3 nodes, 1.5 vCores, 1Gi RAM, 2Gi storage per node' */
|
||||||
|
public get scaleConfiguration(): string | undefined {
|
||||||
|
if (!this._config) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cpuLimit = this._config.spec.scheduling?.default?.resources?.limits?.cpu;
|
||||||
|
const ramLimit = this._config.spec.scheduling?.default?.resources?.limits?.memory;
|
||||||
|
const cpuRequest = this._config.spec.scheduling?.default?.resources?.requests?.cpu;
|
||||||
|
const ramRequest = this._config.spec.scheduling?.default?.resources?.requests?.memory;
|
||||||
|
const storage = this._config.spec.storage?.data?.size;
|
||||||
|
const nodes = (this._config.spec.scale?.shards ?? 0) + 1; // An extra node for the coordinator
|
||||||
|
|
||||||
|
let configuration: string[] = [];
|
||||||
|
configuration.push(`${nodes} ${nodes > 1 ? loc.nodes : loc.node}`);
|
||||||
|
|
||||||
|
// Prefer limits if they're provided, otherwise use requests if they're provided
|
||||||
|
if (cpuLimit || cpuRequest) {
|
||||||
|
configuration.push(`${cpuLimit ?? cpuRequest!} ${loc.vCores}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ramLimit || ramRequest) {
|
||||||
|
configuration.push(`${ramLimit ?? ramRequest!} ${loc.ram}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (storage) {
|
||||||
|
configuration.push(`${storage} ${loc.storagePerNode}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return configuration.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Refreshes the model */
|
/** Refreshes the model */
|
||||||
|
|||||||
@@ -219,23 +219,16 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
|
|||||||
iconHeight: iconSize,
|
iconHeight: iconSize,
|
||||||
iconWidth: iconSize
|
iconWidth: iconSize
|
||||||
}).component();
|
}).component();
|
||||||
let nameComponent: azdata.Component;
|
|
||||||
if (r.instanceType === ResourceType.postgresInstances) {
|
const nameComponent = this.modelView.modelBuilder.hyperlink()
|
||||||
nameComponent = this.modelView.modelBuilder.text()
|
|
||||||
.withProperties<azdata.TextComponentProperties>({
|
|
||||||
value: r.instanceName || '',
|
|
||||||
CSSStyles: { ...cssStyles.text, 'margin-block-start': '0px', 'margin-block-end': '0px' }
|
|
||||||
}).component();
|
|
||||||
} else {
|
|
||||||
nameComponent = this.modelView.modelBuilder.hyperlink()
|
|
||||||
.withProperties<azdata.HyperlinkComponentProperties>({
|
.withProperties<azdata.HyperlinkComponentProperties>({
|
||||||
label: r.instanceName || '',
|
label: r.instanceName || '',
|
||||||
url: ''
|
url: ''
|
||||||
}).component();
|
}).component();
|
||||||
(<azdata.HyperlinkComponent>nameComponent).onDidClick(async () => {
|
|
||||||
|
this.disposables.push(nameComponent.onDidClick(async () => {
|
||||||
await this._controllerModel.treeDataProvider.openResourceDashboard(this._controllerModel, r.instanceType || '', r.instanceName);
|
await this._controllerModel.treeDataProvider.openResourceDashboard(this._controllerModel, r.instanceType || '', r.instanceName);
|
||||||
});
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
// TODO chgagnon
|
// TODO chgagnon
|
||||||
return [imageComponent, nameComponent, resourceTypeToDisplayName(r.instanceType), '-'/* loc.numVCores(r.vCores) */];
|
return [imageComponent, nameComponent, resourceTypeToDisplayName(r.instanceType), '-'/* loc.numVCores(r.vCores) */];
|
||||||
|
|||||||
@@ -98,7 +98,10 @@ export class PostgresConnectionStringsPage extends DashboardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getConnectionStrings(): KeyValue[] {
|
private getConnectionStrings(): KeyValue[] {
|
||||||
const endpoint: { ip: string, port: string } = this._postgresModel.endpoint;
|
const endpoint = this._postgresModel.endpoint;
|
||||||
|
if (!endpoint) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'ADO.NET', `Server=${endpoint.ip};Database=postgres;Port=${endpoint.port};User Id=postgres;Password={your_password_here};Ssl Mode=Require;`),
|
new InputKeyValue(this.modelView.modelBuilder, 'ADO.NET', `Server=${endpoint.ip};Database=postgres;Port=${endpoint.port};User Id=postgres;Password={your_password_here};Ssl Mode=Require;`),
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class PostgresDiagnoseAndSolveProblemsPage extends DashboardPage {
|
|||||||
troubleshootButton.onDidClick(() => {
|
troubleshootButton.onDidClick(() => {
|
||||||
process.env['POSTGRES_SERVER_NAMESPACE'] = this._postgresModel.config?.metadata.namespace;
|
process.env['POSTGRES_SERVER_NAMESPACE'] = this._postgresModel.config?.metadata.namespace;
|
||||||
process.env['POSTGRES_SERVER_NAME'] = this._postgresModel.info.name;
|
process.env['POSTGRES_SERVER_NAME'] = this._postgresModel.info.name;
|
||||||
// TODO set env POSTGRES_SERVER_VERSION
|
process.env['POSTGRES_SERVER_VERSION'] = this._postgresModel.engineVersion;
|
||||||
vscode.commands.executeCommand('bookTreeView.openBook', this._context.asAbsolutePath('notebooks/arcDataServices'), true, 'postgres/tsg100-troubleshoot-postgres');
|
vscode.commands.executeCommand('bookTreeView.openBook', this._context.asAbsolutePath('notebooks/arcDataServices'), true, 'postgres/tsg100-troubleshoot-postgres');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { DashboardPage } from '../../components/dashboardPage';
|
|||||||
import { ControllerModel } from '../../../models/controllerModel';
|
import { ControllerModel } from '../../../models/controllerModel';
|
||||||
import { PostgresModel } from '../../../models/postgresModel';
|
import { PostgresModel } from '../../../models/postgresModel';
|
||||||
import { promptAndConfirmPassword, promptForInstanceDeletion } from '../../../common/utils';
|
import { promptAndConfirmPassword, promptForInstanceDeletion } from '../../../common/utils';
|
||||||
|
import { ResourceType } from 'arc';
|
||||||
|
|
||||||
export class PostgresOverviewPage extends DashboardPage {
|
export class PostgresOverviewPage extends DashboardPage {
|
||||||
|
|
||||||
@@ -154,7 +155,13 @@ export class PostgresOverviewPage extends DashboardPage {
|
|||||||
try {
|
try {
|
||||||
const password = await promptAndConfirmPassword(input => !input ? loc.enterANonEmptyPassword : '');
|
const password = await promptAndConfirmPassword(input => !input ? loc.enterANonEmptyPassword : '');
|
||||||
if (password) {
|
if (password) {
|
||||||
// TODO: azdata arc postgres server edit --admin-password
|
await this._azdataApi.azdata.arc.postgres.server.edit(
|
||||||
|
this._postgresModel.info.name,
|
||||||
|
{
|
||||||
|
adminPassword: true,
|
||||||
|
noWait: true
|
||||||
|
},
|
||||||
|
{ 'AZDATA_PASSWORD': password });
|
||||||
vscode.window.showInformationMessage(loc.passwordReset);
|
vscode.window.showInformationMessage(loc.passwordReset);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -220,15 +227,13 @@ export class PostgresOverviewPage extends DashboardPage {
|
|||||||
|
|
||||||
this.disposables.push(
|
this.disposables.push(
|
||||||
openInAzurePortalButton.onDidClick(async () => {
|
openInAzurePortalButton.onDidClick(async () => {
|
||||||
/*
|
const azure = this._controllerModel.controllerConfig?.spec.settings.azure;
|
||||||
const r = this._controllerModel.getRegistration(ResourceType.postgresInstances, this._postgresModel.namespace, this._postgresModel.name);
|
if (azure) {
|
||||||
if (!r) {
|
|
||||||
vscode.window.showErrorMessage(loc.couldNotFindAzureResource(this._postgresModel.fullName));
|
|
||||||
} else {
|
|
||||||
vscode.env.openExternal(vscode.Uri.parse(
|
vscode.env.openExternal(vscode.Uri.parse(
|
||||||
`https://portal.azure.com/#resource/subscriptions/${r.subscriptionId}/resourceGroups/${r.resourceGroupName}/providers/Microsoft.AzureData/${ResourceType.postgresInstances}/${r.instanceName}`));
|
`https://portal.azure.com/#resource/subscriptions/${azure.subscription}/resourceGroups/${azure.resourceGroup}/providers/Microsoft.AzureData/${ResourceType.postgresInstances}/${this._postgresModel.info.name}`));
|
||||||
|
} else {
|
||||||
|
vscode.window.showErrorMessage(loc.couldNotFindControllerRegistration);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return this.modelView.modelBuilder.toolbarContainer().withToolbarItems([
|
return this.modelView.modelBuilder.toolbarContainer().withToolbarItems([
|
||||||
@@ -240,22 +245,18 @@ export class PostgresOverviewPage extends DashboardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getProperties(): azdata.PropertiesContainerItem[] {
|
private getProperties(): azdata.PropertiesContainerItem[] {
|
||||||
/*
|
const endpoint = this._postgresModel.endpoint;
|
||||||
const registration = this._controllerModel.getRegistration(ResourceType.postgresInstances, this._postgresModel.namespace, this._postgresModel.name);
|
|
||||||
const endpoint: { ip?: string, port?: number } = this._postgresModel.endpoint;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{ displayName: loc.name, value: this._postgresModel.name },
|
{ displayName: loc.name, value: this._postgresModel.info.name },
|
||||||
{ displayName: loc.coordinatorEndpoint, value: `postgresql://postgres@${endpoint.ip}:${endpoint.port}` },
|
{ displayName: loc.coordinatorEndpoint, value: endpoint ? `postgresql://postgres@${endpoint.ip}:${endpoint.port}` : '-' },
|
||||||
{ displayName: loc.status, value: this._postgresModel.service?.status?.state ?? '' },
|
{ displayName: loc.status, value: this._postgresModel.config?.status.state || '-' },
|
||||||
{ displayName: loc.postgresAdminUsername, value: 'postgres' },
|
{ displayName: loc.postgresAdminUsername, value: 'postgres' },
|
||||||
{ displayName: loc.dataController, value: this._controllerModel?.namespace ?? '' },
|
{ displayName: loc.dataController, value: this._controllerModel?.controllerConfig?.metadata.namespace || '-' },
|
||||||
{ displayName: loc.nodeConfiguration, value: this._postgresModel.configuration },
|
{ displayName: loc.nodeConfiguration, value: this._postgresModel.scaleConfiguration || '-' },
|
||||||
{ displayName: loc.subscriptionId, value: registration?.subscriptionId ?? '' },
|
{ displayName: loc.subscriptionId, value: this._controllerModel.controllerConfig?.spec.settings.azure.subscription ?? '' },
|
||||||
{ displayName: loc.postgresVersion, value: this._postgresModel.service?.spec?.engine?.version?.toString() ?? '' }
|
{ displayName: loc.postgresVersion, value: this._postgresModel.engineVersion ?? '-' }
|
||||||
];
|
];
|
||||||
*/
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getKibanaLink(): string {
|
private getKibanaLink(): string {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import * as vscode from 'vscode';
|
|||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as loc from '../../../localizedConstants';
|
import * as loc from '../../../localizedConstants';
|
||||||
import { IconPathHelper, cssStyles } from '../../../constants';
|
import { IconPathHelper, cssStyles } from '../../../constants';
|
||||||
import { KeyValueContainer, KeyValue } from '../../components/keyValueContainer';
|
import { KeyValueContainer, KeyValue, InputKeyValue, TextKeyValue } from '../../components/keyValueContainer';
|
||||||
import { DashboardPage } from '../../components/dashboardPage';
|
import { DashboardPage } from '../../components/dashboardPage';
|
||||||
import { ControllerModel } from '../../../models/controllerModel';
|
import { ControllerModel } from '../../../models/controllerModel';
|
||||||
import { PostgresModel } from '../../../models/postgresModel';
|
import { PostgresModel } from '../../../models/postgresModel';
|
||||||
@@ -91,24 +91,19 @@ export class PostgresPropertiesPage extends DashboardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getProperties(): KeyValue[] {
|
private getProperties(): KeyValue[] {
|
||||||
/*
|
const endpoint = this._postgresModel.endpoint;
|
||||||
const endpoint: { ip?: string, port?: number } = this._postgresModel.endpoint;
|
|
||||||
const connectionString = `postgresql://postgres@${endpoint.ip}:${endpoint.port}`;
|
|
||||||
const registration = this._controllerModel.getRegistration(ResourceType.postgresInstances, this._postgresModel.namespace, this._postgresModel.name);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
new InputKeyValue(this.modelView.modelBuilder, loc.coordinatorEndpoint, connectionString),
|
new InputKeyValue(this.modelView.modelBuilder, loc.coordinatorEndpoint, endpoint ? `postgresql://postgres@${endpoint.ip}:${endpoint.port}` : ''),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, loc.postgresAdminUsername, 'postgres'),
|
new InputKeyValue(this.modelView.modelBuilder, loc.postgresAdminUsername, 'postgres'),
|
||||||
new TextKeyValue(this.modelView.modelBuilder, loc.status, this._postgresModel.service?.status?.state ?? 'Unknown'),
|
new TextKeyValue(this.modelView.modelBuilder, loc.status, this._postgresModel.config?.status.state ?? loc.unknown),
|
||||||
// TODO: Make this a LinkKeyValue that opens the controller dashboard
|
// TODO: Make this a LinkKeyValue that opens the controller dashboard
|
||||||
new TextKeyValue(this.modelView.modelBuilder, loc.dataController, this._controllerModel.namespace ?? ''),
|
new TextKeyValue(this.modelView.modelBuilder, loc.dataController, this._controllerModel.controllerConfig?.metadata.namespace ?? ''),
|
||||||
new TextKeyValue(this.modelView.modelBuilder, loc.nodeConfiguration, this._postgresModel.configuration),
|
new TextKeyValue(this.modelView.modelBuilder, loc.nodeConfiguration, this._postgresModel.scaleConfiguration ?? ''),
|
||||||
new TextKeyValue(this.modelView.modelBuilder, loc.postgresVersion, this._postgresModel.service?.spec?.engine?.version?.toString() ?? ''),
|
new TextKeyValue(this.modelView.modelBuilder, loc.postgresVersion, this._postgresModel.engineVersion ?? ''),
|
||||||
new TextKeyValue(this.modelView.modelBuilder, loc.resourceGroup, registration?.resourceGroupName ?? ''),
|
new TextKeyValue(this.modelView.modelBuilder, loc.resourceGroup, this._controllerModel.controllerConfig?.spec.settings.azure.resourceGroup ?? ''),
|
||||||
new TextKeyValue(this.modelView.modelBuilder, loc.subscriptionId, registration?.subscriptionId ?? '')
|
new TextKeyValue(this.modelView.modelBuilder, loc.subscriptionId, this._controllerModel.controllerConfig?.spec.settings.azure.subscription ?? '')
|
||||||
];
|
];
|
||||||
*/
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleRegistrationsUpdated() {
|
private handleRegistrationsUpdated() {
|
||||||
|
|||||||
@@ -101,8 +101,9 @@ export class AzdataTool implements IAzdataTool {
|
|||||||
show: async (name: string) => {
|
show: async (name: string) => {
|
||||||
return this.executeCommand<azdataExt.PostgresServerShowResult>(['arc', 'postgres', 'server', 'show', '-n', name]);
|
return this.executeCommand<azdataExt.PostgresServerShowResult>(['arc', 'postgres', 'server', 'show', '-n', name]);
|
||||||
},
|
},
|
||||||
edit: async (args: {
|
edit: async (
|
||||||
name: string,
|
name: string,
|
||||||
|
args: {
|
||||||
adminPassword?: boolean,
|
adminPassword?: boolean,
|
||||||
coresLimit?: string,
|
coresLimit?: string,
|
||||||
coresRequest?: string,
|
coresRequest?: string,
|
||||||
@@ -114,8 +115,9 @@ export class AzdataTool implements IAzdataTool {
|
|||||||
port?: number,
|
port?: number,
|
||||||
replaceEngineSettings?: boolean,
|
replaceEngineSettings?: boolean,
|
||||||
workers?: number
|
workers?: number
|
||||||
}) => {
|
},
|
||||||
const argsArray = ['arc', 'postgres', 'server', 'edit', '-n', args.name];
|
additionalEnvVars?: { [key: string]: string }) => {
|
||||||
|
const argsArray = ['arc', 'postgres', 'server', 'edit', '-n', name];
|
||||||
if (args.adminPassword) { argsArray.push('--admin-password'); }
|
if (args.adminPassword) { argsArray.push('--admin-password'); }
|
||||||
if (args.coresLimit !== undefined) { argsArray.push('--cores-limit', args.coresLimit); }
|
if (args.coresLimit !== undefined) { argsArray.push('--cores-limit', args.coresLimit); }
|
||||||
if (args.coresRequest !== undefined) { argsArray.push('--cores-request', args.coresRequest); }
|
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.port !== undefined) { argsArray.push('--port', args.port.toString()); }
|
||||||
if (args.replaceEngineSettings) { argsArray.push('--replace-engine-settings'); }
|
if (args.replaceEngineSettings) { argsArray.push('--replace-engine-settings'); }
|
||||||
if (args.workers !== undefined) { argsArray.push('--workers', args.workers.toString()); }
|
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: '...' }
|
// ERROR: { stderr: '...' }
|
||||||
// so we also need to trim off the start that isn't a valid JSON blob
|
// 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;
|
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)
|
// 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.
|
// check if azdata still exists if it does then rethrow the original error if not then emit a new specific error.
|
||||||
try {
|
try {
|
||||||
await fs.promises.access(this._path);
|
await fs.promises.access(this._path);
|
||||||
//this.path exists
|
//this.path exists
|
||||||
throw err; // rethrow the error
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// this.path does not exist
|
// this.path does not exist
|
||||||
await vscode.commands.executeCommand('setContext', azdataFound, false);
|
await vscode.commands.executeCommand('setContext', azdataFound, false);
|
||||||
throw (loc.noAzdata);
|
throw (loc.noAzdata);
|
||||||
}
|
}
|
||||||
|
throw err; // rethrow the original error
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<azdata
|
|||||||
postgres: {
|
postgres: {
|
||||||
server: {
|
server: {
|
||||||
delete: async (name: string) => {
|
delete: async (name: string) => {
|
||||||
await throwIfNoAzdataOrEulaNotAccepted();
|
throwIfNoAzdataOrEulaNotAccepted();
|
||||||
return localAzdata!.arc.postgres.server.delete(name);
|
return localAzdata!.arc.postgres.server.delete(name);
|
||||||
},
|
},
|
||||||
list: async () => {
|
list: async () => {
|
||||||
@@ -97,8 +97,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<azdata
|
|||||||
throwIfNoAzdataOrEulaNotAccepted();
|
throwIfNoAzdataOrEulaNotAccepted();
|
||||||
return localAzdata!.arc.postgres.server.show(name);
|
return localAzdata!.arc.postgres.server.show(name);
|
||||||
},
|
},
|
||||||
edit: async (args: {
|
edit: async (
|
||||||
name: string,
|
name: string,
|
||||||
|
args: {
|
||||||
adminPassword?: boolean,
|
adminPassword?: boolean,
|
||||||
coresLimit?: string,
|
coresLimit?: string,
|
||||||
coresRequest?: string,
|
coresRequest?: string,
|
||||||
@@ -110,9 +111,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<azdata
|
|||||||
port?: number,
|
port?: number,
|
||||||
replaceEngineSettings?: boolean,
|
replaceEngineSettings?: boolean,
|
||||||
workers?: number
|
workers?: number
|
||||||
}) => {
|
},
|
||||||
await throwIfNoAzdataOrEulaNotAccepted();
|
additionalEnvVars?: { [key: string]: string }) => {
|
||||||
return localAzdata!.arc.postgres.server.edit(args);
|
throwIfNoAzdataOrEulaNotAccepted();
|
||||||
|
return localAzdata!.arc.postgres.server.edit(name, args, additionalEnvVars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ declare module 'azdata-ext' {
|
|||||||
name: string // "citus"
|
name: string // "citus"
|
||||||
}[],
|
}[],
|
||||||
settings: {
|
settings: {
|
||||||
default: { } // { "max_connections": "101", "work_mem": "4MB" }
|
default: { [key: string]: string } // { "max_connections": "101", "work_mem": "4MB" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scale: {
|
scale: {
|
||||||
@@ -233,8 +233,9 @@ declare module 'azdata-ext' {
|
|||||||
delete(name: string): Promise<AzdataOutput<void>>,
|
delete(name: string): Promise<AzdataOutput<void>>,
|
||||||
list(): Promise<AzdataOutput<PostgresServerListResult[]>>,
|
list(): Promise<AzdataOutput<PostgresServerListResult[]>>,
|
||||||
show(name: string): Promise<AzdataOutput<PostgresServerShowResult>>,
|
show(name: string): Promise<AzdataOutput<PostgresServerShowResult>>,
|
||||||
edit(args: {
|
edit(
|
||||||
name: string,
|
name: string,
|
||||||
|
args: {
|
||||||
adminPassword?: boolean,
|
adminPassword?: boolean,
|
||||||
coresLimit?: string,
|
coresLimit?: string,
|
||||||
coresRequest?: string,
|
coresRequest?: string,
|
||||||
@@ -246,7 +247,8 @@ declare module 'azdata-ext' {
|
|||||||
port?: number,
|
port?: number,
|
||||||
replaceEngineSettings?: boolean,
|
replaceEngineSettings?: boolean,
|
||||||
workers?: number
|
workers?: number
|
||||||
}): Promise<AzdataOutput<void>>
|
},
|
||||||
|
additionalEnvVars?: { [key: string]: string }): Promise<AzdataOutput<void>>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sql: {
|
sql: {
|
||||||
|
|||||||
Reference in New Issue
Block a user