diff --git a/src/KubeOps.Transpiler/Crds.cs b/src/KubeOps.Transpiler/Crds.cs index 17fb25f3..104f67b2 100644 --- a/src/KubeOps.Transpiler/Crds.cs +++ b/src/KubeOps.Transpiler/Crds.cs @@ -417,6 +417,9 @@ private static V1JSONSchemaProps MapObjectType(this MetadataLoadContext context, { switch (type.FullName) { + case "k8s.Models.ResourceQuantity": + // Quantities are serialized as strings in CRDs (e.g., "500m", "2Gi") + return new V1JSONSchemaProps { Type = String }; case "k8s.Models.V1ObjectMeta": return new V1JSONSchemaProps { Type = Object }; case "k8s.Models.IntstrIntOrString": diff --git a/test/KubeOps.Transpiler.Test/Crds.Mlc.Test.cs b/test/KubeOps.Transpiler.Test/Crds.Mlc.Test.cs index f3fcf09e..db2e217f 100644 --- a/test/KubeOps.Transpiler.Test/Crds.Mlc.Test.cs +++ b/test/KubeOps.Transpiler.Test/Crds.Mlc.Test.cs @@ -37,6 +37,7 @@ public partial class CrdsMlcTest(MlcProvider provider) : TranspilerTestBase(prov [InlineData(typeof(DateTimeOffsetTestEntity), "string", "date-time", null)] [InlineData(typeof(NullableDateTimeOffsetTestEntity), "string", "date-time", true)] [InlineData(typeof(V1ObjectMetaTestEntity), "object", null, null)] + [InlineData(typeof(ResourceQuantityTestEntity), "string", null, null)] [InlineData(typeof(StringArrayEntity), "array", null, null)] [InlineData(typeof(NullableStringArrayEntity), "array", null, true)] [InlineData(typeof(EnumerableIntEntity), "array", null, null)] @@ -631,6 +632,12 @@ private class V1ObjectMetaTestEntity : CustomKubernetesEntity public V1ObjectMeta Property { get; set; } = null!; } + [KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")] + private class ResourceQuantityTestEntity : CustomKubernetesEntity + { + public ResourceQuantity Property { get; set; } = null!; + } + [KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")] private class StringArrayEntity : CustomKubernetesEntity {