diff --git a/README.md b/README.md index e7ab6bd4..70416cb1 100644 --- a/README.md +++ b/README.md @@ -12,17 +12,21 @@ detailed documentation, head to the [GitHub Pages](https://buehler.github.io/dot ## Packages +All packages support .NET6.0 and higher. The reason is that modern C# features are +used and client libraries are still possible for .NET 6.0 and up. +Also, the KubernetesClient package follows the same strategy regarding the +older framework versions. The following packages exist: -| Package | Description | Framework Support | Latest Version | -|----------------------------------------------------------------------|--------------------------------------------------------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| [KubeOps.Abstractions](./src/KubeOps.Abstractions/README.md) | Contains abstractions, attributes, etc. for the SDK | netstandard2.0 netstandard2.1 net6.0 net7.0 | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Abstractions?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Abstractions/absoluteLatest) | -| [KubeOps.Cli](./src/KubeOps.Cli/README.md) | CLI Dotnet Tool to generate stuff | net7.0 | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Cli?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Cli/absoluteLatest) | -| [KubeOps.Generator](./src/KubeOps.Generator/README.md) | Source Generator for the SDK | netstandard2.0 | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Generator?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Generator/absoluteLatest) | -| [KubeOps.KubernetesClient](./src/KubeOps.KubernetesClient/README.md) | Extended client to communicate with the Kubernetes API | net6.0 net7.0 | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.KubernetesClient?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.KubernetesClient/absoluteLatest) | -| [KubeOps.Operator](./src/KubeOps.Operator/README.md) | Main SDK entrypoint to create an operator | net6.0 net7.0 | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Operator?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Operator/absoluteLatest) | -| [KubeOps.Operator.Web](./src/KubeOps.Operator.Web/README.md) | Web part of the operator (for webhooks) | net6.0 net7.0 | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Operator.Web?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Operator.Web/absoluteLatest) | -| [KubeOps.Transpiler](./src/KubeOps.Transpiler/README.md) | Transpilation helpers for CRDs and RBAC elements | netstandard2.0 netstandard2.1 net6.0 net7.0 | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Transpiler?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Transpiler/absoluteLatest) | +| Package | Description | Latest Version | +|----------------------------------------------------------------------|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [KubeOps.Abstractions](./src/KubeOps.Abstractions/README.md) | Contains abstractions, attributes, etc. for the SDK | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Abstractions?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Abstractions/absoluteLatest) | +| [KubeOps.Cli](./src/KubeOps.Cli/README.md) | CLI Dotnet Tool to generate stuff | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Cli?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Cli/absoluteLatest) | +| [KubeOps.Generator](./src/KubeOps.Generator/README.md) | Source Generator for the SDK | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Generator?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Generator/absoluteLatest) | +| [KubeOps.KubernetesClient](./src/KubeOps.KubernetesClient/README.md) | Extended client to communicate with the Kubernetes API | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.KubernetesClient?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.KubernetesClient/absoluteLatest) | +| [KubeOps.Operator](./src/KubeOps.Operator/README.md) | Main SDK entrypoint to create an operator | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Operator?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Operator/absoluteLatest) | +| [KubeOps.Operator.Web](./src/KubeOps.Operator.Web/README.md) | Web part of the operator (for webhooks) | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Operator.Web?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Operator.Web/absoluteLatest) | +| [KubeOps.Transpiler](./src/KubeOps.Transpiler/README.md) | Transpilation helpers for CRDs and RBAC elements | [![Nuget](https://img.shields.io/nuget/vpre/KubeOps.Transpiler?label=nuget%20prerelease)](https://www.nuget.org/packages/KubeOps.Transpiler/absoluteLatest) | ## Contribution diff --git a/src/KubeOps.Abstractions/Controller/IEntityController{TEntity}.cs b/src/KubeOps.Abstractions/Controller/IEntityController{TEntity}.cs index c37fdd1d..7d3c3892 100644 --- a/src/KubeOps.Abstractions/Controller/IEntityController{TEntity}.cs +++ b/src/KubeOps.Abstractions/Controller/IEntityController{TEntity}.cs @@ -41,12 +41,8 @@ public interface IEntityController /// /// The entity that fired the reconcile event. /// A task that completes when the reconciliation is done. -#if NETSTANDARD2_0 - Task ReconcileAsync(TEntity entity); -#else Task ReconcileAsync(TEntity entity) => Task.CompletedTask; -#endif /// /// Called for `delete` events for a given entity. @@ -55,10 +51,6 @@ Task ReconcileAsync(TEntity entity) => /// /// A task that completes, when the reconciliation is done. /// -#if NETSTANDARD2_0 - Task DeletedAsync(TEntity entity); -#else Task DeletedAsync(TEntity entity) => Task.CompletedTask; -#endif } diff --git a/src/KubeOps.Abstractions/Entities/Attributes/GenericAdditionalPrinterColumnAttribute.cs b/src/KubeOps.Abstractions/Entities/Attributes/GenericAdditionalPrinterColumnAttribute.cs index 236c75c5..fc39dabb 100644 --- a/src/KubeOps.Abstractions/Entities/Attributes/GenericAdditionalPrinterColumnAttribute.cs +++ b/src/KubeOps.Abstractions/Entities/Attributes/GenericAdditionalPrinterColumnAttribute.cs @@ -1,6 +1,4 @@ -using k8s.Models; - -namespace KubeOps.Abstractions.Entities.Attributes; +namespace KubeOps.Abstractions.Entities.Attributes; /// /// Defines a generic additional printer column. @@ -40,11 +38,7 @@ public GenericAdditionalPrinterColumnAttribute(string jsonPath, string name, str /// /// Description for the column. /// -#if NETSTANDARD - public string? Description { get; set; } -#else public string? Description { get; init; } -#endif /// /// The type of the column. @@ -104,11 +98,7 @@ public GenericAdditionalPrinterColumnAttribute(string jsonPath, string name, str /// /// /// -#if NETSTANDARD - public string? Format { get; set; } -#else public string? Format { get; init; } -#endif /// /// The priority of the additional printer column. @@ -124,9 +114,5 @@ public GenericAdditionalPrinterColumnAttribute(string jsonPath, string name, str /// /// /// -#if NETSTANDARD - public PrinterColumnPriority Priority { get; set; } -#else public PrinterColumnPriority Priority { get; init; } -#endif } diff --git a/src/KubeOps.Abstractions/Entities/EntityMetadata.cs b/src/KubeOps.Abstractions/Entities/EntityMetadata.cs index 67a65b33..16323660 100644 --- a/src/KubeOps.Abstractions/Entities/EntityMetadata.cs +++ b/src/KubeOps.Abstractions/Entities/EntityMetadata.cs @@ -1,6 +1,5 @@ namespace KubeOps.Abstractions.Entities; -#if NET /// /// Metadata for a given entity. /// @@ -25,53 +24,3 @@ public record EntityMetadata(string Kind, string Version, string? Group = null, /// public string PluralName => Plural ?? $"{Kind.ToLower()}s"; } -#else -/// -/// Metadata for a given entity. -/// -public class EntityMetadata -{ - public EntityMetadata(string kind, string version, string? group = null, string? plural = null) - { - Kind = kind; - Version = version; - Group = group; - Plural = plural; - } - - /// - /// The kind of the entity (e.g. deployment). - /// - public string Kind { get; } - - /// - /// Version (e.g. v1 or v2-alpha). - /// - public string Version { get; } - - /// - /// The group in Kubernetes (e.g. "testing.dev"). - /// - public string? Group { get; } - - /// - /// An optional plural name. Defaults to the singular name with an added "s". - /// - public string? Plural { get; } - - /// - /// Kind of the entity when used in a list. - /// - public string ListKind => $"{Kind}List"; - - /// - /// Name of the singular entity. - /// - public string SingularName => Kind.ToLower(); - - /// - /// Name of the plural entity. - /// - public string PluralName => Plural ?? $"{Kind.ToLower()}s"; -} -#endif diff --git a/src/KubeOps.Abstractions/Finalizer/IEntityFinalizer{TEntity}.cs b/src/KubeOps.Abstractions/Finalizer/IEntityFinalizer{TEntity}.cs index 68a894b6..1bb9114c 100644 --- a/src/KubeOps.Abstractions/Finalizer/IEntityFinalizer{TEntity}.cs +++ b/src/KubeOps.Abstractions/Finalizer/IEntityFinalizer{TEntity}.cs @@ -15,10 +15,6 @@ public interface IEntityFinalizer /// /// The kubernetes entity that needs to be finalized. /// A task that resolves when the operation is done. -#if NETSTANDARD2_0 - Task FinalizeAsync(TEntity entity); -#else Task FinalizeAsync(TEntity entity) => Task.CompletedTask; -#endif } diff --git a/src/KubeOps.Abstractions/KubeOps.Abstractions.csproj b/src/KubeOps.Abstractions/KubeOps.Abstractions.csproj index ceaad1ab..67780995 100644 --- a/src/KubeOps.Abstractions/KubeOps.Abstractions.csproj +++ b/src/KubeOps.Abstractions/KubeOps.Abstractions.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net6.0;net7.0 + net6.0;net7.0 @@ -14,11 +14,8 @@ - + - - - diff --git a/src/KubeOps.Abstractions/Rbac/EntityRbacAttribute.cs b/src/KubeOps.Abstractions/Rbac/EntityRbacAttribute.cs index 248b81fb..45befffb 100644 --- a/src/KubeOps.Abstractions/Rbac/EntityRbacAttribute.cs +++ b/src/KubeOps.Abstractions/Rbac/EntityRbacAttribute.cs @@ -31,9 +31,5 @@ public EntityRbacAttribute(params Type[] entities) /// "verbs: ["get", "list", "watch"]". /// /// -#if NETSTANDARD - public RbacVerb Verbs { get; set; } -#else public RbacVerb Verbs { get; init; } -#endif } diff --git a/src/KubeOps.Abstractions/Rbac/GenericRbacAttribute.cs b/src/KubeOps.Abstractions/Rbac/GenericRbacAttribute.cs index 856131f1..26e38928 100644 --- a/src/KubeOps.Abstractions/Rbac/GenericRbacAttribute.cs +++ b/src/KubeOps.Abstractions/Rbac/GenericRbacAttribute.cs @@ -18,11 +18,7 @@ public class GenericRbacAttribute : RbacAttribute /// "apiGroups: ...". /// /// -#if NETSTANDARD - public string[] Groups { get; set; } = { }; -#else public string[] Groups { get; init; } = Array.Empty(); -#endif /// /// List of resources. @@ -31,20 +27,12 @@ public class GenericRbacAttribute : RbacAttribute /// "resources: ["pods"]". /// /// -#if NETSTANDARD - public string[] Resources { get; set; } = { }; -#else public string[] Resources { get; init; } = Array.Empty(); -#endif /// /// List of urls. /// -#if NETSTANDARD - public string[] Urls { get; set; } = { }; -#else public string[] Urls { get; init; } = Array.Empty(); -#endif /// /// Flags ("list") of allowed verbs. @@ -53,9 +41,5 @@ public class GenericRbacAttribute : RbacAttribute /// "verbs: ["get", "list", "watch"]". /// /// -#if NETSTANDARD - public RbacVerb Verbs { get; set; } -#else public RbacVerb Verbs { get; init; } -#endif } diff --git a/src/KubeOps.Cli/KubeOps.Cli.csproj b/src/KubeOps.Cli/KubeOps.Cli.csproj index 8ff7ce8e..d392c3b5 100644 --- a/src/KubeOps.Cli/KubeOps.Cli.csproj +++ b/src/KubeOps.Cli/KubeOps.Cli.csproj @@ -18,7 +18,6 @@ - diff --git a/src/KubeOps.KubernetesClient/KubeOps.KubernetesClient.csproj b/src/KubeOps.KubernetesClient/KubeOps.KubernetesClient.csproj index 1881ddab..22db8934 100644 --- a/src/KubeOps.KubernetesClient/KubeOps.KubernetesClient.csproj +++ b/src/KubeOps.KubernetesClient/KubeOps.KubernetesClient.csproj @@ -15,10 +15,6 @@ - - - - diff --git a/src/KubeOps.Operator.Web/KubeOps.Operator.Web.csproj b/src/KubeOps.Operator.Web/KubeOps.Operator.Web.csproj index 352a6f22..4aff8b77 100644 --- a/src/KubeOps.Operator.Web/KubeOps.Operator.Web.csproj +++ b/src/KubeOps.Operator.Web/KubeOps.Operator.Web.csproj @@ -18,6 +18,7 @@ + diff --git a/src/KubeOps.Operator/KubeOps.Operator.csproj b/src/KubeOps.Operator/KubeOps.Operator.csproj index bb7f8240..18431d78 100644 --- a/src/KubeOps.Operator/KubeOps.Operator.csproj +++ b/src/KubeOps.Operator/KubeOps.Operator.csproj @@ -16,7 +16,6 @@ - diff --git a/src/KubeOps.Transpiler/Crds.cs b/src/KubeOps.Transpiler/Crds.cs index af3e1792..e695aa42 100644 --- a/src/KubeOps.Transpiler/Crds.cs +++ b/src/KubeOps.Transpiler/Crds.cs @@ -304,11 +304,7 @@ public static string PropertyName(PropertyInfo prop) { Name: { } attrName } => attrName, }; -#if NETSTANDARD2_0 - return $"{name.Substring(0, 1).ToLowerInvariant()}{name.Substring(1)}"; -#else return $"{name[..1].ToLowerInvariant()}{name[1..]}"; -#endif } private static Func, V1JSONSchemaProps?> Mapper( @@ -475,9 +471,7 @@ private static bool IsSimpleType(Type type) => private static bool IsGenericEnumerableType( Type type, -#if NET [NotNullWhen(true)] -#endif out Type? closingType) { if (type.IsGenericType && typeof(IEnumerable<>).IsAssignableFrom(type.GetGenericTypeDefinition())) diff --git a/src/KubeOps.Transpiler/KubeOps.Transpiler.csproj b/src/KubeOps.Transpiler/KubeOps.Transpiler.csproj index 556a3162..f8120036 100644 --- a/src/KubeOps.Transpiler/KubeOps.Transpiler.csproj +++ b/src/KubeOps.Transpiler/KubeOps.Transpiler.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1;net6.0;net7.0 + net6.0;net7.0 @@ -15,7 +15,6 @@ - diff --git a/src/KubeOps.Transpiler/Rbac.cs b/src/KubeOps.Transpiler/Rbac.cs index e629175d..8e2fe610 100644 --- a/src/KubeOps.Transpiler/Rbac.cs +++ b/src/KubeOps.Transpiler/Rbac.cs @@ -73,11 +73,7 @@ public static IEnumerable Transpile(IEnumerable att RbacVerb.None => Array.Empty(), _ when verbs.HasFlag(RbacVerb.All) => new[] { "*" }, _ => -#if NETSTANDARD - Enum.GetValues(typeof(RbacVerb)).Cast() -#else Enum.GetValues() -#endif .Where(v => verbs.HasFlag(v) && v != RbacVerb.All && v != RbacVerb.None) .Select(v => v.ToString().ToLowerInvariant()) .ToArray(),