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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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);
        }