Add a loadAll to load multiple objects from a single YAML. (and tests) (#344)
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
3a30033090
commit
67be97e74b
26
examples/yaml/Program.cs
Normal file
26
examples/yaml/Program.cs
Normal 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
12
examples/yaml/yaml.csproj
Normal 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>
|
||||
Reference in New Issue
Block a user