mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 09:35:41 -05:00
Native installers for azdata in auto deployment (#8285)
* code complete * minor fixes from self-review * installation searchaPaths and display logs fixes * revert inadvertent change * fixing installaton roott for debian and mac * Chaning from getos to linux-release-info with sync api usage for figuring out os distribution * adding file missed in previous commit * fixing indvertent compile error that creeped in * fix default install root for azli
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
import { EOL } from 'os';
|
||||
import { SemVer } from 'semver';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Command, OsType, ToolType } from '../../interfaces';
|
||||
import { Command, OsDistribution, ToolType } from '../../interfaces';
|
||||
import { IPlatformService } from '../platformService';
|
||||
import { dependencyType, ToolBase } from './toolBase';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
const defaultInstallationRoot = '~/.local/bin';
|
||||
const defaultInstallationRoot = '/usr/local/bin';
|
||||
const win32InstallationRoot = `${process.env['ProgramFiles(x86)']}\\Microsoft SDKs\\Azure\\CLI2\\wbin`;
|
||||
export const AzCliToolName = 'azure-cli';
|
||||
|
||||
@@ -44,19 +44,19 @@ export class AzCliTool extends ToolBase {
|
||||
}
|
||||
|
||||
protected async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osType) {
|
||||
case OsType.win32:
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
return [win32InstallationRoot];
|
||||
default:
|
||||
return [defaultInstallationRoot];
|
||||
}
|
||||
}
|
||||
|
||||
protected readonly allInstallationCommands: Map<OsType, Command[]> = new Map<OsType, Command[]>([
|
||||
[OsType.linux, linuxInstallationCommands],
|
||||
[OsType.win32, win32InstallationCommands],
|
||||
[OsType.darwin, macOsInstallationCommands],
|
||||
[OsType.others, defaultInstallationCommands]
|
||||
protected readonly allInstallationCommands: Map<OsDistribution, Command[]> = new Map<OsDistribution, Command[]>([
|
||||
[OsDistribution.debian, debianInstallationCommands],
|
||||
[OsDistribution.win32, win32InstallationCommands],
|
||||
[OsDistribution.darwin, macOsInstallationCommands],
|
||||
[OsDistribution.others, defaultInstallationCommands]
|
||||
]);
|
||||
|
||||
protected getVersionFromOutput(output: string): SemVer | undefined {
|
||||
@@ -73,11 +73,11 @@ export class AzCliTool extends ToolBase {
|
||||
};
|
||||
}
|
||||
|
||||
protected dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>([
|
||||
[OsType.linux, []],
|
||||
[OsType.win32, []],
|
||||
[OsType.darwin, [dependencyType.Brew]],
|
||||
[OsType.others, [dependencyType.Curl]]
|
||||
protected dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||
[OsDistribution.debian, []],
|
||||
[OsDistribution.win32, []],
|
||||
[OsDistribution.darwin, [dependencyType.Brew]],
|
||||
[OsDistribution.others, [dependencyType.Curl]]
|
||||
]);
|
||||
|
||||
protected get discoveryCommand(): Command {
|
||||
@@ -99,12 +99,11 @@ const win32InstallationCommands = [
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.AziCli.DisplayingInstallationLog', "displaying the installation log …"),
|
||||
command: `type AzureCliInstall.log | findstr /i /v /c:"cached product context" | findstr /i /v /c:"has no eligible binary patches" `,
|
||||
command: `type ADS_AzureCliInstall.log | findstr /i /v "^MSI"`,
|
||||
ignoreError: true
|
||||
}
|
||||
];
|
||||
const macOsInstallationCommands = [
|
||||
// try to install brew ourselves
|
||||
{
|
||||
comment: localize('resourceDeployment.AziCli.UpdatingBrewRepository', "updating your brew repository for azure-cli installation …"),
|
||||
command: 'brew update'
|
||||
@@ -114,7 +113,7 @@ const macOsInstallationCommands = [
|
||||
command: 'brew install azure-cli'
|
||||
}
|
||||
];
|
||||
const linuxInstallationCommands = [
|
||||
const debianInstallationCommands = [
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.AziCli.AptGetUpdate', "updating repository information before installing azure-cli …"),
|
||||
|
||||
@@ -8,12 +8,15 @@ import { SemVer } from 'semver';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { azdataPipInstallArgsKey, AzdataPipInstallUriKey, DeploymentConfigurationKey } from '../../constants';
|
||||
import { Command, OsType, ToolType } from '../../interfaces';
|
||||
import { Command, OsDistribution, ToolType } from '../../interfaces';
|
||||
import { IPlatformService } from '../platformService';
|
||||
import { dependencyType, ToolBase } from './toolBase';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
export const AzdataToolName = 'azdata';
|
||||
const win32InstallationRoot = `${process.env['ProgramFiles(x86)']}\\Microsoft SDKs\\Azdata\\CLI\\wbin`;
|
||||
const macInstallationRoot = '/usr/local/bin';
|
||||
const debianInstallationRoot = '/usr/local/bin';
|
||||
|
||||
export class AzdataTool extends ToolBase {
|
||||
constructor(platformService: IPlatformService) {
|
||||
@@ -65,7 +68,13 @@ export class AzdataTool extends ToolBase {
|
||||
}
|
||||
|
||||
protected async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osType) {
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
return [win32InstallationRoot];
|
||||
case OsDistribution.darwin:
|
||||
return [macInstallationRoot];
|
||||
case OsDistribution.debian:
|
||||
return [debianInstallationRoot];
|
||||
default:
|
||||
const azdataCliInstallLocation = await this.getPip3InstallLocation('azdata-cli');
|
||||
if (azdataCliInstallLocation) {
|
||||
@@ -76,12 +85,12 @@ export class AzdataTool extends ToolBase {
|
||||
}
|
||||
}
|
||||
|
||||
protected get allInstallationCommands(): Map<OsType, Command[]> {
|
||||
return new Map<OsType, Command[]>([
|
||||
[OsType.linux, this.defaultInstallationCommands],
|
||||
[OsType.win32, this.defaultInstallationCommands],
|
||||
[OsType.darwin, this.defaultInstallationCommands],
|
||||
[OsType.others, this.defaultInstallationCommands]
|
||||
protected get allInstallationCommands(): Map<OsDistribution, Command[]> {
|
||||
return new Map<OsDistribution, Command[]>([
|
||||
[OsDistribution.debian, debianInstallationCommands],
|
||||
[OsDistribution.win32, win32InstallationCommands],
|
||||
[OsDistribution.darwin, macOsInstallationCommands],
|
||||
[OsDistribution.others, this.defaultInstallationCommands]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -114,16 +123,45 @@ export class AzdataTool extends ToolBase {
|
||||
return vscode.workspace.getConfiguration(DeploymentConfigurationKey)[azdataPipInstallArgsKey];
|
||||
}
|
||||
|
||||
protected dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>([
|
||||
[OsType.linux, [dependencyType.PythonAndPip3]],
|
||||
[OsType.win32, [dependencyType.PythonAndPip3]],
|
||||
[OsType.darwin, [dependencyType.PythonAndPip3]],
|
||||
[OsType.others, [dependencyType.PythonAndPip3]]
|
||||
protected dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||
[OsDistribution.debian, []],
|
||||
[OsDistribution.win32, []],
|
||||
[OsDistribution.darwin, []],
|
||||
[OsDistribution.others, [dependencyType.PythonAndPip3]]
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
const linuxInstallationCommands = [
|
||||
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
|
||||
}
|
||||
];
|
||||
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'
|
||||
}
|
||||
];
|
||||
const debianInstallationCommands = [
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information …"),
|
||||
@@ -141,8 +179,8 @@ const linuxInstallationCommands = [
|
||||
},
|
||||
{
|
||||
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)"'
|
||||
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,
|
||||
@@ -155,4 +193,3 @@ const linuxInstallationCommands = [
|
||||
command: 'apt-get install -y azdata-cli'
|
||||
}
|
||||
];
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { SemVer } from 'semver';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Command, ToolType, OsType } from '../../interfaces';
|
||||
import { Command, ToolType, OsDistribution } from '../../interfaces';
|
||||
import { IPlatformService } from '../platformService';
|
||||
import { ToolBase } from './toolBase';
|
||||
|
||||
@@ -51,7 +51,7 @@ export class DockerTool extends ToolBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected get allInstallationCommands(): Map<OsType, Command[]> {
|
||||
protected get allInstallationCommands(): Map<OsDistribution, Command[]> {
|
||||
throw Error('Installation of DockerTool is not supported');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Command, ToolType, OsType } from '../../interfaces';
|
||||
import { Command, ToolType, OsDistribution } from '../../interfaces';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { SemVer } from 'semver';
|
||||
import { IPlatformService } from '../platformService';
|
||||
@@ -63,25 +63,25 @@ export class KubeCtlTool extends ToolBase {
|
||||
}
|
||||
|
||||
protected async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osType) {
|
||||
case OsType.win32:
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
return [this.storagePath];
|
||||
default:
|
||||
return [defaultInstallationRoot];
|
||||
}
|
||||
}
|
||||
protected readonly allInstallationCommands: Map<OsType, Command[]> = new Map<OsType, Command[]>([
|
||||
[OsType.linux, linuxInstallationCommands],
|
||||
[OsType.win32, win32InstallationCommands],
|
||||
[OsType.darwin, macOsInstallationCommands],
|
||||
[OsType.others, defaultInstallationCommands]
|
||||
protected readonly allInstallationCommands: Map<OsDistribution, Command[]> = new Map<OsDistribution, Command[]>([
|
||||
[OsDistribution.debian, debianInstallationCommands],
|
||||
[OsDistribution.win32, win32InstallationCommands],
|
||||
[OsDistribution.darwin, macOsInstallationCommands],
|
||||
[OsDistribution.others, defaultInstallationCommands]
|
||||
]);
|
||||
|
||||
protected dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>([
|
||||
[OsType.linux, []],
|
||||
[OsType.win32, []],
|
||||
[OsType.darwin, [dependencyType.Brew]],
|
||||
[OsType.others, [dependencyType.Curl]]
|
||||
protected dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||
[OsDistribution.debian, []],
|
||||
[OsDistribution.win32, []],
|
||||
[OsDistribution.darwin, [dependencyType.Brew]],
|
||||
[OsDistribution.others, [dependencyType.Curl]]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ const macOsInstallationCommands = [
|
||||
command: 'brew install kubectl'
|
||||
}
|
||||
];
|
||||
const linuxInstallationCommands = [
|
||||
const debianInstallationCommands = [
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Kubectl.AptGetUpdate', "updating repository information …"),
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as path from 'path';
|
||||
import { SemVer, compare } from 'semver';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { Command, ITool, OsType, ToolStatus, ToolType } from '../../interfaces';
|
||||
import { Command, ITool, OsDistribution, ToolStatus, ToolType } from '../../interfaces';
|
||||
import { getErrorMessage } from '../../utils';
|
||||
import { IPlatformService } from '../platformService';
|
||||
|
||||
@@ -44,7 +44,6 @@ export const messageByDependencyType: Map<dependencyType, string> = new Map<depe
|
||||
|
||||
export abstract class ToolBase implements ITool {
|
||||
constructor(private _platformService: IPlatformService) {
|
||||
this._osType = this._platformService.osType();
|
||||
}
|
||||
|
||||
abstract name: string;
|
||||
@@ -53,8 +52,8 @@ export abstract class ToolBase implements ITool {
|
||||
abstract type: ToolType;
|
||||
abstract homePage: string;
|
||||
abstract autoInstallSupported: boolean;
|
||||
protected abstract readonly allInstallationCommands: Map<OsType, Command[]>;
|
||||
protected readonly dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>();
|
||||
protected abstract readonly allInstallationCommands: Map<OsDistribution, Command[]>;
|
||||
protected readonly dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>();
|
||||
|
||||
protected abstract getVersionFromOutput(output: string): SemVer | undefined;
|
||||
protected readonly _onDidUpdateData = new vscode.EventEmitter<ITool>();
|
||||
@@ -63,7 +62,7 @@ export abstract class ToolBase implements ITool {
|
||||
protected abstract readonly versionCommand: Command;
|
||||
|
||||
public get dependencyMessages(): string[] {
|
||||
return (this.dependenciesByOsType.get(this.osType) || []).map((msgType: dependencyType) => messageByDependencyType.get(msgType)!);
|
||||
return (this.dependenciesByOsType.get(this.osDistribution) || []).map((msgType: dependencyType) => messageByDependencyType.get(msgType)!);
|
||||
}
|
||||
|
||||
protected async getInstallationPath(): Promise<string | undefined> {
|
||||
@@ -125,8 +124,8 @@ export abstract class ToolBase implements ITool {
|
||||
return this._platformService.storagePath();
|
||||
}
|
||||
|
||||
public get osType(): OsType {
|
||||
return this._osType;
|
||||
public get osDistribution(): OsDistribution {
|
||||
return this._platformService.osDistribution();
|
||||
}
|
||||
|
||||
protected get version(): SemVer | undefined {
|
||||
@@ -152,7 +151,7 @@ export abstract class ToolBase implements ITool {
|
||||
}
|
||||
|
||||
protected get installationCommands(): Command[] | undefined {
|
||||
return this.allInstallationCommands.get(this.osType);
|
||||
return this.allInstallationCommands.get(this.osDistribution);
|
||||
}
|
||||
|
||||
protected async getPip3InstallLocation(packageName: string): Promise<string> {
|
||||
@@ -272,10 +271,10 @@ export abstract class ToolBase implements ITool {
|
||||
}
|
||||
|
||||
protected discoveryCommandString(toolBinary: string) {
|
||||
switch (this.osType) {
|
||||
case OsType.win32:
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
return `where.exe ${toolBinary}`;
|
||||
case OsType.darwin:
|
||||
case OsDistribution.darwin:
|
||||
return `command -v ${toolBinary}`;
|
||||
default:
|
||||
return `which ${toolBinary}`;
|
||||
@@ -304,7 +303,6 @@ export abstract class ToolBase implements ITool {
|
||||
}
|
||||
|
||||
private _status: ToolStatus = ToolStatus.NotInstalled;
|
||||
private _osType: OsType;
|
||||
private _version?: SemVer;
|
||||
private _statusDescription?: string;
|
||||
private _installationPath!: string;
|
||||
|
||||
Reference in New Issue
Block a user