Feat/tool install master merge back to master (#7819)

* add install tools button (#7454)

* add install tools button

* address comments

* remove description for install tools hint message

* First working version of AutoDeployment of tools (#7647)

First working version of AutoDeployment of tools.

This pull request adds feature to install the tools needed for doing BDC/TINA deployments.

This has been tested so far only on win32 and testing on other platforms is in progress.

* removing TODO and redundant code

* Not localizing azuredatastudio product name

* convert methods returning Promises to async-await

* changing from null to undefined

* Localize all the command labels

* using existing sudo-prompt typings

* progres/error status in ModalDialogue && PR fixes

* review feedback to change warning to information

* revert settings.json changes

* fix resource-Deployment Extension Unit Test

* ensuring platform service's working directory

* incorporate review feedback

* review feedback

* addressing PR feedback

* PR fixes

* PR Feedback

* remove debug logs

* disable UI deployment containers when installing

* addding data type to stdout/stderr messaging

* remove commented code

* revert accidental change

* addressing review feedback

* fix failed install with zero exit code

* fixing bug due to typo

* fixes for linux

* Misc fixes during mac testing

* PR fixes
This commit is contained in:
Arvind Ranasaria
2019-10-18 23:17:21 -07:00
committed by GitHub
parent a2f105a913
commit 4dd6db57ee
18 changed files with 893 additions and 141 deletions

View File

@@ -2,15 +2,16 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ToolType } from '../../interfaces';
import * as nls from 'vscode-nls';
import { SemVer } from 'semver';
import { EOL } from 'os';
import * as path from 'path';
import { SemVer } from 'semver';
import * as nls from 'vscode-nls';
import { Command, OsType, ToolType } from '../../interfaces';
import { IPlatformService } from '../platformService';
import { ToolBase } from './toolBase';
const localize = nls.loadMessageBundle();
const installationRoot = '~/.local/bin';
export class AzdataTool extends ToolBase {
constructor(platformService: IPlatformService) {
@@ -37,8 +38,10 @@ export class AzdataTool extends ToolBase {
return 'https://docs.microsoft.com/sql/big-data-cluster/deploy-install-azdata';
}
protected get versionCommand(): string {
return 'azdata -v';
protected get versionCommand(): Command {
return {
command: 'azdata -v'
};
}
protected getVersionFromOutput(output: string): SemVer | undefined {
@@ -48,4 +51,79 @@ export class AzdataTool extends ToolBase {
}
return version;
}
get autoInstallSupported(): boolean {
return true;
}
protected async getInstallationPath(): Promise<string | undefined> {
switch (this.osType) {
case OsType.linux:
return installationRoot;
default:
const azdataCliInstallLocation = await this.getPip3InstallLocation('azdata-cli');
return azdataCliInstallLocation && path.join(azdataCliInstallLocation, '..', 'Scripts');
}
}
readonly allInstallationCommands: Map<OsType, Command[]> = new Map<OsType, Command[]>([
[OsType.linux, linuxInstallationCommands],
[OsType.win32, defaultInstallationCommands],
[OsType.darwin, defaultInstallationCommands],
[OsType.others, defaultInstallationCommands]
]);
protected get uninstallCommand(): string | undefined {
if (this.osType !== OsType.linux) {
return defaultUninstallCommand;
} else {
return super.uninstallCommand;
}
}
}
const linuxInstallationCommands = [
{
sudo: true,
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information ..."),
command: 'apt-get update'
},
{
sudo: true,
comment: localize('resourceDeployment.Azdata.AptGetPackages', "getting packages needed for azdata installation ..."),
command: 'apt-get install gnupg ca-certificates curl apt-transport-https lsb-release -y'
},
{
sudo: true,
comment: localize('resourceDeployment.Azdata.DownloadAndInstallingSigningKey', "downloading and installing the signing key for azdata ..."),
command: 'wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add -'
},
{
sudo: true,
comment: localize('resourceDeployment.Azdata.AddingAzureCliRepositoryInformation', "adding the azdata repository information ..."),
command: 'add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-preview.list)"'
},
{
sudo: true,
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information ..."),
command: 'apt-get update'
},
{
sudo: true,
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata ..."),
command: 'apt-get install -y azdata-cli'
}
];
const defaultInstallationCommands = [
{
comment: localize('resourceDeployment.Azdata.InstallUpdatePythonRequestsPackage', "installing/updating to latest version of requests python package azdata ..."),
command: `pip3 install -U requests`
},
{
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata ..."),
command: `pip3 install -r https://aka.ms/azdata --quiet --user`
}
];
const defaultUninstallCommand = `pip3 uninstall -r https://aka.ms/azdata -y `;