mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -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:
@@ -353,6 +353,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"linux-release-info": "^2.0.0",
|
||||||
"promisify-child-process": "^3.1.1",
|
"promisify-child-process": "^3.1.1",
|
||||||
"sudo-prompt": "^9.0.0",
|
"sudo-prompt": "^9.0.0",
|
||||||
"vscode-nls": "^4.0.0",
|
"vscode-nls": "^4.0.0",
|
||||||
|
|||||||
@@ -201,12 +201,21 @@ export interface NotebookInfo {
|
|||||||
linux: string;
|
linux: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum OsType {
|
export enum OsDistribution {
|
||||||
win32 = 'win32',
|
win32 = 'win32',
|
||||||
darwin = 'darwin',
|
darwin = 'darwin',
|
||||||
linux = 'linux',
|
debian = 'debian',
|
||||||
others = 'others'
|
others = 'others'
|
||||||
}
|
}
|
||||||
|
export interface OsRelease extends JSON {
|
||||||
|
type: string;
|
||||||
|
platform: string;
|
||||||
|
hostname: string;
|
||||||
|
arch: string;
|
||||||
|
release: string;
|
||||||
|
id?: string;
|
||||||
|
id_like?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ToolRequirementInfo {
|
export interface ToolRequirementInfo {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export class AzdataService implements IAzdataService {
|
|||||||
default:
|
default:
|
||||||
throw new Error(`Unknown deployment type: ${deploymentType}`);
|
throw new Error(`Unknown deployment type: ${deploymentType}`);
|
||||||
}
|
}
|
||||||
await this.ensureWorkingDirectoryExists();
|
|
||||||
const profileNames = await this.getDeploymentProfileNames();
|
const profileNames = await this.getDeploymentProfileNames();
|
||||||
return await Promise.all(profileNames.filter(profile => profile.startsWith(profilePrefix)).map(profile => this.getDeploymentProfileInfo(profile)));
|
return await Promise.all(profileNames.filter(profile => profile.startsWith(profilePrefix)).map(profile => this.getDeploymentProfileInfo(profile)));
|
||||||
}
|
}
|
||||||
@@ -65,10 +64,6 @@ export class AzdataService implements IAzdataService {
|
|||||||
return new BigDataClusterDeploymentProfile(profileName, configObjects[0], configObjects[1]);
|
return new BigDataClusterDeploymentProfile(profileName, configObjects[0], configObjects[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ensureWorkingDirectoryExists(): Promise<void> {
|
|
||||||
await this.platformService.ensureDirectoryExists(this.platformService.storagePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getJsonObjectFromFile(path: string): Promise<any> {
|
private async getJsonObjectFromFile(path: string): Promise<any> {
|
||||||
return JSON.parse(await this.platformService.readTextFile(path));
|
return JSON.parse(await this.platformService.readTextFile(path));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import * as releaseInfo from 'linux-release-info';
|
||||||
import * as cp from 'promisify-child-process';
|
import * as cp from 'promisify-child-process';
|
||||||
import * as sudo from 'sudo-prompt';
|
import * as sudo from 'sudo-prompt';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { OsType } from '../interfaces';
|
import { OsDistribution, OsRelease } from '../interfaces';
|
||||||
import { getErrorMessage } from '../utils';
|
import { getErrorMessage } from '../utils';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
@@ -18,7 +19,7 @@ const sudoPromptTitle = 'AzureDataStudio';
|
|||||||
* Abstract of platform dependencies
|
* Abstract of platform dependencies
|
||||||
*/
|
*/
|
||||||
export interface IPlatformService {
|
export interface IPlatformService {
|
||||||
osType(): OsType;
|
osDistribution(): OsDistribution;
|
||||||
platform(): string;
|
platform(): string;
|
||||||
storagePath(): string;
|
storagePath(): string;
|
||||||
initialize(): Promise<void>;
|
initialize(): Promise<void>;
|
||||||
@@ -31,7 +32,6 @@ export interface IPlatformService {
|
|||||||
showOutputChannel(preserveFocus?: boolean): void;
|
showOutputChannel(preserveFocus?: boolean): void;
|
||||||
isNotebookNameUsed(title: string): boolean;
|
isNotebookNameUsed(title: string): boolean;
|
||||||
makeDirectory(path: string): Promise<void>;
|
makeDirectory(path: string): Promise<void>;
|
||||||
ensureDirectoryExists(directory: string): Promise<void>;
|
|
||||||
readTextFile(filePath: string): Promise<string>;
|
readTextFile(filePath: string): Promise<string>;
|
||||||
runCommand(command: string, options?: CommandOptions): Promise<string>;
|
runCommand(command: string, options?: CommandOptions): Promise<string>;
|
||||||
saveTextFile(content: string, path: string): Promise<void>;
|
saveTextFile(content: string, path: string): Promise<void>;
|
||||||
@@ -57,14 +57,16 @@ export interface CommandOptions {
|
|||||||
export class PlatformService implements IPlatformService {
|
export class PlatformService implements IPlatformService {
|
||||||
|
|
||||||
private _outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel(extensionOutputChannel);
|
private _outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel(extensionOutputChannel);
|
||||||
private _storagePathEnsurer: Promise<void>;
|
private _initializationEnsurer: Promise<void>;
|
||||||
|
private _osDistribution: OsDistribution;
|
||||||
|
|
||||||
constructor(private _storagePath: string = '') {
|
constructor(private _storagePath: string) {
|
||||||
this._storagePathEnsurer = this.ensureDirectoryExists(_storagePath);
|
this._osDistribution = this.getOsDistribution();
|
||||||
|
this._initializationEnsurer = this.ensureDirectoryExists(_storagePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async initialize(): Promise<void> {
|
async initialize(): Promise<void> {
|
||||||
await this._storagePathEnsurer;
|
await this._initializationEnsurer;
|
||||||
}
|
}
|
||||||
|
|
||||||
storagePath(): string {
|
storagePath(): string {
|
||||||
@@ -83,12 +85,18 @@ export class PlatformService implements IPlatformService {
|
|||||||
this._outputChannel.show(preserveFocus);
|
this._outputChannel.show(preserveFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
osType(platform: string = this.platform()): OsType {
|
osDistribution(): OsDistribution {
|
||||||
if (Object.values(OsType).includes(<OsType>platform)) {
|
return this._osDistribution;
|
||||||
return <OsType>platform;
|
|
||||||
} else {
|
|
||||||
return OsType.others;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getOsDistribution(): OsDistribution {
|
||||||
|
const currentReleaseInfo = <OsRelease>releaseInfo({ mode: 'sync' });
|
||||||
|
const dist = currentReleaseInfo.id_like || currentReleaseInfo.id || currentReleaseInfo.platform;
|
||||||
|
if (Object.values(OsDistribution).includes(<OsDistribution>dist)) {
|
||||||
|
return <OsDistribution>dist;
|
||||||
|
}
|
||||||
|
// all other unrecognized oses/distributions are treated as OsType.others
|
||||||
|
return OsDistribution.others;
|
||||||
}
|
}
|
||||||
|
|
||||||
async copyFile(source: string, target: string): Promise<void> {
|
async copyFile(source: string, target: string): Promise<void> {
|
||||||
@@ -127,7 +135,7 @@ export class PlatformService implements IPlatformService {
|
|||||||
*This function ensures that the given {@link directory} does not exist it creates it. It creates only the most leaf folder so if any ancestor folders are missing then this command throws an error.
|
*This function ensures that the given {@link directory} does not exist it creates it. It creates only the most leaf folder so if any ancestor folders are missing then this command throws an error.
|
||||||
* @param directory - the path to ensure
|
* @param directory - the path to ensure
|
||||||
*/
|
*/
|
||||||
async ensureDirectoryExists(directory: string): Promise<void> {
|
private async ensureDirectoryExists(directory: string): Promise<void> {
|
||||||
if (!await this.fileExists(directory)) {
|
if (!await this.fileExists(directory)) {
|
||||||
await this.makeDirectory(directory);
|
await this.makeDirectory(directory);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
import { EOL } from 'os';
|
import { EOL } from 'os';
|
||||||
import { SemVer } from 'semver';
|
import { SemVer } from 'semver';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { Command, OsType, ToolType } from '../../interfaces';
|
import { Command, OsDistribution, ToolType } from '../../interfaces';
|
||||||
import { IPlatformService } from '../platformService';
|
import { IPlatformService } from '../platformService';
|
||||||
import { dependencyType, ToolBase } from './toolBase';
|
import { dependencyType, ToolBase } from './toolBase';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
const defaultInstallationRoot = '~/.local/bin';
|
const defaultInstallationRoot = '/usr/local/bin';
|
||||||
const win32InstallationRoot = `${process.env['ProgramFiles(x86)']}\\Microsoft SDKs\\Azure\\CLI2\\wbin`;
|
const win32InstallationRoot = `${process.env['ProgramFiles(x86)']}\\Microsoft SDKs\\Azure\\CLI2\\wbin`;
|
||||||
export const AzCliToolName = 'azure-cli';
|
export const AzCliToolName = 'azure-cli';
|
||||||
|
|
||||||
@@ -44,19 +44,19 @@ export class AzCliTool extends ToolBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async getSearchPaths(): Promise<string[]> {
|
protected async getSearchPaths(): Promise<string[]> {
|
||||||
switch (this.osType) {
|
switch (this.osDistribution) {
|
||||||
case OsType.win32:
|
case OsDistribution.win32:
|
||||||
return [win32InstallationRoot];
|
return [win32InstallationRoot];
|
||||||
default:
|
default:
|
||||||
return [defaultInstallationRoot];
|
return [defaultInstallationRoot];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly allInstallationCommands: Map<OsType, Command[]> = new Map<OsType, Command[]>([
|
protected readonly allInstallationCommands: Map<OsDistribution, Command[]> = new Map<OsDistribution, Command[]>([
|
||||||
[OsType.linux, linuxInstallationCommands],
|
[OsDistribution.debian, debianInstallationCommands],
|
||||||
[OsType.win32, win32InstallationCommands],
|
[OsDistribution.win32, win32InstallationCommands],
|
||||||
[OsType.darwin, macOsInstallationCommands],
|
[OsDistribution.darwin, macOsInstallationCommands],
|
||||||
[OsType.others, defaultInstallationCommands]
|
[OsDistribution.others, defaultInstallationCommands]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
protected getVersionFromOutput(output: string): SemVer | undefined {
|
protected getVersionFromOutput(output: string): SemVer | undefined {
|
||||||
@@ -73,11 +73,11 @@ export class AzCliTool extends ToolBase {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>([
|
protected dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||||
[OsType.linux, []],
|
[OsDistribution.debian, []],
|
||||||
[OsType.win32, []],
|
[OsDistribution.win32, []],
|
||||||
[OsType.darwin, [dependencyType.Brew]],
|
[OsDistribution.darwin, [dependencyType.Brew]],
|
||||||
[OsType.others, [dependencyType.Curl]]
|
[OsDistribution.others, [dependencyType.Curl]]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
protected get discoveryCommand(): Command {
|
protected get discoveryCommand(): Command {
|
||||||
@@ -99,12 +99,11 @@ const win32InstallationCommands = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
comment: localize('resourceDeployment.AziCli.DisplayingInstallationLog', "displaying the installation log …"),
|
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
|
ignoreError: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const macOsInstallationCommands = [
|
const macOsInstallationCommands = [
|
||||||
// try to install brew ourselves
|
|
||||||
{
|
{
|
||||||
comment: localize('resourceDeployment.AziCli.UpdatingBrewRepository', "updating your brew repository for azure-cli installation …"),
|
comment: localize('resourceDeployment.AziCli.UpdatingBrewRepository', "updating your brew repository for azure-cli installation …"),
|
||||||
command: 'brew update'
|
command: 'brew update'
|
||||||
@@ -114,7 +113,7 @@ const macOsInstallationCommands = [
|
|||||||
command: 'brew install azure-cli'
|
command: 'brew install azure-cli'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const linuxInstallationCommands = [
|
const debianInstallationCommands = [
|
||||||
{
|
{
|
||||||
sudo: true,
|
sudo: true,
|
||||||
comment: localize('resourceDeployment.AziCli.AptGetUpdate', "updating repository information before installing azure-cli …"),
|
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 vscode from 'vscode';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { azdataPipInstallArgsKey, AzdataPipInstallUriKey, DeploymentConfigurationKey } from '../../constants';
|
import { azdataPipInstallArgsKey, AzdataPipInstallUriKey, DeploymentConfigurationKey } from '../../constants';
|
||||||
import { Command, OsType, ToolType } from '../../interfaces';
|
import { Command, OsDistribution, ToolType } from '../../interfaces';
|
||||||
import { IPlatformService } from '../platformService';
|
import { IPlatformService } from '../platformService';
|
||||||
import { dependencyType, ToolBase } from './toolBase';
|
import { dependencyType, ToolBase } from './toolBase';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
export const AzdataToolName = 'azdata';
|
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 {
|
export class AzdataTool extends ToolBase {
|
||||||
constructor(platformService: IPlatformService) {
|
constructor(platformService: IPlatformService) {
|
||||||
@@ -65,7 +68,13 @@ export class AzdataTool extends ToolBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async getSearchPaths(): Promise<string[]> {
|
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:
|
default:
|
||||||
const azdataCliInstallLocation = await this.getPip3InstallLocation('azdata-cli');
|
const azdataCliInstallLocation = await this.getPip3InstallLocation('azdata-cli');
|
||||||
if (azdataCliInstallLocation) {
|
if (azdataCliInstallLocation) {
|
||||||
@@ -76,12 +85,12 @@ export class AzdataTool extends ToolBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get allInstallationCommands(): Map<OsType, Command[]> {
|
protected get allInstallationCommands(): Map<OsDistribution, Command[]> {
|
||||||
return new Map<OsType, Command[]>([
|
return new Map<OsDistribution, Command[]>([
|
||||||
[OsType.linux, this.defaultInstallationCommands],
|
[OsDistribution.debian, debianInstallationCommands],
|
||||||
[OsType.win32, this.defaultInstallationCommands],
|
[OsDistribution.win32, win32InstallationCommands],
|
||||||
[OsType.darwin, this.defaultInstallationCommands],
|
[OsDistribution.darwin, macOsInstallationCommands],
|
||||||
[OsType.others, this.defaultInstallationCommands]
|
[OsDistribution.others, this.defaultInstallationCommands]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,16 +123,45 @@ export class AzdataTool extends ToolBase {
|
|||||||
return vscode.workspace.getConfiguration(DeploymentConfigurationKey)[azdataPipInstallArgsKey];
|
return vscode.workspace.getConfiguration(DeploymentConfigurationKey)[azdataPipInstallArgsKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>([
|
protected dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||||
[OsType.linux, [dependencyType.PythonAndPip3]],
|
[OsDistribution.debian, []],
|
||||||
[OsType.win32, [dependencyType.PythonAndPip3]],
|
[OsDistribution.win32, []],
|
||||||
[OsType.darwin, [dependencyType.PythonAndPip3]],
|
[OsDistribution.darwin, []],
|
||||||
[OsType.others, [dependencyType.PythonAndPip3]]
|
[OsDistribution.others, [dependencyType.PythonAndPip3]]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
const win32InstallationCommands = [
|
||||||
const linuxInstallationCommands = [
|
{
|
||||||
|
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,
|
sudo: true,
|
||||||
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information …"),
|
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information …"),
|
||||||
@@ -141,8 +179,8 @@ const linuxInstallationCommands = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
sudo: true,
|
sudo: true,
|
||||||
comment: localize('resourceDeployment.Azdata.AddingAzureCliRepositoryInformation', "adding the azdata repository information …"),
|
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-preview.list)"'
|
command: 'add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2019.list)"'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sudo: true,
|
sudo: true,
|
||||||
@@ -155,4 +193,3 @@ const linuxInstallationCommands = [
|
|||||||
command: 'apt-get install -y azdata-cli'
|
command: 'apt-get install -y azdata-cli'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
*/
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
import { SemVer } from 'semver';
|
import { SemVer } from 'semver';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { Command, ToolType, OsType } from '../../interfaces';
|
import { Command, ToolType, OsDistribution } from '../../interfaces';
|
||||||
import { IPlatformService } from '../platformService';
|
import { IPlatformService } from '../platformService';
|
||||||
import { ToolBase } from './toolBase';
|
import { ToolBase } from './toolBase';
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export class DockerTool extends ToolBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get allInstallationCommands(): Map<OsType, Command[]> {
|
protected get allInstallationCommands(): Map<OsDistribution, Command[]> {
|
||||||
throw Error('Installation of DockerTool is not supported');
|
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.
|
* 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 * as nls from 'vscode-nls';
|
||||||
import { SemVer } from 'semver';
|
import { SemVer } from 'semver';
|
||||||
import { IPlatformService } from '../platformService';
|
import { IPlatformService } from '../platformService';
|
||||||
@@ -63,25 +63,25 @@ export class KubeCtlTool extends ToolBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async getSearchPaths(): Promise<string[]> {
|
protected async getSearchPaths(): Promise<string[]> {
|
||||||
switch (this.osType) {
|
switch (this.osDistribution) {
|
||||||
case OsType.win32:
|
case OsDistribution.win32:
|
||||||
return [this.storagePath];
|
return [this.storagePath];
|
||||||
default:
|
default:
|
||||||
return [defaultInstallationRoot];
|
return [defaultInstallationRoot];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected readonly allInstallationCommands: Map<OsType, Command[]> = new Map<OsType, Command[]>([
|
protected readonly allInstallationCommands: Map<OsDistribution, Command[]> = new Map<OsDistribution, Command[]>([
|
||||||
[OsType.linux, linuxInstallationCommands],
|
[OsDistribution.debian, debianInstallationCommands],
|
||||||
[OsType.win32, win32InstallationCommands],
|
[OsDistribution.win32, win32InstallationCommands],
|
||||||
[OsType.darwin, macOsInstallationCommands],
|
[OsDistribution.darwin, macOsInstallationCommands],
|
||||||
[OsType.others, defaultInstallationCommands]
|
[OsDistribution.others, defaultInstallationCommands]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
protected dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>([
|
protected dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||||
[OsType.linux, []],
|
[OsDistribution.debian, []],
|
||||||
[OsType.win32, []],
|
[OsDistribution.win32, []],
|
||||||
[OsType.darwin, [dependencyType.Brew]],
|
[OsDistribution.darwin, [dependencyType.Brew]],
|
||||||
[OsType.others, [dependencyType.Curl]]
|
[OsDistribution.others, [dependencyType.Curl]]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ const macOsInstallationCommands = [
|
|||||||
command: 'brew install kubectl'
|
command: 'brew install kubectl'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const linuxInstallationCommands = [
|
const debianInstallationCommands = [
|
||||||
{
|
{
|
||||||
sudo: true,
|
sudo: true,
|
||||||
comment: localize('resourceDeployment.Kubectl.AptGetUpdate', "updating repository information …"),
|
comment: localize('resourceDeployment.Kubectl.AptGetUpdate', "updating repository information …"),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import * as path from 'path';
|
|||||||
import { SemVer, compare } from 'semver';
|
import { SemVer, compare } from 'semver';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as nls from 'vscode-nls';
|
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 { getErrorMessage } from '../../utils';
|
||||||
import { IPlatformService } from '../platformService';
|
import { IPlatformService } from '../platformService';
|
||||||
|
|
||||||
@@ -44,7 +44,6 @@ export const messageByDependencyType: Map<dependencyType, string> = new Map<depe
|
|||||||
|
|
||||||
export abstract class ToolBase implements ITool {
|
export abstract class ToolBase implements ITool {
|
||||||
constructor(private _platformService: IPlatformService) {
|
constructor(private _platformService: IPlatformService) {
|
||||||
this._osType = this._platformService.osType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract name: string;
|
abstract name: string;
|
||||||
@@ -53,8 +52,8 @@ export abstract class ToolBase implements ITool {
|
|||||||
abstract type: ToolType;
|
abstract type: ToolType;
|
||||||
abstract homePage: string;
|
abstract homePage: string;
|
||||||
abstract autoInstallSupported: boolean;
|
abstract autoInstallSupported: boolean;
|
||||||
protected abstract readonly allInstallationCommands: Map<OsType, Command[]>;
|
protected abstract readonly allInstallationCommands: Map<OsDistribution, Command[]>;
|
||||||
protected readonly dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>();
|
protected readonly dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>();
|
||||||
|
|
||||||
protected abstract getVersionFromOutput(output: string): SemVer | undefined;
|
protected abstract getVersionFromOutput(output: string): SemVer | undefined;
|
||||||
protected readonly _onDidUpdateData = new vscode.EventEmitter<ITool>();
|
protected readonly _onDidUpdateData = new vscode.EventEmitter<ITool>();
|
||||||
@@ -63,7 +62,7 @@ export abstract class ToolBase implements ITool {
|
|||||||
protected abstract readonly versionCommand: Command;
|
protected abstract readonly versionCommand: Command;
|
||||||
|
|
||||||
public get dependencyMessages(): string[] {
|
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> {
|
protected async getInstallationPath(): Promise<string | undefined> {
|
||||||
@@ -125,8 +124,8 @@ export abstract class ToolBase implements ITool {
|
|||||||
return this._platformService.storagePath();
|
return this._platformService.storagePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get osType(): OsType {
|
public get osDistribution(): OsDistribution {
|
||||||
return this._osType;
|
return this._platformService.osDistribution();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get version(): SemVer | undefined {
|
protected get version(): SemVer | undefined {
|
||||||
@@ -152,7 +151,7 @@ export abstract class ToolBase implements ITool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected get installationCommands(): Command[] | undefined {
|
protected get installationCommands(): Command[] | undefined {
|
||||||
return this.allInstallationCommands.get(this.osType);
|
return this.allInstallationCommands.get(this.osDistribution);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getPip3InstallLocation(packageName: string): Promise<string> {
|
protected async getPip3InstallLocation(packageName: string): Promise<string> {
|
||||||
@@ -272,10 +271,10 @@ export abstract class ToolBase implements ITool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected discoveryCommandString(toolBinary: string) {
|
protected discoveryCommandString(toolBinary: string) {
|
||||||
switch (this.osType) {
|
switch (this.osDistribution) {
|
||||||
case OsType.win32:
|
case OsDistribution.win32:
|
||||||
return `where.exe ${toolBinary}`;
|
return `where.exe ${toolBinary}`;
|
||||||
case OsType.darwin:
|
case OsDistribution.darwin:
|
||||||
return `command -v ${toolBinary}`;
|
return `command -v ${toolBinary}`;
|
||||||
default:
|
default:
|
||||||
return `which ${toolBinary}`;
|
return `which ${toolBinary}`;
|
||||||
@@ -304,7 +303,6 @@ export abstract class ToolBase implements ITool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _status: ToolStatus = ToolStatus.NotInstalled;
|
private _status: ToolStatus = ToolStatus.NotInstalled;
|
||||||
private _osType: OsType;
|
|
||||||
private _version?: SemVer;
|
private _version?: SemVer;
|
||||||
private _statusDescription?: string;
|
private _statusDescription?: string;
|
||||||
private _installationPath!: string;
|
private _installationPath!: string;
|
||||||
|
|||||||
28
extensions/resource-deployment/src/typings/linuxReleaseInfo.d.ts
vendored
Normal file
28
extensions/resource-deployment/src/typings/linuxReleaseInfo.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
declare module 'linux-release-info' {
|
||||||
|
namespace linuxReleaseInfo {
|
||||||
|
/**
|
||||||
|
* Get Os release info (distribution name, version, arch, release, etc.) from '/etc/os-release' or '/usr/lib/os-release' files and from native os module. On Windows and Darwin platforms it only returns common node os module info (platform, hostname, release, and arch)
|
||||||
|
* {@param options} - input options of type {@link OsReleaseOptions} - allows user to request sync/async and point to custom file for discovery of release information on linux distributions. If absent, default is async call with no custom file specified.
|
||||||
|
* (@param debug) - whether the api call should spew debug information to the console. Default is false.
|
||||||
|
* {@link https://github.com/samuelcarreira/linux-release-info/blob/master/README.md }
|
||||||
|
*/
|
||||||
|
interface OsReleaseInfoApi {
|
||||||
|
(options?: OsReleaseOptions, debug?: boolean): JSON | Promise<JSON>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OsReleaseOptions {
|
||||||
|
/**
|
||||||
|
* api calling mode: async/sync - default is 'async'
|
||||||
|
*/
|
||||||
|
mode?: 'async'|'sync';
|
||||||
|
/**
|
||||||
|
* path to custom file on the linux os that can be used to discover the distribution information
|
||||||
|
*/
|
||||||
|
customReleaseInfoFile?: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
const osReleaseInfo: linuxReleaseInfo.OsReleaseInfoApi;
|
||||||
|
export = osReleaseInfo;
|
||||||
|
}
|
||||||
@@ -398,6 +398,11 @@ jsprim@^1.2.2:
|
|||||||
json-schema "0.2.3"
|
json-schema "0.2.3"
|
||||||
verror "1.10.0"
|
verror "1.10.0"
|
||||||
|
|
||||||
|
linux-release-info@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/linux-release-info/-/linux-release-info-2.0.0.tgz#bdd4743a3ac49151ce612dbfe063f5eec116aeab"
|
||||||
|
integrity sha512-w0RoUAZOQvnwuypQT+kwiDRNrMrEyrNWC8OOQH4e0Chii/BqB2tq7yeUHKo9brPDymY0Iz7EKe0TtwsflAlOnA==
|
||||||
|
|
||||||
lodash@^4.16.4, lodash@^4.17.4:
|
lodash@^4.16.4, lodash@^4.17.4:
|
||||||
version "4.17.15"
|
version "4.17.15"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
|
||||||
|
|||||||
Reference in New Issue
Block a user