Exemplo n.º 1
0
func downloadPluginZip(downloadUrls downloadUrls) (string, error) {
	var platformLinks *platformSpecificUrl
	if strings.Contains(runtime.GOARCH, "64") {
		platformLinks = &downloadUrls.X64
	} else {
		platformLinks = &downloadUrls.X86
	}

	var downloadLink string
	switch runtime.GOOS {
	case "windows":
		downloadLink = platformLinks.Windows
		break
	case "darwin":
		downloadLink = platformLinks.Darwin
		break
	default:
		downloadLink = platformLinks.Linux
		break
	}
	if downloadLink == "" {
		return "", errors.New(fmt.Sprintf("Platform not supported for %s. Download URL not specified.", runtime.GOOS))
	}
	logger.Log.Info("Downloading Plugin... => %s", downloadLink)
	downloadedFile, err := common.DownloadToTempDir(downloadLink)
	if err != nil {
		return "", errors.New(fmt.Sprintf("Could not download File %s: %s", downloadLink, err.Error()))
	}
	return downloadedFile, err
}
Exemplo n.º 2
0
func getPluginInstallJson(plugin string) (string, installResult) {
	versionInstallDescriptionJsonFile := plugin + "-install.json"
	versionInstallDescriptionJsonUrl, result := constructPluginInstallJsonUrl(plugin)
	if !result.Success {
		return "", installError(fmt.Sprintf("Could not construct plugin install json file URL. %s", result.Error))
	}
	downloadedFile, downloadErr := common.DownloadToTempDir(versionInstallDescriptionJsonUrl)
	if downloadErr != nil {
		return "", installError(fmt.Sprintf("Invalid plugin : Could not download %s file. %s", versionInstallDescriptionJsonFile, downloadErr))
	}
	return downloadedFile, installSuccess("")
}
Exemplo n.º 3
0
// DownloadAndUnzip downloads the zip file from given download link and unzips it.
// Returns the unzipped file path.
func DownloadAndUnzip(downloadLink string) (string, error) {
	logger.Debug("Downloading => %s", downloadLink)
	downloadedFile, err := common.DownloadToTempDir(downloadLink)
	if err != nil {
		return "", fmt.Errorf("Could not download file %s: %s", downloadLink, err.Error())
	}
	logger.Debug("Downloaded to %s", downloadedFile)
	defer Remove(downloadedFile)

	unzippedPluginDir, err := common.UnzipArchive(downloadedFile)
	if err != nil {
		return "", fmt.Errorf("Failed to Unzip file %s: %s", downloadedFile, err.Error())
	}
	logger.Debug("Unzipped to => %s\n", unzippedPluginDir)

	return unzippedPluginDir, nil
}