-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathVersionConfiguration.cs
More file actions
183 lines (172 loc) · 5.02 KB
/
VersionConfiguration.cs
File metadata and controls
183 lines (172 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using System.ComponentModel.DataAnnotations;
using NetEscapades.EnumGenerators;
using YamlDotNet.Serialization;
namespace Elastic.Documentation.Configuration.Versions;
[YamlSerializable]
public record VersionsConfiguration
{
public required IReadOnlyDictionary<VersioningSystemId, VersioningSystem> VersioningSystems { get; init; }
public VersioningSystem GetVersioningSystem(VersioningSystemId versioningSystem)
{
if (!VersioningSystems.TryGetValue(versioningSystem, out var version))
throw new ArgumentException($"Unknown versioning system: {versioningSystem}");
return version;
}
}
[EnumExtensions]
public enum VersioningSystemId
{
[Display(Name = "stack")]
Stack,
[Display(Name = "all")]
All,
[Display(Name = "ece")]
Ece,
[Display(Name = "ech")]
Ech,
[Display(Name = "eck")]
Eck,
[Display(Name = "ess")]
Ess,
[Display(Name = "ecs")]
Ecs,
[Display(Name = "self")]
Self,
[Display(Name = "ecctl")]
Ecctl,
[Display(Name = "curator")]
Curator,
[Display(Name = "serverless")]
Serverless,
[Display(Name = "elasticsearch")]
ElasticsearchProject,
[Display(Name = "observability")]
ObservabilityProject,
[Display(Name = "security")]
SecurityProject,
[Display(Name = "apm-agent-android")]
ApmAgentAndroid,
[Display(Name = "apm-agent-ios")]
ApmAgentIos,
[Display(Name = "apm-agent-dotnet")]
ApmAgentDotnet,
[Display(Name = "apm-agent-go")]
ApmAgentGo,
[Display(Name = "apm-agent-java")]
ApmAgentJava,
[Display(Name = "apm-agent-node")]
ApmAgentNode,
[Display(Name = "apm-agent-php")]
ApmAgentPhp,
[Display(Name = "apm-agent-python")]
ApmAgentPython,
[Display(Name = "apm-agent-ruby")]
ApmAgentRuby,
[Display(Name = "apm-agent-rum-js")]
ApmAgentRumJs,
[Display(Name = "apm-attacher")]
ApmAttacher,
[Display(Name = "apm-lambda")]
ApmLambda,
[Display(Name = "ecs-logging-dotnet")]
EcsLoggingDotnet,
[Display(Name = "ecs-logging-go-logrus")]
EcsLoggingGoLogrus,
[Display(Name = "ecs-logging-go-zap")]
EcsLoggingGoZap,
[Display(Name = "ecs-logging-go-zerolog")]
EcsLoggingGoZerolog,
[Display(Name = "ecs-logging-java")]
EcsLoggingJava,
[Display(Name = "ecs-logging-nodejs")]
EcsLoggingNodeJs,
[Display(Name = "ecs-logging-php")]
EcsLoggingPhp,
[Display(Name = "ecs-logging-python")]
EcsLoggingPython,
[Display(Name = "ecs-logging-ruby")]
EcsLoggingRuby,
[Display(Name = "esf")]
Esf,
[Display(Name = "edot-ios")]
EdotIos,
[Display(Name = "edot-android")]
EdotAndroid,
[Display(Name = "edot-dotnet")]
EdotDotnet,
[Display(Name = "edot-java")]
EdotJava,
[Display(Name = "edot-node")]
EdotNode,
[Display(Name = "edot-browser")]
EdotBrowser,
[Display(Name = "edot-php")]
EdotPhp,
[Display(Name = "edot-python")]
EdotPython,
[Display(Name = "edot-cf-aws")]
EdotCfAws,
[Display(Name = "edot-cf-azure")]
EdotCfAzure,
[Display(Name = "edot-cf-gcp")]
EdotCfGcp,
[Display(Name = "terraform-google-edot-cf")]
TerraformGoogleEdotCf,
[Display(Name = "edot-collector")]
EdotCollector,
[Display(Name = "search-ui")]
SearchUI,
[Display(Name = "cloud-terraform")]
CloudTerraform,
[Display(Name = "elasticsearch-client-go")]
ElasticsearchClientGo,
[Display(Name = "elasticsearch-client-java")]
ElasticsearchClientJava,
[Display(Name = "elasticsearch-client-javascript")]
ElasticsearchClientJavascript,
[Display(Name = "elasticsearch-client-dotnet")]
ElasticsearchClientDotnet,
[Display(Name = "elasticsearch-client-php")]
ElasticsearchClientPhp,
[Display(Name = "elasticsearch-client-python")]
ElasticsearchClientPython,
[Display(Name = "elasticsearch-client-ruby")]
ElasticsearchClientRuby,
[Display(Name = "elasticsearch-client-rust")]
ElasticsearchClientRust,
[Display(Name = "none")]
None = -1,
}
[YamlSerializable]
public record VersioningSystem
{
/// <summary>
/// The sentinel major version value used for "versionless" products (serverless, cloud, etc.)
/// Products with this version should not display a version dropdown.
/// </summary>
public const int VersionlessSentinel = 99999;
/// <summary>
/// A versionless sentinel for products that have no versioning system at all
/// (e.g. release-notes-only products without public documentation).
/// </summary>
public static VersioningSystem None { get; } = new()
{
Id = VersioningSystemId.None,
Base = new SemVersion(VersionlessSentinel, 0, 0),
Current = new SemVersion(VersionlessSentinel, 0, 0)
};
public required VersioningSystemId Id { get; init; }
[YamlMember(Alias = "base")]
public required SemVersion Base { get; init; }
[YamlMember(Alias = "current")]
public required SemVersion Current { get; init; }
public bool IsVersioned() => Base.Major != AllVersions.Instance.Major;
/// <summary>
/// Returns true if this versioning system represents a "versionless" product
/// (e.g., serverless, cloud services) that should not display a version dropdown.
/// </summary>
public bool IsVersionless => Current.Major >= VersionlessSentinel;
}