mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Changes to remove Pip3 based installations for azdata (#8577)
* saving intermediate work - to merge master * remove inadvertent change * Remove Pip3 installation from all tools * working version * making some small fixes * add back accidently removed file * Update resourceTypePickerDialog.ts * Removing redundant trailing "," * Remove commented dead code * fix casing of nls string * remove inadvertent change * change installation locations from field to properties so that they are constructed at run time'
This commit is contained in:
@@ -39,10 +39,6 @@ export class AzCliTool extends ToolBase {
|
||||
return 'https://docs.microsoft.com/cli/azure/install-azure-cli';
|
||||
}
|
||||
|
||||
get autoInstallSupported(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as path from 'path';
|
||||
import { SemVer } from 'semver';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { azdataPipInstallArgsKey, AzdataPipInstallUriKey, DeploymentConfigurationKey } from '../../constants';
|
||||
import { AzdataInstallLocationKey, DeploymentConfigurationKey } from '../../constants';
|
||||
import { Command, OsDistribution, ToolType } from '../../interfaces';
|
||||
import { IPlatformService } from '../platformService';
|
||||
import { dependencyType, ToolBase } from './toolBase';
|
||||
@@ -62,11 +62,6 @@ export class AzdataTool extends ToolBase {
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
get autoInstallSupported(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
@@ -87,109 +82,100 @@ export class AzdataTool extends ToolBase {
|
||||
|
||||
protected get allInstallationCommands(): Map<OsDistribution, Command[]> {
|
||||
return new Map<OsDistribution, Command[]>([
|
||||
[OsDistribution.debian, debianInstallationCommands],
|
||||
[OsDistribution.win32, win32InstallationCommands],
|
||||
[OsDistribution.darwin, macOsInstallationCommands],
|
||||
[OsDistribution.others, this.defaultInstallationCommands]
|
||||
[OsDistribution.debian, this.debianInstallationCommands],
|
||||
[OsDistribution.win32, this.win32InstallationCommands],
|
||||
[OsDistribution.darwin, this.macOsInstallationCommands],
|
||||
[OsDistribution.others, []]
|
||||
]);
|
||||
}
|
||||
|
||||
protected get uninstallCommand(): string | undefined {
|
||||
return this.defaultUninstallCommand;
|
||||
|
||||
private get azdataInstallLocation(): string {
|
||||
return vscode.workspace.getConfiguration(DeploymentConfigurationKey)[AzdataInstallLocationKey] || this.defaultInstallLocationByDistribution.get(this.osDistribution);
|
||||
}
|
||||
|
||||
private get defaultInstallationCommands(): Command[] {
|
||||
return [
|
||||
{
|
||||
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 ${this.azdataInstallUri} ${this.azdataInstallAdditionalArgs} --quiet --user`
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
private get defaultUninstallCommand(): string {
|
||||
return `pip3 uninstall -r ${this.azdataInstallUri} ${this.azdataInstallAdditionalArgs} -y `;
|
||||
}
|
||||
|
||||
private get azdataInstallUri(): string {
|
||||
return vscode.workspace.getConfiguration(DeploymentConfigurationKey)[AzdataPipInstallUriKey];
|
||||
}
|
||||
|
||||
private get azdataInstallAdditionalArgs(): string {
|
||||
return vscode.workspace.getConfiguration(DeploymentConfigurationKey)[azdataPipInstallArgsKey];
|
||||
}
|
||||
private defaultInstallLocationByDistribution: Map<OsDistribution, string> = new Map<OsDistribution, string>([
|
||||
[OsDistribution.debian, 'https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2019.list'],
|
||||
[OsDistribution.win32, 'https://aka.ms/azdata-msi'],
|
||||
[OsDistribution.darwin, 'microsoft/azdata-cli-release'],
|
||||
[OsDistribution.others, '']
|
||||
]);
|
||||
|
||||
protected dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||
[OsDistribution.debian, []],
|
||||
[OsDistribution.win32, []],
|
||||
[OsDistribution.darwin, []],
|
||||
[OsDistribution.others, [dependencyType.PythonAndPip3]]
|
||||
[OsDistribution.darwin, [dependencyType.Brew]],
|
||||
[OsDistribution.others, []]
|
||||
]);
|
||||
}
|
||||
|
||||
const win32InstallationCommands = [
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.DeletingPreviousAzdata.msi', "deleting previously downloaded Azdata.msi if one exists …"),
|
||||
command: `IF EXIST .\\Azdata.msi DEL /F .\\Azdata.msi`
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.DownloadingAndInstallingAzdata', "downloading Azdata.msi and installing azdata-cli …"),
|
||||
command: `powershell -Command "& {(New-Object System.Net.WebClient).DownloadFile('https://aka.ms/azdata-msi', 'Azdata.msi'); Start-Process msiexec.exe -Wait -ArgumentList '/I Azdata.msi /passive /quiet /lvx ADS_AzdataInstall.log'}"`
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.DisplayingInstallationLog', "displaying the installation log …"),
|
||||
command: `type ADS_AzdataInstall.log | findstr /i /v ^MSI"`,
|
||||
ignoreError: true
|
||||
private get win32InstallationCommands() {
|
||||
return [
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.DeletingPreviousAzdata.msi', "deleting previously downloaded Azdata.msi if one exists …"),
|
||||
command: `IF EXIST .\\Azdata.msi DEL /F .\\Azdata.msi`
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.DownloadingAndInstallingAzdata', "downloading Azdata.msi and installing azdata-cli …"),
|
||||
command: `powershell -Command "& {(New-Object System.Net.WebClient).DownloadFile('${this.azdataInstallLocation}', 'Azdata.msi'); Start-Process msiexec.exe -Wait -ArgumentList '/I Azdata.msi /passive /quiet /lvx ADS_AzdataInstall.log'}"`
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.DisplayingInstallationLog', "displaying the installation log …"),
|
||||
command: `type ADS_AzdataInstall.log | findstr /i /v ^MSI"`,
|
||||
ignoreError: true
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
const macOsInstallationCommands = [
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.TappingBrewRepository', "tapping into the brew repository for azdata-cli …"),
|
||||
command: 'brew tap microsoft/azdata-cli-release'
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.UpdatingBrewRepository', "updating the brew repository for azdata-cli installation …"),
|
||||
command: 'brew update'
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata …"),
|
||||
command: 'brew install azdata-cli'
|
||||
|
||||
private get macOsInstallationCommands() {
|
||||
return [
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.TappingBrewRepository', "tapping into the brew repository for azdata-cli …"),
|
||||
command: `brew tap ${this.azdataInstallLocation}`
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.UpdatingBrewRepository', "updating the brew repository for azdata-cli installation …"),
|
||||
command: 'brew update'
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata …"),
|
||||
command: 'brew install azdata-cli'
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
const debianInstallationCommands = [
|
||||
{
|
||||
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.AddingAzdataRepositoryInformation', "adding the azdata repository information …"),
|
||||
command: 'add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2019.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'
|
||||
|
||||
private get debianInstallationCommands() {
|
||||
return [
|
||||
{
|
||||
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.AddingAzdataRepositoryInformation', "adding the azdata repository information …"),
|
||||
command: `add-apt-repository "$(wget -qO- ${this.azdataInstallLocation})"`
|
||||
},
|
||||
{
|
||||
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'
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
@@ -47,11 +47,5 @@ export class DockerTool extends ToolBase {
|
||||
return { command: 'docker version --format "{{json .}}"' };
|
||||
}
|
||||
|
||||
get autoInstallSupported(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected get allInstallationCommands(): Map<OsDistribution, Command[]> {
|
||||
throw Error('Installation of DockerTool is not supported');
|
||||
}
|
||||
protected readonly allInstallationCommands: Map<OsDistribution, Command[]> = new Map<OsDistribution, Command[]>();
|
||||
}
|
||||
|
||||
@@ -57,11 +57,6 @@ export class KubeCtlTool extends ToolBase {
|
||||
command: this.discoveryCommandString('kubectl')
|
||||
};
|
||||
}
|
||||
|
||||
get autoInstallSupported(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
|
||||
@@ -27,17 +27,14 @@ const toolStatusLocalized: Map<ToolStatus, string> = new Map<ToolStatus, string>
|
||||
]);
|
||||
|
||||
export const enum dependencyType {
|
||||
PythonAndPip3 = 'PythonAndPip3',
|
||||
Brew = 'Brew',
|
||||
Curl = 'Curl'
|
||||
}
|
||||
|
||||
const pythonAndPip3Localized = localize('deploymentDialog.ToolInformationalMessage.PythonAndPip3', "• azdata installation needs pip3 and python3 version 3.6 to be pre-installed before necessary tools can be deployed");
|
||||
const brewLocalized = localize('deploymentDialog.ToolInformationalMessage.Brew', "• brew is needed for deployment of the tools and needs to be pre-installed before necessary tools can be deployed");
|
||||
const curlLocalized = localize('deploymentDialog.ToolInformationalMessage.Curl', "• curl is needed for installation and needs to be pre-installed before necessary tools can be deployed");
|
||||
|
||||
export const messageByDependencyType: Map<dependencyType, string> = new Map<dependencyType, string>([
|
||||
[dependencyType.PythonAndPip3, pythonAndPip3Localized],
|
||||
[dependencyType.Brew, brewLocalized],
|
||||
[dependencyType.Curl, curlLocalized]
|
||||
]);
|
||||
@@ -51,7 +48,6 @@ export abstract class ToolBase implements ITool {
|
||||
abstract description: string;
|
||||
abstract type: ToolType;
|
||||
abstract homePage: string;
|
||||
abstract autoInstallSupported: boolean;
|
||||
protected abstract readonly allInstallationCommands: Map<OsDistribution, Command[]>;
|
||||
protected readonly dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>();
|
||||
|
||||
@@ -100,7 +96,7 @@ export abstract class ToolBase implements ITool {
|
||||
return <string>toolStatusLocalized.get(this._status);
|
||||
}
|
||||
|
||||
public get autoInstallRequired(): boolean {
|
||||
public get autoInstallNeeded(): boolean {
|
||||
return this.status !== ToolStatus.Installed && this.autoInstallSupported;
|
||||
}
|
||||
|
||||
@@ -116,10 +112,6 @@ export abstract class ToolBase implements ITool {
|
||||
return this.status === ToolStatus.Installing;
|
||||
}
|
||||
|
||||
public get needsInstallation(): boolean {
|
||||
return this.status !== ToolStatus.Installed;
|
||||
}
|
||||
|
||||
public get storagePath(): string {
|
||||
return this._platformService.storagePath();
|
||||
}
|
||||
@@ -177,6 +169,11 @@ export abstract class ToolBase implements ITool {
|
||||
this._platformService.showOutputChannel(preserveFocus);
|
||||
}
|
||||
|
||||
|
||||
get autoInstallSupported(): boolean {
|
||||
return !!this.installationCommands && !!this.installationCommands.length;
|
||||
}
|
||||
|
||||
public async install(): Promise<void> {
|
||||
this._statusDescription = '';
|
||||
try {
|
||||
@@ -207,7 +204,7 @@ export abstract class ToolBase implements ITool {
|
||||
protected async installCore() {
|
||||
const installationCommands: Command[] | undefined = this.installationCommands;
|
||||
if (!installationCommands || installationCommands.length === 0) {
|
||||
throw new Error(localize('toolBase.installCore.CannotInstallTool', "Cannot install tool:${0}::${1} as installation commands are unknown", this.displayName, this.description));
|
||||
throw new Error(localize('toolBase.installCore.CannotInstallTool', "Cannot install tool:{0}::{1} as installation commands are unknown for your OS distribution, Please install {0} manually before proceeding", this.displayName, this.description));
|
||||
}
|
||||
for (let i: number = 0; i < installationCommands.length; i++) {
|
||||
await this._platformService.runCommand(installationCommands[i].command,
|
||||
@@ -229,11 +226,9 @@ export abstract class ToolBase implements ITool {
|
||||
if (process.env.PATH) {
|
||||
if (!`${path.delimiter}${process.env.PATH}${path.delimiter}`.includes(`${path.delimiter}${searchPath}${path.delimiter}`)) {
|
||||
process.env.PATH += `${path.delimiter}${searchPath}`;
|
||||
console.log(`Appending to Path -> '${path.delimiter}${searchPath}'`);
|
||||
}
|
||||
} else {
|
||||
process.env.PATH = searchPath;
|
||||
console.log(`Setting PATH to -> '${searchPath}'`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user