mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add external miaa endpoint property (#11940)
This commit is contained in:
@@ -209,3 +209,18 @@ export function parseInstanceName(instanceName: string | undefined): string {
|
|||||||
}
|
}
|
||||||
return instanceName;
|
return instanceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses an address into its separate ip and port values. Address must be in the form <ip>:<port>
|
||||||
|
* @param address The address to parse
|
||||||
|
*/
|
||||||
|
export function parseIpAndPort(address: string): { ip: string, port: string } {
|
||||||
|
const sections = address.split(':');
|
||||||
|
if (sections.length !== 2) {
|
||||||
|
throw new Error(`Invalid address format for ${address}. Address must be in the form <ip>:<port>`);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
ip: sections[0],
|
||||||
|
port: sections[1]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as should from 'should';
|
import * as should from 'should';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
import { resourceTypeToDisplayName, parseEndpoint, parseInstanceName, getAzurecoreApi, getResourceTypeIcon, getConnectionModeDisplayText, getDatabaseStateDisplayText, promptForResourceDeletion, promptAndConfirmPassword, getErrorMessage } from '../../common/utils';
|
import { resourceTypeToDisplayName, parseEndpoint, parseInstanceName, getAzurecoreApi, getResourceTypeIcon, getConnectionModeDisplayText, getDatabaseStateDisplayText, promptForResourceDeletion, promptAndConfirmPassword, getErrorMessage, parseIpAndPort } from '../../common/utils';
|
||||||
|
|
||||||
import * as loc from '../../localizedConstants';
|
import * as loc from '../../localizedConstants';
|
||||||
import { ResourceType, IconPathHelper, ConnectionMode as ConnectionMode } from '../../constants';
|
import { ResourceType, IconPathHelper, ConnectionMode as ConnectionMode } from '../../constants';
|
||||||
@@ -274,3 +274,16 @@ describe('parseInstanceName Method Tests', function () {
|
|||||||
should(() => parseInstanceName('Some_Invalid_Name')).throwError();
|
should(() => parseInstanceName('Some_Invalid_Name')).throwError();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('parseIpAndPort', function (): void {
|
||||||
|
it('Valid address', function (): void {
|
||||||
|
const ip = '127.0.0.1';
|
||||||
|
const port = '80';
|
||||||
|
should(parseIpAndPort(`${ip}:${port}`)).deepEqual({ ip: ip, port: port });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('invalid address - no port', function (): void {
|
||||||
|
const ip = '127.0.0.1';
|
||||||
|
should(() => parseIpAndPort(ip)).throwError();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -6,15 +6,17 @@
|
|||||||
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, MultilineInputKeyValue } from '../../components/keyValueContainer';
|
||||||
import { DashboardPage } from '../../components/dashboardPage';
|
import { DashboardPage } from '../../components/dashboardPage';
|
||||||
import { ControllerModel } from '../../../models/controllerModel';
|
import { ControllerModel } from '../../../models/controllerModel';
|
||||||
|
import { MiaaModel } from '../../../models/miaaModel';
|
||||||
|
import { parseIpAndPort } from '../../../common/utils';
|
||||||
|
|
||||||
export class MiaaConnectionStringsPage extends DashboardPage {
|
export class MiaaConnectionStringsPage extends DashboardPage {
|
||||||
|
|
||||||
private _keyValueContainer!: KeyValueContainer;
|
private _keyValueContainer!: KeyValueContainer;
|
||||||
|
|
||||||
constructor(modelView: azdata.ModelView, private _controllerModel: ControllerModel) {
|
constructor(modelView: azdata.ModelView, private _controllerModel: ControllerModel, private _miaaModel: MiaaModel) {
|
||||||
super(modelView);
|
super(modelView);
|
||||||
this.disposables.push(this._controllerModel.onRegistrationsUpdated(_ =>
|
this.disposables.push(this._controllerModel.onRegistrationsUpdated(_ =>
|
||||||
this.eventuallyRunOnInitialized(() => this.updateConnectionStrings())));
|
this.eventuallyRunOnInitialized(() => this.updateConnectionStrings())));
|
||||||
@@ -63,32 +65,28 @@ export class MiaaConnectionStringsPage extends DashboardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getConnectionStrings(): KeyValue[] {
|
private getConnectionStrings(): KeyValue[] {
|
||||||
/*
|
const config = this._miaaModel.config;
|
||||||
const instanceRegistration = this._controllerModel.getRegistration(ResourceType.sqlManagedInstances, this._miaaModel.info.namespace, this._miaaModel.info.name);
|
if (!config?.status.externalEndpoint) {
|
||||||
if (!instanceRegistration) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ip = instanceRegistration.externalIp;
|
const externalEndpoint = parseIpAndPort(config.status.externalEndpoint);
|
||||||
const port = instanceRegistration.externalPort;
|
|
||||||
const username = this._miaaModel.username;
|
const username = this._miaaModel.username;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'ADO.NET', `Server=tcp:${ip},${port};Persist Security Info=False;User ID=${username};Password={your_password_here};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;`),
|
new InputKeyValue(this.modelView.modelBuilder, 'ADO.NET', `Server=tcp:${externalEndpoint.ip},${externalEndpoint.port};Persist Security Info=False;User ID=${username};Password={your_password_here};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;`),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'C++ (libpq)', `host=${ip} port=${port} user=${username} password={your_password_here} sslmode=require`),
|
new InputKeyValue(this.modelView.modelBuilder, 'C++ (libpq)', `host=${externalEndpoint.ip} port=${externalEndpoint.port} user=${username} password={your_password_here} sslmode=require`),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'JDBC', `jdbc:sqlserver://${ip}:${port};user=${username};password={your_password_here};encrypt=true;trustServerCertificate=false;loginTimeout=30;`),
|
new InputKeyValue(this.modelView.modelBuilder, 'JDBC', `jdbc:sqlserver://${externalEndpoint.ip}:${externalEndpoint.port};user=${username};password={your_password_here};encrypt=true;trustServerCertificate=false;loginTimeout=30;`),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'Node.js', `host=${ip} port=${port} dbname=master user=${username} password={your_password_here} sslmode=require`),
|
new InputKeyValue(this.modelView.modelBuilder, 'Node.js', `host=${externalEndpoint.ip} port=${externalEndpoint.port} dbname=master user=${username} password={your_password_here} sslmode=require`),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'ODBC', `Driver={ODBC Driver 13 for SQL Server};Server=${ip},${port};Uid=${username};Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;`),
|
new InputKeyValue(this.modelView.modelBuilder, 'ODBC', `Driver={ODBC Driver 13 for SQL Server};Server=${externalEndpoint.ip},${externalEndpoint.port};Uid=${username};Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;`),
|
||||||
new MultilineInputKeyValue(this.modelView.modelBuilder, 'PHP',
|
new MultilineInputKeyValue(this.modelView.modelBuilder, 'PHP',
|
||||||
`$connectionInfo = array("UID" => "${username}", "pwd" => "{your_password_here}", "LoginTimeout" => 30, "Encrypt" => 1, "TrustServerCertificate" => 0);
|
`$connectionInfo = array("UID" => "${username}", "pwd" => "{your_password_here}", "LoginTimeout" => 30, "Encrypt" => 1, "TrustServerCertificate" => 0);
|
||||||
$serverName = "${ip},${port}";
|
$serverName = "${externalEndpoint.ip},${externalEndpoint.port}";
|
||||||
$conn = sqlsrv_connect($serverName, $connectionInfo);`),
|
$conn = sqlsrv_connect($serverName, $connectionInfo);`),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'Python', `dbname='master' user='${username}' host='${ip}' password='{your_password_here}' port='${port}' sslmode='true'`),
|
new InputKeyValue(this.modelView.modelBuilder, 'Python', `dbname='master' user='${username}' host='${externalEndpoint.ip}' password='{your_password_here}' port='${externalEndpoint.port}' sslmode='true'`),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'Ruby', `host=${ip}; user=${username} password={your_password_here} port=${port} sslmode=require`),
|
new InputKeyValue(this.modelView.modelBuilder, 'Ruby', `host=${externalEndpoint.ip}; user=${username} password={your_password_here} port=${externalEndpoint.port} sslmode=require`),
|
||||||
new InputKeyValue(this.modelView.modelBuilder, 'Web App', `Database=master; Data Source=${ip}; User Id=${username}; Password={your_password_here}`)
|
new InputKeyValue(this.modelView.modelBuilder, 'Web App', `Database=master; Data Source=${externalEndpoint.ip}; User Id=${username}; Password={your_password_here}`)
|
||||||
];
|
];
|
||||||
*/
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateConnectionStrings(): void {
|
private updateConnectionStrings(): void {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class MiaaDashboard extends Dashboard {
|
|||||||
|
|
||||||
protected async registerTabs(modelView: azdata.ModelView): Promise<(azdata.DashboardTab | azdata.DashboardTabGroup)[]> {
|
protected async registerTabs(modelView: azdata.ModelView): Promise<(azdata.DashboardTab | azdata.DashboardTabGroup)[]> {
|
||||||
const overviewPage = new MiaaDashboardOverviewPage(modelView, this._controllerModel, this._miaaModel);
|
const overviewPage = new MiaaDashboardOverviewPage(modelView, this._controllerModel, this._miaaModel);
|
||||||
const connectionStringsPage = new MiaaConnectionStringsPage(modelView, this._controllerModel);
|
const connectionStringsPage = new MiaaConnectionStringsPage(modelView, this._controllerModel, this._miaaModel);
|
||||||
return [
|
return [
|
||||||
overviewPage.tab,
|
overviewPage.tab,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -257,7 +257,6 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
|||||||
this._instanceProperties.region = reg.region || '-';
|
this._instanceProperties.region = reg.region || '-';
|
||||||
this._instanceProperties.subscriptionId = reg.subscriptionId || '-';
|
this._instanceProperties.subscriptionId = reg.subscriptionId || '-';
|
||||||
this._instanceProperties.vCores = reg.vCores || '';
|
this._instanceProperties.vCores = reg.vCores || '';
|
||||||
this._instanceProperties.host = reg.externalEndpoint || '-';
|
|
||||||
this.refreshDisplayedProperties();
|
this.refreshDisplayedProperties();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -265,6 +264,7 @@ export class MiaaDashboardOverviewPage extends DashboardPage {
|
|||||||
|
|
||||||
private handleMiaaConfigUpdated(): void {
|
private handleMiaaConfigUpdated(): void {
|
||||||
this._instanceProperties.status = this._miaaModel.config?.status.state || '-';
|
this._instanceProperties.status = this._miaaModel.config?.status.state || '-';
|
||||||
|
this._instanceProperties.host = this._miaaModel.config?.status.externalEndpoint || '-';
|
||||||
this.refreshDisplayedProperties();
|
this.refreshDisplayedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ declare module 'azdata-ext' {
|
|||||||
uid: string // "cea737aa-3f82-4f6a-9bed-2b51c2c33dff"
|
uid: string // "cea737aa-3f82-4f6a-9bed-2b51c2c33dff"
|
||||||
},
|
},
|
||||||
spec: {
|
spec: {
|
||||||
|
service: {
|
||||||
|
type: string // "NodePort"
|
||||||
|
}
|
||||||
storage: {
|
storage: {
|
||||||
data: {
|
data: {
|
||||||
className: string, // "local-storage"
|
className: string, // "local-storage"
|
||||||
@@ -125,7 +128,8 @@ declare module 'azdata-ext' {
|
|||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
readyReplicas: string, // "1/1"
|
readyReplicas: string, // "1/1"
|
||||||
state: string // "Ready"
|
state: string, // "Ready"
|
||||||
|
externalEndpoint?: string // "10.91.86.39:32718"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user