dependencies messages, no curl on win32, fixes to min Version (#8039)

* checking temp work to move to another branch

* removing freeTds

* dependencies Messages and No curl on Win32

* elipsis instead of ...

* add min version check post install and pr fixes

* removing unnecessary comment

* removing old TODO comment

* fix text messages

* add github toke nto electron download (#8047)

* remove hardcode of kubectl version for download
This commit is contained in:
Arvind Ranasaria
2019-10-27 17:13:12 -07:00
committed by GitHub
parent 833adf3515
commit a7f597c943
8 changed files with 158 additions and 80 deletions

View File

@@ -7,7 +7,7 @@ import { SemVer } from 'semver';
import * as nls from 'vscode-nls';
import { Command, OsType, ToolType } from '../../interfaces';
import { IPlatformService } from '../platformService';
import { ToolBase } from './toolBase';
import { ToolBase, dependencyType } from './toolBase';
const localize = nls.loadMessageBundle();
const defaultInstallationRoot = '~/.local/bin';
@@ -72,6 +72,13 @@ 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 get discoveryCommand(): Command {
return {
command: this.discoveryCommandString('az')
@@ -81,66 +88,67 @@ export class AzCliTool extends ToolBase {
const win32InstallationCommands = [
{
comment: localize('resourceDeployment.AziCli.DeletingPreviousAzureCli.msi', "deleting previously downloaded azurecli.msi if one exists ..."),
comment: localize('resourceDeployment.AziCli.DeletingPreviousAzureCli.msi', "deleting previously downloaded azurecli.msi if one exists "),
command: `IF EXIST .\\AzureCLI.msi DEL /F .\\AzureCLI.msi`
},
{
sudo: true,
comment: localize('resourceDeployment.AziCli.DownloadingAndInstallingAzureCli', "downloading azurecli.msi and installing azure-cli ..."),
comment: localize('resourceDeployment.AziCli.DownloadingAndInstallingAzureCli', "downloading azurecli.msi and installing azure-cli "),
command: `powershell -Command "& {(New-Object System.Net.WebClient).DownloadFile('https://aka.ms/installazurecliwindows', 'AzureCLI.msi'); Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /passive /quiet /lvx ADS_AzureCliInstall.log'}"`
},
{
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" `,
ignoreError: true
}
];
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'
},
{
comment: localize('resourceDeployment.AziCli.InstallingAzureCli', "installing azure-cli ..."),
comment: localize('resourceDeployment.AziCli.InstallingAzureCli', "installing azure-cli "),
command: 'brew install azure-cli'
}
];
const linuxInstallationCommands = [
{
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 "),
command: 'apt-get update'
},
{
sudo: true,
comment: localize('resourceDeployment.AziCli.AptGetPackages', "getting packages needed for azure-cli installation ..."),
comment: localize('resourceDeployment.AziCli.AptGetPackages', "getting packages needed for azure-cli installation "),
command: 'apt-get install ca-certificates curl apt-transport-https lsb-release gnupg -y'
},
{
sudo: true,
comment: localize('resourceDeployment.AziCli.DownloadAndInstallingSigningKey', "downloading and installing the signing key for azure-cli ..."),
comment: localize('resourceDeployment.AziCli.DownloadAndInstallingSigningKey', "downloading and installing the signing key for azure-cli "),
command: 'curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null'
},
{
sudo: true,
comment: localize('resourceDeployment.AziCli.AddingAzureCliRepositoryInformation', "adding the azure-cli repository information ..."),
comment: localize('resourceDeployment.AziCli.AddingAzureCliRepositoryInformation', "adding the azure-cli repository information "),
command: 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ `lsb_release -cs` main" | tee /etc/apt/sources.list.d/azure-cli.list'
},
{
sudo: true,
comment: localize('resourceDeployment.AziCli.AptGetUpdateAgain', "updating repository information again for azure-cli ..."),
comment: localize('resourceDeployment.AziCli.AptGetUpdateAgain', "updating repository information again for azure-cli "),
command: 'apt-get update'
},
{
sudo: true,
comment: localize('resourceDeployment.AziCli.InstallingAzureCli', "installing azure-cli ..."),
comment: localize('resourceDeployment.AziCli.InstallingAzureCli', "installing azure-cli "),
command: 'apt-get install azure-cli'
}
];
const defaultInstallationCommands = [
{
sudo: true,
comment: localize('resourceDeployment.AziCli.ScriptedInstall', "download and invoking script to install azure-cli ..."),
comment: localize('resourceDeployment.AziCli.ScriptedInstall', "download and invoking script to install azure-cli "),
command: 'curl -sL https://aka.ms/InstallAzureCLIDeb | bash'
}
];

View File

@@ -3,14 +3,14 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { EOL } from 'os';
import * as vscode from 'vscode';
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 { Command, OsType, ToolType } from '../../interfaces';
import { IPlatformService } from '../platformService';
import { ToolBase } from './toolBase';
import { DeploymentConfigurationKey, AzdataPipInstallUriKey, azdataPipInstallArgsKey } from '../../constants';
import { dependencyType, ToolBase } from './toolBase';
const localize = nls.loadMessageBundle();
@@ -91,11 +91,11 @@ export class AzdataTool extends ToolBase {
private get defaultInstallationCommands(): Command[] {
return [
{
comment: localize('resourceDeployment.Azdata.InstallUpdatePythonRequestsPackage', "installing/updating to latest version of requests python package azdata ..."),
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 ..."),
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata "),
command: `pip3 install -r ${this.azdataInstallUri} ${this.azdataInstallAdditionalArgs} --quiet --user`
}
];
@@ -112,38 +112,45 @@ export class AzdataTool extends ToolBase {
private get azdataInstallAdditionalArgs(): string {
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]]
]);
}
/*
const linuxInstallationCommands = [
{
sudo: true,
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information ..."),
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 ..."),
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 ..."),
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 ..."),
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 ..."),
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information "),
command: 'apt-get update'
},
{
sudo: true,
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata ..."),
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata "),
command: 'apt-get install -y azdata-cli'
}
];

View File

@@ -7,7 +7,7 @@ import { Command, ToolType, OsType } from '../../interfaces';
import * as nls from 'vscode-nls';
import { SemVer } from 'semver';
import { IPlatformService } from '../platformService';
import { ToolBase } from './toolBase';
import { ToolBase, dependencyType } from './toolBase';
const localize = nls.loadMessageBundle();
@@ -75,86 +75,92 @@ export class KubeCtlTool extends ToolBase {
[OsType.darwin, macOsInstallationCommands],
[OsType.others, defaultInstallationCommands]
]);
protected dependenciesByOsType: Map<OsType, dependencyType[]> = new Map<OsType, dependencyType[]>([
[OsType.linux, []],
[OsType.win32, []],
[OsType.darwin, [dependencyType.Brew]],
[OsType.others, [dependencyType.Curl]]
]);
}
const macOsInstallationCommands = [
{
comment: localize('resourceDeployment.Kubectl.UpdatingBrewRepository', "updating your brew repository for kubectl installation ..."),
comment: localize('resourceDeployment.Kubectl.UpdatingBrewRepository', "updating your brew repository for kubectl installation "),
command: 'brew update'
},
{
comment: localize('resourceDeployment.Kubectl.InstallingKubeCtl', "installing kubectl ..."),
comment: localize('resourceDeployment.Kubectl.InstallingKubeCtl', "installing kubectl "),
command: 'brew install kubectl'
}
];
const linuxInstallationCommands = [
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.AptGetUpdate', "updating repository information ..."),
comment: localize('resourceDeployment.Kubectl.AptGetUpdate', "updating repository information "),
command: 'apt-get update'
},
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.AptGetPackages', "getting packages needed for kubectl installation ..."),
comment: localize('resourceDeployment.Kubectl.AptGetPackages', "getting packages needed for kubectl installation "),
command: 'apt-get install -y apt-transport-https'
},
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.DownloadAndInstallingSigningKey', "downloading and installing the signing key for kubectl ..."),
comment: localize('resourceDeployment.Kubectl.DownloadAndInstallingSigningKey', "downloading and installing the signing key for kubectl "),
command: 'curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -'
},
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.AddingKubectlRepositoryInformation', "adding the kubectl repository information ..."),
comment: localize('resourceDeployment.Kubectl.AddingKubectlRepositoryInformation', "adding the kubectl repository information "),
command: 'echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list'
},
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.AptGetUpdate', "updating repository information ..."),
comment: localize('resourceDeployment.Kubectl.AptGetUpdate', "updating repository information "),
command: 'apt-get update'
},
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.InstallingKubectl', "installing kubectl ..."),
comment: localize('resourceDeployment.Kubectl.InstallingKubectl', "installing kubectl "),
command: 'apt-get install -y kubectl'
}
];
// TODO: Remove dependency on curl on Win32 and use powershell Invoke-WebRequest instead
const win32InstallationCommands = [
{
comment: localize('resourceDeployment.Kubectl.DeletePreviousDownloadedKubectl.exe', "deleting previously downloaded kubectl.exe if one exists ..."),
command: `IF EXIST .\kubectl.exe DEL /F .\kubectl.exe`,
comment: localize('resourceDeployment.Kubectl.DeletePreviousDownloadedKubectl.exe', "deleting previously downloaded kubectl.exe if one exists "),
command: 'IF EXIST .\\kubectl.exe DEL /F .\\kubectl.exe',
},
{
comment: localize('resourceDeployment.Kubectl.DownloadingAndInstallingKubectl', "downloading and installing the latest kubectl.exe ..."),
command: `for /f %i in ('curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt') do curl -LO https://storage.googleapis.com/kubernetes-release/release/%i/bin/windows/amd64/kubectl.exe`
comment: localize('resourceDeployment.Kubectl.DownloadingAndInstallingKubectl', "downloading and installing the latest kubectl.exe "),
command: `powershell -Command "& {$WebClient = New-Object System.Net.WebClient; $Version=$WebClient.DownloadString('https://storage.googleapis.com/kubernetes-release/release/stable.txt').Trim();Write-Output \\\"KubeCtl Version=$Version\\\";$Url=\\\"https://storage.googleapis.com/kubernetes-release/release/$Version/bin/windows/amd64/kubectl.exe\\\"; Write-Output \\\"Downloading file: $Url\\\"; $WebClient.DownloadFile($Url, 'kubectl.exe')}"`
}
];
const defaultInstallationCommands = [
{
comment: localize('resourceDeployment.Kubectl.DeletePreviousDownloadedKubectl', "deleting previously downloaded kubectl if one exists ..."),
comment: localize('resourceDeployment.Kubectl.DeletePreviousDownloadedKubectl', "deleting previously downloaded kubectl if one exists "),
command: `[ -e ./kubectl ] && rm -f ./kubectl`,
},
{
comment: localize('resourceDeployment.Kubectl.DownloadingKubectl', "downloading the latest kubectl release ..."),
comment: localize('resourceDeployment.Kubectl.DownloadingKubectl', "downloading the latest kubectl release "),
command: 'curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl'
},
{
comment: localize('resourceDeployment.Kubectl.MakingExecutable', "making kubectl executable ..."),
comment: localize('resourceDeployment.Kubectl.MakingExecutable', "making kubectl executable "),
command: 'chmod +x ./kubectl',
},
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.CleaningUpOldBackups', "cleaning up any previously backed up version in the install location if they exist ..."),
command: `[ -e /usr/local/bin/kubectl] && [ -e /usr/local/bin/kubectl_movedByADS ] && rm -f /usr/local/bin/kubectl_movedByADS`
comment: localize('resourceDeployment.Kubectl.CleaningUpOldBackups', "cleaning up any previously backed up version in the install location if they exist "),
command: '[ -e /usr/local/bin/kubectl] && [ -e /usr/local/bin/kubectl_movedByADS ] && rm -f /usr/local/bin/kubectl_movedByADS'
},
{
sudo: true,
comment: localize('resourceDeployment.Kubectl.BackupCurrentBinary', "backing up any existing kubectl in the install location ..."),
command: `[ -e /usr/local/bin/kubectl ] && mv /usr/local/bin/kubectl /usr/local/bin/kubectl_movedByADS`
comment: localize('resourceDeployment.Kubectl.BackupCurrentBinary', "backing up any existing kubectl in the install location "),
command: '[ -e /usr/local/bin/kubectl ] && mv /usr/local/bin/kubectl /usr/local/bin/kubectl_movedByADS'
},
{
comment: localize('resourceDeployment.Kubectl.MoveToSystemPath', "moving kubectl into the install location in the PATH ..."),
comment: localize('resourceDeployment.Kubectl.MoveToSystemPath', "moving kubectl into the install location in the PATH "),
sudo: true,
command: 'mv ./kubectl /usr/local/bin/kubectl'
}

View File

@@ -14,7 +14,7 @@ import { IPlatformService } from '../platformService';
const localize = nls.loadMessageBundle();
const toolStatusNotInstalled: string = localize('deploymentDialog.ToolStatus.NotInstalled', "Not Installed");
const toolStatusInstalled: string = localize('deploymentDialog.ToolStatus.Installed', "Installed");
const toolStatusInstalling: string = localize('deploymentDialog.ToolStatus.Installing', "Installing");
const toolStatusInstalling: string = localize('deploymentDialog.ToolStatus.Installing', "Installing");
const toolStatusError: string = localize('deploymentDialog.ToolStatus.Error', "Error");
const toolStatusFailed: string = localize('deploymentDialog.ToolStatus.Failed', "Failed");
@@ -26,6 +26,22 @@ const toolStatusLocalized: Map<ToolStatus, string> = new Map<ToolStatus, string>
[ToolStatus.Failed, toolStatusFailed]
]);
export const enum dependencyType {
PythonAndPip3 = 'PythonAndPip3',
Brew = 'Brew',
Curl = 'Curl'
}
const pythonAndPip3Localized = localize('deploymentDialog.ToolInformationalMessage.PythonAndPip3', "• azdata installation needs python3 and pip3 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]
]);
export abstract class ToolBase implements ITool {
constructor(private _platformService: IPlatformService) {
this._osType = this._platformService.osType();
@@ -38,13 +54,22 @@ export abstract class ToolBase implements ITool {
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 getVersionFromOutput(output: string): SemVer | undefined;
protected readonly _onDidUpdateData = new vscode.EventEmitter<ITool>();
protected readonly uninstallCommand?: string;
protected abstract readonly versionCommand: Command;
public get dependencyMessages(): string[] {
return (this.dependenciesByOsType.get(this.osType) || []).map((msgType: dependencyType) => messageByDependencyType.get(msgType)!);
}
protected async getInstallationPath(): Promise<string | undefined> {
return undefined;
}
protected abstract readonly discoveryCommand: Command;
protected async getSearchPaths(): Promise<string[]> {
@@ -63,11 +88,11 @@ export abstract class ToolBase implements ITool {
return this._onDidUpdateData.event;
}
get status(): ToolStatus {
protected get status(): ToolStatus {
return this._status;
}
set status(value: ToolStatus) {
protected set status(value: ToolStatus) {
this._status = value;
this._onDidUpdateData.fire(this);
}
@@ -84,6 +109,10 @@ export abstract class ToolBase implements ITool {
return this.status === ToolStatus.NotInstalled;
}
public get isInstalled(): boolean {
return this.status === ToolStatus.Installed;
}
public get isInstalling(): boolean {
return this.status === ToolStatus.Installing;
}
@@ -154,6 +183,7 @@ export abstract class ToolBase implements ITool {
}
public async install(): Promise<void> {
this._statusDescription = '';
try {
this.status = ToolStatus.Installing;
await this.installCore();
@@ -221,6 +251,7 @@ export abstract class ToolBase implements ITool {
}
private async updateVersionAndGetStatus(): Promise<ToolStatus> {
this._statusDescription = '';
const commandOutput = await this._platformService.runCommand(
this.versionCommand.command,
{
@@ -271,10 +302,7 @@ export abstract class ToolBase implements ITool {
}
isSameOrNewerThan(version: string): boolean {
const currentVersion = new SemVer(this.fullVersion!);
const requiredVersion = new SemVer(version);
return compare(currentVersion, requiredVersion) >= 0;
return this._version ? compare(this._version, new SemVer(version)) >= 0 : false;
}
private _storagePathEnsured: boolean = false;