Пример #1
0
        private static string TranslateConfigVersion(string configMoniker, ElasticsearchVersionResolver resolver)
        {
            switch (configMoniker)
            {
            case "latest": return(resolver.LatestVersion);

            case string _ when TryParseBuildCandidate(configMoniker, out var version, out _):
                return(version);

            default: return(configMoniker);
            }
        }
Пример #2
0
        internal ElasticsearchVersion(string version, ElasticsearchVersionResolver resolver)
            : base(TranslateConfigVersion(version, resolver))
        {
            this._resolver   = resolver;
            this.Version     = version;
            this.ZipFilename = $"elasticsearch-{this.Version}.zip";
            switch (version)
            {
            case "latest":
                this.State           = ReleaseState.Released;
                this.Version         = _resolver.LatestVersion;
                this.ZipFilename     = _resolver.LatestSnapshot;
                this.RootUrl         = ArtifactsUrl;
                this.LocalFolderName = this.Version;
                break;

            case string snapShotVersion when version.EndsWith("-snapshot", StringComparison.OrdinalIgnoreCase):
                this.State = ReleaseState.Snapshot;

                this.RootUrl                  = ElasticsearchVersionResolver.SonaTypeUrl;
                this.ZipFilename              = resolver.SnapshotZipFilename(version);
                this.LocalFolderName          = this.ZipFilename?.Replace(".zip", "").Replace("elasticsearch-", "");
                this.ElasticsearchDownloadUrl = $"{this.RootUrl}/{this.Version}/{this.ZipFilename}";
                break;

            case string bcVersion when TryParseBuildCandidate(version, out var v, out var gitHash):
                this.State = ReleaseState.BuildCandidate;

                this.Version     = v;
                this.RootUrl     = string.Format(StagingUrlFormat, v, gitHash);
                this.ZipFilename = $"elasticsearch-{this.Version}.zip";
                this.ElasticsearchDownloadUrl = $"{this.RootUrl}/downloads/elasticsearch/{this.ZipFilename}";
                this.LocalFolderName          = $"{v}-bc+{gitHash}";
                break;

            default:
                this.State   = ReleaseState.Released;
                this.RootUrl = ArtifactsUrl;
                break;
            }


            this.ElasticsearchDownloadUrl = this.ElasticsearchDownloadUrl ?? $"{this.RootUrl}/{this.ZipFilename}";
            this.LocalFolderName          = this.LocalFolderName ?? this.Version;
        }
Пример #3
0
 /// <summary>
 /// Represents an Elasticsearch version and its download locations
 /// <pre>Follows a static factory pattern to create new instances because based on the version it calls out to the internet to learn more</pre>
 /// </summary>
 /// <param name="version">Can be either a released version, snapshot version or a build candidate following a githash:version pattern</param>
 /// <param name="resolver">A resolver that can find out the latest elasticsearch version</param>
 /// <returns></returns>
 public static ElasticsearchVersion Create(string version, ElasticsearchVersionResolver resolver = null)
 {
     return(resolver == null
                         ? Versions.GetOrAdd(version, v => new ElasticsearchVersion(v, ElasticsearchVersionResolver.Default))
                         : new ElasticsearchVersion(version, resolver));
 }