From 6cc86c4ea013fba887e5386e377b5861d81273c9 Mon Sep 17 00:00:00 2001 From: Patrick Evers Date: Tue, 25 Mar 2025 16:05:51 +0100 Subject: [PATCH] Added Int32 and Int64 and Boolean Datatypes --- ...stomResourceDefinitionBuilderExtensions.cs | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/K8sOperator.NET.Generators/Builders/CustomResourceDefinitionBuilderExtensions.cs b/src/K8sOperator.NET.Generators/Builders/CustomResourceDefinitionBuilderExtensions.cs index 6c252b9..b1972c5 100644 --- a/src/K8sOperator.NET.Generators/Builders/CustomResourceDefinitionBuilderExtensions.cs +++ b/src/K8sOperator.NET.Generators/Builders/CustomResourceDefinitionBuilderExtensions.cs @@ -219,9 +219,10 @@ public static TBuilder OfType(this TBuilder builder, string type) /// The type of the builder. /// The builder instance. /// The type of the schema property. + /// /// The configured builder. /// Thrown when the provided type is not valid. - public static TBuilder OfType(this TBuilder builder, Type type) + public static TBuilder OfType(this TBuilder builder, Type type, bool? nullable = false) where TBuilder : IKubernetesObjectBuilder { if (type.FullName == "System.String") @@ -229,14 +230,44 @@ public static TBuilder OfType(this TBuilder builder, Type type) builder.Add(x => { x.Type = "string"; - x.Nullable = false; + x.Nullable = nullable; + }); + return builder; + } + + if (type.FullName == "System.Int32") + { + builder.Add(x => + { + x.Type = "integer"; + x.Nullable = nullable; + }); + return builder; + } + + if (type.FullName == "System.Int64") + { + builder.Add(x => + { + x.Type = "integer"; + x.Nullable = nullable; + }); + return builder; + } + + if (type.FullName == "System.Boolean") + { + builder.Add(x => + { + x.Type = "boolean"; + x.Nullable = nullable; }); return builder; } if (type.Name == typeof(Nullable<>).Name && type.GenericTypeArguments.Length == 1) { - return builder.OfType(type.GenericTypeArguments[0]); + return builder.OfType(type.GenericTypeArguments[0], true); } return type.BaseType?.FullName switch