Provide strict k8s yaml model deserializer (#1047)

* Provide strict k8s yaml model deserializer

* Provide documentation

* Add UT coverage
This commit is contained in:
stan-sz
2022-10-14 11:44:47 +02:00
committed by GitHub
parent 6a7e9b2d7b
commit 0b67950590
3 changed files with 33 additions and 19 deletions

View File

@@ -79,6 +79,7 @@ metadata:
name: ns
youDontKnow: Me";
Assert.Throws<YamlDotNet.Core.YamlException>(() => KubernetesYaml.LoadAllFromString(content, strict: true));
var objs = KubernetesYaml.LoadAllFromString(content);
Assert.Equal(2, objs.Count);
Assert.IsType<V1Pod>(objs[0]);
@@ -109,6 +110,7 @@ metadata:
name: ns
youDontKnow: Me";
Assert.Throws<YamlDotNet.Core.YamlException>(() => KubernetesYaml.LoadAllFromString(content, strict: true));
var objs = KubernetesYaml.LoadAllFromString(content, types);
Assert.Equal(2, objs.Count);
Assert.IsType<MyPod>(objs[0]);
@@ -218,6 +220,7 @@ metadata:
var obj = KubernetesYaml.Deserialize<V1Pod>(content);
Assert.Equal("foo", obj.Metadata.Name);
Assert.Throws<YamlDotNet.Core.YamlException>(() => KubernetesYaml.Deserialize<V1Pod>(content, strict: true));
}
[Fact]
@@ -233,6 +236,7 @@ metadata:
var obj = KubernetesYaml.Deserialize<V1Pod>(content);
Assert.Equal("foo", obj.Metadata.Name);
Assert.Throws<YamlDotNet.Core.YamlException>(() => KubernetesYaml.Deserialize<V1Pod>(content, strict: true));
}
[Fact]