Skip to content

Commit 3acc7ee

Browse files
committed
rename ess to hosted
1 parent 1fb3b1c commit 3acc7ee

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/Elastic.Markdown/Myst/FrontMatterParser.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ public class SelfManagedDeployment
6868
[YamlSerializable]
6969
public class CloudManagedDeployment
7070
{
71-
[YamlMember(Alias = "ess")]
72-
public SemVersion? Ess { get; set; }
71+
[YamlMember(Alias = "hosted")]
72+
public SemVersion? Hosted { get; set; }
7373

7474
[YamlMember(Alias = "serverless")]
7575
public SemVersion? Serverless { get; set; }
7676

7777
public static CloudManagedDeployment All { get; } = new()
7878
{
79-
Ess = AllVersions.Instance,
79+
Hosted = AllVersions.Instance,
8080
Serverless = AllVersions.Instance
8181
};
8282

@@ -121,6 +121,15 @@ public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializ
121121
return;
122122
emitter.Emit(new Scalar(value.ToString()!));
123123
}
124+
125+
public static SemVersion? Parse(string? value) =>
126+
value?.Trim().ToLowerInvariant() switch
127+
{
128+
null => AllVersions.Instance,
129+
"all" => AllVersions.Instance,
130+
"" => AllVersions.Instance,
131+
_ => SemVersion.TryParse(value, out var v) ? v : null
132+
};
124133
}
125134

126135
public class CloudManagedSerializer : IYamlTypeConverter
@@ -141,10 +150,10 @@ public class CloudManagedSerializer : IYamlTypeConverter
141150
return null;
142151

143152
var cloudManaged = new CloudManagedDeployment();
144-
if (dictionary.TryGetValue("ess", out var v))
145-
cloudManaged.Ess = (SemVersion)v;
153+
if (dictionary.TryGetValue("hosted", out var v))
154+
cloudManaged.Hosted = SemVersionConverter.Parse(v);
146155
if (dictionary.TryGetValue("serverless", out v))
147-
cloudManaged.Serverless = (SemVersion)v;
156+
cloudManaged.Serverless = SemVersionConverter.Parse(v);
148157
return cloudManaged;
149158

150159
}
@@ -172,11 +181,11 @@ public class SelfManagedSerializer : IYamlTypeConverter
172181

173182
var deployment = new SelfManagedDeployment();
174183
if (dictionary.TryGetValue("stack", out var v))
175-
deployment.Stack = (SemVersion)v;
184+
deployment.Stack = SemVersionConverter.Parse(v);
176185
if (dictionary.TryGetValue("ece", out v))
177-
deployment.Ece = (SemVersion)v;
186+
deployment.Ece = SemVersionConverter.Parse(v);
178187
if (dictionary.TryGetValue("eck", out v))
179-
deployment.Eck = (SemVersion)v;
188+
deployment.Eck = SemVersionConverter.Parse(v);
180189
return deployment;
181190

182191
}

tests/Elastic.Markdown.Tests/FrontMatter/ProductConstraintTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,5 @@ public class EmptyCloudSetsAllProductsToAll(ITestOutputHelper output) : Directiv
8989
{
9090
[Fact]
9191
public void Assert() =>
92-
File.YamlFrontMatter!.AppliesTo!.Cloud!.Ess.Should().BeEquivalentTo(AllVersions.Instance);
92+
File.YamlFrontMatter!.AppliesTo!.Cloud!.Hosted.Should().BeEquivalentTo(AllVersions.Instance);
9393
}

0 commit comments

Comments
 (0)