Skip to content

Commit

Permalink
rename ess to hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Dec 12, 2024
1 parent 1fb3b1c commit 3acc7ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 18 additions & 9 deletions src/Elastic.Markdown/Myst/FrontMatterParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public class SelfManagedDeployment
[YamlSerializable]
public class CloudManagedDeployment
{
[YamlMember(Alias = "ess")]
public SemVersion? Ess { get; set; }
[YamlMember(Alias = "hosted")]
public SemVersion? Hosted { get; set; }

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

public static CloudManagedDeployment All { get; } = new()
{
Ess = AllVersions.Instance,
Hosted = AllVersions.Instance,
Serverless = AllVersions.Instance
};

Expand Down Expand Up @@ -121,6 +121,15 @@ public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializ
return;
emitter.Emit(new Scalar(value.ToString()!));
}

public static SemVersion? Parse(string? value) =>
value?.Trim().ToLowerInvariant() switch
{
null => AllVersions.Instance,
"all" => AllVersions.Instance,
"" => AllVersions.Instance,
_ => SemVersion.TryParse(value, out var v) ? v : null
};
}

public class CloudManagedSerializer : IYamlTypeConverter
Expand All @@ -141,10 +150,10 @@ public class CloudManagedSerializer : IYamlTypeConverter
return null;

var cloudManaged = new CloudManagedDeployment();
if (dictionary.TryGetValue("ess", out var v))
cloudManaged.Ess = (SemVersion)v;
if (dictionary.TryGetValue("hosted", out var v))
cloudManaged.Hosted = SemVersionConverter.Parse(v);
if (dictionary.TryGetValue("serverless", out v))
cloudManaged.Serverless = (SemVersion)v;
cloudManaged.Serverless = SemVersionConverter.Parse(v);
return cloudManaged;

}
Expand Down Expand Up @@ -172,11 +181,11 @@ public class SelfManagedSerializer : IYamlTypeConverter

var deployment = new SelfManagedDeployment();
if (dictionary.TryGetValue("stack", out var v))
deployment.Stack = (SemVersion)v;
deployment.Stack = SemVersionConverter.Parse(v);
if (dictionary.TryGetValue("ece", out v))
deployment.Ece = (SemVersion)v;
deployment.Ece = SemVersionConverter.Parse(v);
if (dictionary.TryGetValue("eck", out v))
deployment.Eck = (SemVersion)v;
deployment.Eck = SemVersionConverter.Parse(v);
return deployment;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ public class EmptyCloudSetsAllProductsToAll(ITestOutputHelper output) : Directiv
{
[Fact]
public void Assert() =>
File.YamlFrontMatter!.AppliesTo!.Cloud!.Ess.Should().BeEquivalentTo(AllVersions.Instance);
File.YamlFrontMatter!.AppliesTo!.Cloud!.Hosted.Should().BeEquivalentTo(AllVersions.Instance);
}

0 comments on commit 3acc7ee

Please sign in to comment.