mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-09 17:52:34 -05:00
Port updates for removing EULA acceptance checkbox from Arc deployments (#12409)
* controller dropdown field to SQL MIAA and Postgres deployment. (#12217) * saving first draft * throw if no controllers * cleanup * bug fixes * bug fixes and caching controller access * pr comments and bug fixes. * fixes * fixes * comment fix * remove debug prints * comment fixes * remove debug logs * inputValueTransformer returns string|Promise * PR feedback * pr fixes * remove _ from protected fields * anonymous to full methods * small fixes (cherry picked from commit9cf80113fc) * fix option sources (#12387) (cherry picked from commitfca8b85a72) * Remove azdata eula acceptance from arc deployments (#12292) * saving to switch tasks * activate to exports in extApi * working version - cleanup pending * improve messages * apply pr feedback from a different review * remove unneeded strings * redo apiService * remove async from getVersionFromOutput * remove _ prefix from protected fields * error message fix * throw specif errors from azdata extension * arrow methods to regular methods * pr feedback * expand azdata extension api * pr feedback * remove unused var * pr feedback (cherry picked from commitba44a2f02e) Co-authored-by: Arvind Ranasaria <ranasaria@outlook.com>
This commit is contained in:
@@ -3,28 +3,22 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as arc from 'arc';
|
||||
import * as azdataExt from 'azdata-ext';
|
||||
import * as azurecore from 'azurecore';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export interface IApiService {
|
||||
getAzurecoreApi(): Promise<azurecore.IExtension>;
|
||||
readonly azurecoreApi: azurecore.IExtension;
|
||||
readonly azdataApi: azdataExt.IExtension;
|
||||
readonly arcApi: arc.IExtension;
|
||||
}
|
||||
|
||||
class ApiService implements IApiService {
|
||||
|
||||
private azurecoreApi: azurecore.IExtension | undefined;
|
||||
|
||||
constructor() { }
|
||||
|
||||
public async getAzurecoreApi(): Promise<azurecore.IExtension> {
|
||||
if (!this.azurecoreApi) {
|
||||
this.azurecoreApi = <azurecore.IExtension>(await vscode.extensions.getExtension(azurecore.extension.name)?.activate());
|
||||
if (!this.azurecoreApi) {
|
||||
throw new Error('Unable to retrieve azurecore API');
|
||||
}
|
||||
}
|
||||
return this.azurecoreApi;
|
||||
}
|
||||
public get azurecoreApi() { return vscode.extensions.getExtension(azurecore.extension.name)?.exports; }
|
||||
public get azdataApi() { return vscode.extensions.getExtension(azdataExt.extension.name)?.exports; }
|
||||
public get arcApi() { return vscode.extensions.getExtension(arc.extension.name)?.exports; }
|
||||
}
|
||||
|
||||
export const apiService: IApiService = new ApiService();
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as arc from 'arc';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export class ArcService {
|
||||
private _arcApi: arc.IExtension;
|
||||
constructor() {
|
||||
this._arcApi = vscode.extensions.getExtension(arc.extension.name)?.exports;
|
||||
}
|
||||
|
||||
public async getRegisteredDataControllers(): Promise<arc.ControllerInfo[]> {
|
||||
return await this._arcApi.getRegisteredDataControllers();
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,11 @@ import { SemVer } from 'semver';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { AzdataInstallLocationKey, DeploymentConfigurationKey } from '../../constants';
|
||||
import { Command, OsDistribution, ToolType } from '../../interfaces';
|
||||
import { Command, OsDistribution, ToolStatus, ToolType } from '../../interfaces';
|
||||
import { apiService } from '../apiService';
|
||||
import { IPlatformService } from '../platformService';
|
||||
import { dependencyType, ToolBase } from './toolBase';
|
||||
import { SemVerProxy } from './SemVerProxy';
|
||||
import * as loc from '../../localizedConstants';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
export const AzdataToolName = 'azdata';
|
||||
@@ -44,25 +45,57 @@ export class AzdataTool extends ToolBase {
|
||||
return 'https://docs.microsoft.com/sql/big-data-cluster/deploy-install-azdata';
|
||||
}
|
||||
|
||||
public validateEula(): boolean {
|
||||
if (apiService.azdataApi.isEulaAccepted()) {
|
||||
return true;
|
||||
} else {
|
||||
this.setStatusDescription(loc.azdataEulaNotAccepted);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* unused */
|
||||
protected get versionCommand(): Command {
|
||||
return {
|
||||
command: 'azdata -v'
|
||||
command: ''
|
||||
};
|
||||
}
|
||||
|
||||
/* unused */
|
||||
protected get discoveryCommand(): Command {
|
||||
return {
|
||||
command: this.discoveryCommandString('azdata')
|
||||
command: ''
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* updates the version and status for the tool.
|
||||
*/
|
||||
protected async updateVersionAndStatus(): Promise<void> {
|
||||
this.setStatusDescription('');
|
||||
await this.addInstallationSearchPathsToSystemPath();
|
||||
|
||||
const commandOutput = await apiService.azdataApi.azdata.version();
|
||||
this.version = apiService.azdataApi.azdata.getSemVersion();
|
||||
if (this.version) {
|
||||
if (this.autoInstallSupported) {
|
||||
// set the installationPath
|
||||
this.setInstallationPathOrAdditionalInformation(apiService.azdataApi.azdata.getPath());
|
||||
}
|
||||
this.setStatus(ToolStatus.Installed);
|
||||
}
|
||||
else {
|
||||
this.setInstallationPathOrAdditionalInformation(localize('deployCluster.GetToolVersionErrorInformation', "Error retrieving version information. See output channel '{0}' for more details", this.outputChannelName));
|
||||
this.setStatusDescription(localize('deployCluster.GetToolVersionError', "Error retrieving version information.{0}Invalid output received, get version command output: '{1}' ", EOL, commandOutput.stderr.join(EOL)));
|
||||
this.setStatus(ToolStatus.NotInstalled);
|
||||
}
|
||||
}
|
||||
|
||||
protected getVersionFromOutput(output: string): SemVer | undefined {
|
||||
let version: SemVer | undefined = undefined;
|
||||
if (output && output.split(EOL).length > 0) {
|
||||
version = new SemVerProxy(output.split(EOL)[0].replace(/ /g, ''));
|
||||
}
|
||||
return version;
|
||||
return apiService.azdataApi.azdata.getSemVersion();
|
||||
|
||||
}
|
||||
|
||||
protected async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
|
||||
@@ -58,6 +58,8 @@ export abstract class ToolBase implements ITool {
|
||||
|
||||
protected abstract readonly versionCommand: Command;
|
||||
|
||||
public validateEula(): boolean { return true; }
|
||||
|
||||
public get dependencyMessages(): string[] {
|
||||
return (this.dependenciesByOsType.get(this.osDistribution) || []).map((msgType: dependencyType) => messageByDependencyType.get(msgType)!);
|
||||
}
|
||||
@@ -126,10 +128,18 @@ export abstract class ToolBase implements ITool {
|
||||
return this._statusDescription;
|
||||
}
|
||||
|
||||
protected setStatusDescription(value: string | undefined): void {
|
||||
this._statusDescription = value;
|
||||
}
|
||||
|
||||
public get installationPathOrAdditionalInformation(): string | undefined {
|
||||
return this._installationPathOrAdditionalInformation;
|
||||
}
|
||||
|
||||
protected setInstallationPathOrAdditionalInformation(value: string | undefined) {
|
||||
this._installationPathOrAdditionalInformation = value;
|
||||
}
|
||||
|
||||
protected get installationCommands(): Command[] | undefined {
|
||||
return this.allInstallationCommands.get(this.osDistribution);
|
||||
}
|
||||
@@ -250,7 +260,7 @@ export abstract class ToolBase implements ITool {
|
||||
/**
|
||||
* updates the version and status for the tool.
|
||||
*/
|
||||
private async updateVersionAndStatus(): Promise<void> {
|
||||
protected async updateVersionAndStatus(): Promise<void> {
|
||||
this._statusDescription = '';
|
||||
await this.addInstallationSearchPathsToSystemPath();
|
||||
const commandOutput = await this.platformService.runCommand(
|
||||
@@ -306,7 +316,7 @@ export abstract class ToolBase implements ITool {
|
||||
}
|
||||
|
||||
isSameOrNewerThan(version?: string): boolean {
|
||||
return !version || (this._version ? SemVerCompare(this._version, version) >= 0 : false);
|
||||
return !version || (this._version ? SemVerCompare(this._version.raw, version) >= 0 : false);
|
||||
}
|
||||
|
||||
private _pendingVersionAndStatusUpdate!: Promise<void>;
|
||||
|
||||
Reference in New Issue
Block a user