Skip to content

Commit 8b4350c

Browse files
authored
fix: transpilation of k8s.Models.ResourceQuantity (#959)
1 parent e363711 commit 8b4350c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/KubeOps.Transpiler/Crds.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ private static V1JSONSchemaProps MapObjectType(this MetadataLoadContext context,
417417
{
418418
switch (type.FullName)
419419
{
420+
case "k8s.Models.ResourceQuantity":
421+
// Quantities are serialized as strings in CRDs (e.g., "500m", "2Gi")
422+
return new V1JSONSchemaProps { Type = String };
420423
case "k8s.Models.V1ObjectMeta":
421424
return new V1JSONSchemaProps { Type = Object };
422425
case "k8s.Models.IntstrIntOrString":

test/KubeOps.Transpiler.Test/Crds.Mlc.Test.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public partial class CrdsMlcTest(MlcProvider provider) : TranspilerTestBase(prov
3737
[InlineData(typeof(DateTimeOffsetTestEntity), "string", "date-time", null)]
3838
[InlineData(typeof(NullableDateTimeOffsetTestEntity), "string", "date-time", true)]
3939
[InlineData(typeof(V1ObjectMetaTestEntity), "object", null, null)]
40+
[InlineData(typeof(ResourceQuantityTestEntity), "string", null, null)]
4041
[InlineData(typeof(StringArrayEntity), "array", null, null)]
4142
[InlineData(typeof(NullableStringArrayEntity), "array", null, true)]
4243
[InlineData(typeof(EnumerableIntEntity), "array", null, null)]
@@ -631,6 +632,12 @@ private class V1ObjectMetaTestEntity : CustomKubernetesEntity
631632
public V1ObjectMeta Property { get; set; } = null!;
632633
}
633634

635+
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")]
636+
private class ResourceQuantityTestEntity : CustomKubernetesEntity
637+
{
638+
public ResourceQuantity Property { get; set; } = null!;
639+
}
640+
634641
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")]
635642
private class StringArrayEntity : CustomKubernetesEntity
636643
{

0 commit comments

Comments
 (0)