in src/Elastic.Markdown/Myst/FrontMatter/Deployment.cs [72:140]
public object? ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
{
if (parser.TryConsume<Scalar>(out var value))
{
if (string.IsNullOrWhiteSpace(value.Value))
return Deployment.All;
if (string.Equals(value.Value, "all", StringComparison.InvariantCultureIgnoreCase))
return Deployment.All;
}
var deserialized = rootDeserializer.Invoke(typeof(Dictionary<string, string>));
if (deserialized is not Dictionary<string, string> { Count: > 0 } dictionary)
return null;
var deployment = new Deployment();
if (TryGetAvailability("cloud", out var version))
{
deployment.Cloud ??= new CloudManagedDeployment();
deployment.Cloud.Serverless = version;
deployment.Cloud.Hosted = version;
}
if (TryGetAvailability("self", out version))
{
deployment.SelfManaged ??= new SelfManagedDeployment();
deployment.SelfManaged.Ece = version;
deployment.SelfManaged.Eck = version;
deployment.SelfManaged.Stack = version;
}
if (TryGetAvailability("stack", out version))
{
deployment.SelfManaged ??= new SelfManagedDeployment();
deployment.SelfManaged.Stack = version;
}
if (TryGetAvailability("ece", out version))
{
deployment.SelfManaged ??= new SelfManagedDeployment();
deployment.SelfManaged.Ece = version;
}
if (TryGetAvailability("eck", out version))
{
deployment.SelfManaged ??= new SelfManagedDeployment();
deployment.SelfManaged.Eck = version;
}
if (TryGetAvailability("hosted", out version))
{
deployment.Cloud ??= new CloudManagedDeployment();
deployment.Cloud.Hosted = version;
}
if (TryGetAvailability("serverless", out version))
{
deployment.Cloud ??= new CloudManagedDeployment();
deployment.Cloud.Serverless = version;
}
return deployment;
bool TryGetAvailability(string key, out Applicability? semVersion)
{
semVersion = null;
return dictionary.TryGetValue(key, out var v) && Applicability.TryParse(v, out semVersion);
}
}