Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/KubeOps.Transpiler/Crds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
7 changes: 7 additions & 0 deletions test/KubeOps.Transpiler.Test/Crds.Mlc.Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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
{
Expand Down