Add a loadAll to load multiple objects from a single YAML. (and tests) (#344)

This commit is contained in:
Brendan Burns
2020-01-10 13:59:37 -08:00
committed by Kubernetes Prow Robot
parent 3a30033090
commit 67be97e74b
4 changed files with 140 additions and 1 deletions

26
examples/yaml/Program.cs Normal file
View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using k8s;
using k8s.Models;
namespace yaml
{
internal class Program
{
private async static Task Main(string[] args)
{
var typeMap = new Dictionary<String, Type>();
typeMap.Add("v1/Pod", typeof(V1Pod));
typeMap.Add("v1/Service", typeof(V1Service));
typeMap.Add("apps/v1beta1/Deployment", typeof(Appsv1beta1Deployment));
var objects = await Yaml.LoadAllFromFileAsync(args[0], typeMap);
foreach (var obj in objects) {
Console.WriteLine(obj);
}
}
}
}

12
examples/yaml/yaml.csproj Normal file
View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\src\KubernetesClient\KubernetesClient.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>