mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
* Changed azdata to az in azcli extension and resource-deployment, and some arc. Removed user, pass, url from controller connect blade. Commented out tests. Ported over work from old branch. * Changed unit tests, all unit tests passing. Changed parameters to new ones, fixed some Controller Connect issues. * Connect data controller and create dc working. * Changed az back to azdata in necessary places in resource-deployment. * Changed notebook values and added namespace to some params. * Added some changes from PR to this branch * Changed azdata.ts to az.ts and changed subscription parameter * Brought over changes from azcli PR into this branch. * added endpoint, username, password to getIsPassword * Changed notebooks to use proper az params, hard coded in some values to verify it is working, removed some variableNames from package.json. * Changed -sc to --storage-class in notebook * Added namespace to SQL deploy, deleted dc create in api * Deleted more dc create code and uncommented findAz() with unfinished work on Do Not Ask Again. * Removed (preview) from extensions/arc and extensions/azcli excluding preview:true in package.json * Commented out install/update prompts until DoNotAskAgain is implemented * Fixed bugs: JSON Output errors are now being caught, --infrastructure now has a required UI component with dropdown options, config page loads properly, SQL create flags use full names instead of shortnames. * Adds validation to pg extensions and bug fixes (#16486) * Extensions * Server parameters * Change locaiton of postgres extensions, pr fixes * Change location of list * List spacing * Commented out Don't Ask Again prompt implementation. * Uncommented header of a test file. * Added Azure CLI arcdata extension to Prerequisites * Reverted package.json and yarn.lock * Took away casting of stderr and stdout in executeCommand. * Deleted override function for initializeFields in connectControllerDialog.ts * Removed fakeAzApi for testing and added back in (Preview) * Removed en-us from python notebook links. * Deleted azdata tool from tool tests in resource-deployment * Deleted another instance of azdata in tool test * Add back in azdata tooltype * Remove en-us * Replaced AzdataTool in typings * Reverting adding azdata tool back in * Changed Azdata to AzdataToolOld * Added back azdata tool type * Added AzdataToolOld to tool types * fix test Co-authored-by: Candice Ye <canye@microsoft.com> Co-authored-by: nasc17 <nasc@microsoft.com> Co-authored-by: nasc17 <69922333+nasc17@users.noreply.github.com> Co-authored-by: chgagnon <chgagnon@microsoft.com>
157 lines
5.4 KiB
TypeScript
157 lines
5.4 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { ControllerInfo, ResourceType } from 'arc';
|
|
import * as azExt from 'az-ext';
|
|
import * as vscode from 'vscode';
|
|
import * as loc from '../localizedConstants';
|
|
import { AzureArcTreeDataProvider } from '../ui/tree/azureArcTreeDataProvider';
|
|
|
|
export type Registration = {
|
|
instanceName: string,
|
|
state: string,
|
|
instanceType: ResourceType,
|
|
};
|
|
|
|
export class ControllerModel {
|
|
private readonly _azApi: azExt.IExtension;
|
|
private _endpoints: azExt.DcEndpointListResult[] = [];
|
|
private _registrations: Registration[] = [];
|
|
private _controllerConfig: azExt.DcConfigShowResult | undefined = undefined;
|
|
|
|
private readonly _onConfigUpdated = new vscode.EventEmitter<azExt.DcConfigShowResult | undefined>();
|
|
private readonly _onEndpointsUpdated = new vscode.EventEmitter<azExt.DcEndpointListResult[]>();
|
|
private readonly _onRegistrationsUpdated = new vscode.EventEmitter<Registration[]>();
|
|
private readonly _onInfoUpdated = new vscode.EventEmitter<ControllerInfo>();
|
|
|
|
public onConfigUpdated = this._onConfigUpdated.event;
|
|
public onEndpointsUpdated = this._onEndpointsUpdated.event;
|
|
public onRegistrationsUpdated = this._onRegistrationsUpdated.event;
|
|
public onInfoUpdated = this._onInfoUpdated.event;
|
|
|
|
public configLastUpdated?: Date;
|
|
public endpointsLastUpdated?: Date;
|
|
public registrationsLastUpdated?: Date;
|
|
|
|
constructor(public treeDataProvider: AzureArcTreeDataProvider, private _info: ControllerInfo) {
|
|
this._azApi = <azExt.IExtension>vscode.extensions.getExtension(azExt.extension.name)?.exports;
|
|
}
|
|
|
|
public get info(): ControllerInfo {
|
|
return this._info;
|
|
}
|
|
|
|
public set info(value: ControllerInfo) {
|
|
this._info = value;
|
|
this._onInfoUpdated.fire(this._info);
|
|
}
|
|
|
|
public get azAdditionalEnvVars(): azExt.AdditionalEnvVars {
|
|
return {
|
|
'KUBECONFIG': this.info.kubeConfigFilePath,
|
|
'KUBECTL_CONTEXT': this.info.kubeClusterContext
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Refreshes the Tree Node for this model. This will also result in the model being refreshed.
|
|
*/
|
|
public async refreshTreeNode(): Promise<void> {
|
|
const node = this.treeDataProvider.getControllerNode(this);
|
|
if (node) {
|
|
this.treeDataProvider.refreshNode(node);
|
|
} else {
|
|
await this.refresh(false, this.info.namespace);
|
|
}
|
|
}
|
|
public async refresh(showErrors: boolean = true, namespace: string): Promise<void> {
|
|
const newRegistrations: Registration[] = [];
|
|
await Promise.all([
|
|
this._azApi.az.arcdata.dc.config.show(namespace, this.azAdditionalEnvVars).then(result => {
|
|
this._controllerConfig = result.stdout;
|
|
this.configLastUpdated = new Date();
|
|
this._onConfigUpdated.fire(this._controllerConfig);
|
|
}).catch(err => {
|
|
// If an error occurs show a message so the user knows something failed but still
|
|
// fire the event so callers hooking into this can handle the error (e.g. so dashboards don't show the
|
|
// loading icon forever)
|
|
if (showErrors) {
|
|
vscode.window.showErrorMessage(loc.fetchConfigFailed(this.info.name, err));
|
|
}
|
|
this._onConfigUpdated.fire(this._controllerConfig);
|
|
throw err;
|
|
}),
|
|
this._azApi.az.arcdata.dc.endpoint.list(namespace, this.azAdditionalEnvVars).then(result => {
|
|
this._endpoints = result.stdout;
|
|
this.endpointsLastUpdated = new Date();
|
|
this._onEndpointsUpdated.fire(this._endpoints);
|
|
}).catch(err => {
|
|
// If an error occurs show a message so the user knows something failed but still
|
|
// fire the event so callers can know to update (e.g. so dashboards don't show the
|
|
// loading icon forever)
|
|
if (showErrors) {
|
|
vscode.window.showErrorMessage(loc.fetchEndpointsFailed(this.info.name, err));
|
|
}
|
|
this._onEndpointsUpdated.fire(this._endpoints);
|
|
throw err;
|
|
}),
|
|
Promise.all([
|
|
this._azApi.az.postgres.arcserver.list(namespace, this.azAdditionalEnvVars).then(result => {
|
|
newRegistrations.push(...result.stdout.map(r => {
|
|
return {
|
|
instanceName: r.name,
|
|
state: r.state,
|
|
instanceType: ResourceType.postgresInstances
|
|
};
|
|
}));
|
|
}),
|
|
this._azApi.az.sql.miarc.list(namespace, this.azAdditionalEnvVars).then(result => {
|
|
newRegistrations.push(...result.stdout.map(r => {
|
|
return {
|
|
instanceName: r.name,
|
|
state: r.state,
|
|
instanceType: ResourceType.sqlManagedInstances
|
|
};
|
|
}));
|
|
|
|
})
|
|
]).then(() => {
|
|
this._registrations = newRegistrations;
|
|
this.registrationsLastUpdated = new Date();
|
|
this._onRegistrationsUpdated.fire(this._registrations);
|
|
})
|
|
]);
|
|
}
|
|
|
|
public get endpoints(): azExt.DcEndpointListResult[] {
|
|
return this._endpoints;
|
|
}
|
|
|
|
public getEndpoint(name: string): azExt.DcEndpointListResult | undefined {
|
|
return this._endpoints.find(e => e.name === name);
|
|
}
|
|
|
|
public get registrations(): Registration[] {
|
|
return this._registrations;
|
|
}
|
|
|
|
public get controllerConfig(): azExt.DcConfigShowResult | undefined {
|
|
return this._controllerConfig;
|
|
}
|
|
|
|
public getRegistration(type: ResourceType, name: string): Registration | undefined {
|
|
return this._registrations.find(r => {
|
|
return r.instanceType === type && r.instanceName === name;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* property to for use a display label for this controller
|
|
*/
|
|
public get label(): string {
|
|
return `${this.info.name}`;
|
|
}
|
|
}
|