public PackagePhysicalFileMetadata DownloadPackage(string packageId,
                                                           IVersion version,
                                                           string feedId,
                                                           Uri feedUri,
                                                           FeedType feedType,
                                                           string feedUsername,
                                                           string feedPassword,
                                                           bool forcePackageDownload,
                                                           int maxDownloadAttempts,
                                                           TimeSpan downloadAttemptBackoff)
        {
            IPackageDownloader?downloader = null;

            switch (feedType)
            {
            case FeedType.Maven:
                downloader = new MavenPackageDownloader(fileSystem);
                break;

            case FeedType.NuGet:
                downloader = new NuGetPackageDownloader(fileSystem, variables);
                break;

            case FeedType.GitHub:
                downloader = new GitHubPackageDownloader(log, fileSystem);
                break;

            case FeedType.Helm:
                downloader = new HelmChartPackageDownloader(fileSystem);
                break;

            case FeedType.Docker:
            case FeedType.AwsElasticContainerRegistry:
                downloader = new DockerImagePackageDownloader(engine, fileSystem, commandLineRunner, variables, log);
                break;

            case FeedType.S3:
                downloader = new S3PackageDownloader(log, fileSystem);
                break;

            default:
                throw new NotImplementedException($"No Calamari downloader exists for feed type `{feedType}`.");
            }
            Log.Verbose($"Feed type provided `{feedType}` using {downloader.GetType().Name}");

            return(downloader.DownloadPackage(
                       packageId,
                       version,
                       feedId,
                       feedUri,
                       feedUsername,
                       feedPassword,
                       forcePackageDownload,
                       maxDownloadAttempts,
                       downloadAttemptBackoff));
        }
        private void DownloadPackage(string packageId, NuGetVersion version, Uri feedUri, ICredentials feedCredentials, string cacheDirectory, int maxDownloadAttempts, TimeSpan downloadAttemptBackoff, out LocalNuGetPackage downloaded, out string downloadedTo)
        {
            Log.Info("Downloading NuGet package {0} {1} from feed: '{2}'", packageId, version, feedUri);
            Log.VerboseFormat("Downloaded package will be stored in: '{0}'", cacheDirectory);
            fileSystem.EnsureDirectoryExists(cacheDirectory);
            fileSystem.EnsureDiskHasEnoughFreeSpace(cacheDirectory);

            var fullPathToDownloadTo = GetFilePathToDownloadPackageTo(cacheDirectory, packageId, version.ToString());

            var downloader = new NuGetPackageDownloader(fileSystem);
            downloader.DownloadPackage(packageId, version, feedUri, feedCredentials, fullPathToDownloadTo, maxDownloadAttempts, downloadAttemptBackoff);

            downloaded = new LocalNuGetPackage(fullPathToDownloadTo);
            downloadedTo = fullPathToDownloadTo;
            CheckWhetherThePackageHasDependencies(downloaded.Metadata);
        }
Пример #3
0
        public PackagePhysicalFileMetadata DownloadPackage(
            string packageId,
            IVersion version,
            string feedId,
            Uri feedUri,
            FeedType feedType,
            ICredentials feedCredentials,
            bool forcePackageDownload,
            int maxDownloadAttempts,
            TimeSpan downloadAttemptBackoff)
        {
            IPackageDownloader downloader = null;

            switch (feedType)
            {
            case FeedType.Maven:
                downloader = new MavenPackageDownloader();
                break;

            case FeedType.NuGet:
                downloader = new NuGetPackageDownloader();
                break;

            case FeedType.GitHub:
                downloader = new GitHubPackageDownloader();
                break;

            case FeedType.Helm:
                downloader = new HelmChartPackageDownloader(engine, fileSystem, commandLineRunner);
                break;

            default:
                throw new NotImplementedException($"No Calamari downloader exists for feed type `{feedType}`.");
            }
            Log.Verbose($"Feed type provided `{feedType}` using {downloader.GetType().Name}");

            return(downloader.DownloadPackage(
                       packageId,
                       version,
                       feedId,
                       feedUri,
                       feedCredentials,
                       forcePackageDownload,
                       maxDownloadAttempts,
                       downloadAttemptBackoff));
        }
Пример #4
0
        public void DownloadPackage(
            string packageId,
            IVersion version,
            string feedId,
            Uri feedUri,
            ICredentials feedCredentials,
            bool forcePackageDownload,
            int maxDownloadAttempts,
            TimeSpan downloadAttemptBackoff,
            out string downloadedTo,
            out string hash,
            out long size)
        {
            IPackageDownloader downloader = null;

            if (MavenPackageIdParser.TryGetMetadataFromPackageID(packageId, out var mavenMetadata))
            {
                downloader = new MavenPackageDownloader();
            }
            else if (NugetPackageIdParser.TryGetMetadataFromPackageID(packageId, out var nugetMetadata))
            {
                downloader = new NuGetPackageDownloader();
            }
            else
            {
                throw new NotImplementedException($"Package ID {packageId} is not recognised.");
            }

            downloader.DownloadPackage(
                packageId,
                version,
                feedId,
                feedUri,
                feedCredentials,
                forcePackageDownload,
                maxDownloadAttempts,
                downloadAttemptBackoff,
                out downloadedTo,
                out hash,
                out size);
        }