mirror of https://github.com/dotnet/tye.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
980 B
29 lines
980 B
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using YamlDotNet.RepresentationModel;
|
|
|
|
namespace Tye
|
|
{
|
|
public sealed class ApplicationYamlWriter
|
|
{
|
|
public static Task WriteAsync(OutputContext output, StreamWriter writer, Application application)
|
|
{
|
|
var yaml = application.Services.SelectMany(s => s.Outputs.OfType<IYamlManifestOutput>()).ToArray();
|
|
if (yaml.Length == 0)
|
|
{
|
|
output.WriteDebugLine($"No yaml manifests found. Skipping.");
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
var yamlStream = new YamlStream(yaml.Select(y => y.Yaml));
|
|
yamlStream.Save(writer, assignAnchors: false);
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|
|
|