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
This commit is contained in:
Arvind Ranasaria
2020-09-17 11:20:32 -07:00
committed by GitHub
parent 945e04ed92
commit ba44a2f02e
17 changed files with 181 additions and 114 deletions

View File

@@ -3,18 +3,21 @@
* 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';
import * as arc from 'arc';
export interface IApiService {
readonly azurecoreApi: azurecore.IExtension;
readonly azdataApi: azdataExt.IExtension;
readonly arcApi: arc.IExtension;
}
class ApiService implements IApiService {
constructor() { }
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; }
}

View File

@@ -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:

View File

@@ -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>;