KubeOps.Generator
9.0.0-pre.2
See the version list below for details.
dotnet add package KubeOps.Generator --version 9.0.0-pre.2
NuGet\Install-Package KubeOps.Generator -Version 9.0.0-pre.2
<PackageReference Include="KubeOps.Generator" Version="9.0.0-pre.2" />
paket add KubeOps.Generator --version 9.0.0-pre.2
#r "nuget: KubeOps.Generator, 9.0.0-pre.2"
// Install KubeOps.Generator as a Cake Addin #addin nuget:?package=KubeOps.Generator&version=9.0.0-pre.2&prerelease // Install KubeOps.Generator as a Cake Tool #tool nuget:?package=KubeOps.Generator&version=9.0.0-pre.2&prerelease
KubeOps Generator
This is a C# source generator for KubeOps and operators. It is used to generate convenience functions to help registering resources within an operator.
Usage
The generator is automatically used when the KubeOps.Generator
package is referenced.
dotnet add package KubeOps.Generator
which results in the following csproj
reference:
<ItemGroup>
<PackageReference Include="KubeOps.Generator" Version="..." />
</ItemGroup>
Generated Sources
The generator will automatically generate functions for the IOperatorBuilder
.
Entity Metadata / Entity Definitions
The generator creates a file in the root namespace called EntityDefinitions.g.cs
.
This file contains all entities that are annotated with the KubernetesEntityAttribute
.
The static class contains the EntityMetadata
for the entities as well
as a function to register all entities within the IOperatorBuilder
.
Example
using KubeOps.Abstractions.Builder;
using KubeOps.Abstractions.Entities;
public static class EntityDefinitions
{
public static readonly EntityMetadata V1TestEntity = new("TestEntity", "v1", "testing.dev", null);
public static IOperatorBuilder RegisterEntities(this IOperatorBuilder builder)
{
builder.AddEntity<global::Operator.Entities.V1TestEntity>(V1TestEntity);
return builder;
}
}
Entity Initializer
All entities must have their Kind
and ApiVersion
fields set.
To achieve this, the generator creates an initializer file for each entity
that is annotated with the KubernetesEntityAttribute
.
For each partial class that does not contain a default constructor,
the generator will create a default constructor that sets the Kind
and ApiVersion
fields.
For each non partial class, a method extension is created that sets
the Kind
and ApiVersion
fields.
[!NOTE] Setting your class partial is crucial for the generator to create the constructor. Also, if some default constructor is already present, the generator uses the method extension fallback.
Example
namespace Operator.Entities;
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")]
public partial class V1TestEntity : CustomKubernetesEntity
{
}
The partial defined entity above will generate the following V1TestEntity.init.g.cs
file:
namespace Operator.Entities;
public partial class V1TestEntity
{
public V1TestEntity()
{
ApiVersion = "testing.dev/v1";
Kind = "TestEntity";
}
}
The non partial defined entity below:
namespace Operator.Entities;
[KubernetesEntity(Group = "testing.dev", ApiVersion = "v1", Kind = "TestEntity")]
public class V1TestEntity : CustomKubernetesEntity
{
}
will generate a static method extension in EntityInitializer.g.cs
for the entity to initialize the fields:
public static class EntityInitializer
{
public static global::Operator.Entities.V1ClusterTestEntity Initialize(this global::Operator.Entities.V1ClusterTestEntity entity)
{
entity.ApiVersion = "testing.dev/v1";
entity.Kind = "ClusterTestEntity";
return entity;
}
}
Controller Registrations
The generator creates a file in the root namespace called ControllerRegistrations.g.cs
.
This file contains a function to register all found controllers
(i.e. classes that implement the IEntityController<T>
interface).
Example
using KubeOps.Abstractions.Builder;
public static class ControllerRegistrations
{
public static IOperatorBuilder RegisterControllers(this IOperatorBuilder builder)
{
builder.AddController<global::Operator.Controller.V1TestEntityController, global::Operator.Entities.V1TestEntity>();
return builder;
}
}
Finalizer Registrations
The generator creates a file in the root namespace called FinalizerRegistrations.g.cs
.
This file contains all finalizers with generated finalizer-identifiers.
Further, a function to register all finalizers is generated.
Example
using KubeOps.Abstractions.Builder;
public static class FinalizerRegistrations
{
public const string FinalizerOneIdentifier = "testing.dev/finalizeronefinalizer";
public const string FinalizerTwoIdentifier = "testing.dev/finalizertwofinalizer";
public static IOperatorBuilder RegisterFinalizers(this IOperatorBuilder builder)
{
builder.AddFinalizer<global::Operator.Finalizer.FinalizerOne, global::Operator.Entities.V1TestEntity>(FinalizerOneIdentifier);
builder.AddFinalizer<global::Operator.Finalizer.FinalizerTwo, global::Operator.Entities.V1TestEntity>(FinalizerTwoIdentifier);
return builder;
}
}
General Operator Extensions
The generator creates a file in the root namespace called OperatorExtensions.g.cs
.
It contains convenience functions to register all generated sources.
Example
using KubeOps.Abstractions.Builder;
public static class OperatorBuilderExtensions
{
public static IOperatorBuilder RegisterComponents(this IOperatorBuilder builder)
{
builder.RegisterEntities();
builder.RegisterControllers();
builder.RegisterFinalizers();
return builder;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on KubeOps.Generator:
Repository | Stars |
---|---|
josephnhtam/live-streaming-server-net
A .NET implementation of RTMP live streaming server, supporting HTTP-FLV, WebSocket-FLV, HLS, Kubernetes, cloud storage services integration and more.
|
Version | Downloads | Last updated |
---|---|---|
9.1.5 | 2,588 | 9/10/2024 |
9.1.4 | 976 | 8/26/2024 |
9.1.3 | 6,101 | 6/28/2024 |
9.1.2 | 589 | 6/20/2024 |
9.1.1 | 1,447 | 5/22/2024 |
9.1.0 | 1,818 | 5/15/2024 |
9.0.2 | 139 | 5/13/2024 |
9.0.0 | 7,339 | 3/13/2024 |
9.0.0-pre.4 | 68 | 4/19/2024 |
9.0.0-pre.3 | 62 | 3/21/2024 |
9.0.0-pre.2 | 59 | 3/13/2024 |
9.0.0-pre.1 | 54 | 3/7/2024 |
8.0.2-pre.2 | 71 | 2/21/2024 |
8.0.2-pre.1 | 51 | 2/19/2024 |
8.0.1 | 2,397 | 2/13/2024 |
8.0.1-pre.7 | 61 | 2/12/2024 |
8.0.1-pre.6 | 65 | 2/7/2024 |
8.0.1-pre.5 | 62 | 2/5/2024 |
8.0.1-pre.4 | 66 | 1/31/2024 |
8.0.1-pre.3 | 61 | 1/26/2024 |
8.0.1-pre.2 | 57 | 1/25/2024 |
8.0.1-pre.1 | 59 | 1/18/2024 |
8.0.0 | 629 | 1/17/2024 |
8.0.0-pre.45 | 50 | 1/17/2024 |
8.0.0-pre.44 | 55 | 1/16/2024 |
8.0.0-pre.43 | 64 | 1/16/2024 |
8.0.0-pre.42 | 1,169 | 1/10/2024 |
8.0.0-pre.41 | 188 | 1/2/2024 |
8.0.0-pre.40 | 162 | 12/27/2023 |
8.0.0-pre.39 | 78 | 12/21/2023 |
8.0.0-pre.38 | 181 | 12/6/2023 |
8.0.0-pre.37 | 93 | 12/6/2023 |
8.0.0-pre.36 | 136 | 12/3/2023 |
8.0.0-pre.35 | 72 | 11/28/2023 |
8.0.0-pre.34 | 85 | 11/24/2023 |
8.0.0-pre.33 | 62 | 11/24/2023 |
8.0.0-pre.32 | 63 | 11/23/2023 |
8.0.0-pre.31 | 69 | 11/23/2023 |
8.0.0-pre.30 | 75 | 11/23/2023 |
8.0.0-pre.29 | 457 | 11/11/2023 |
8.0.0-pre.28 | 83 | 11/8/2023 |
8.0.0-pre.27 | 590 | 10/23/2023 |
8.0.0-pre.26 | 91 | 10/19/2023 |
8.0.0-pre.25 | 68 | 10/18/2023 |
8.0.0-pre.24 | 89 | 10/13/2023 |
8.0.0-pre.23 | 68 | 10/13/2023 |
8.0.0-pre.22 | 72 | 10/13/2023 |
8.0.0-pre.21 | 74 | 10/12/2023 |
8.0.0-pre.20 | 79 | 10/11/2023 |
8.0.0-pre.19 | 82 | 10/9/2023 |
8.0.0-pre.18 | 68 | 10/9/2023 |
8.0.0-pre.17 | 65 | 10/7/2023 |
8.0.0-pre.16 | 105 | 10/6/2023 |
8.0.0-pre.15 | 75 | 10/6/2023 |
8.0.0-pre.14 | 68 | 10/5/2023 |
8.0.0-pre.13 | 62 | 10/5/2023 |
8.0.0-pre.12 | 69 | 10/4/2023 |
8.0.0-pre.11 | 68 | 10/3/2023 |
8.0.0-pre.10 | 77 | 10/3/2023 |
8.0.0-pre.9 | 72 | 10/3/2023 |
8.0.0-pre.8 | 65 | 10/2/2023 |
8.0.0-pre.7 | 71 | 10/2/2023 |
8.0.0-pre.6 | 69 | 9/29/2023 |
8.0.0-pre.5 | 66 | 9/28/2023 |
8.0.0-pre.4 | 63 | 9/28/2023 |
8.0.0-pre.3 | 71 | 9/27/2023 |
8.0.0-pre.2 | 51 | 9/26/2023 |
8.0.0-pre.1 | 70 | 9/22/2023 |
'# [9.0.0-pre.2](https://github.com/buehler/dotnet-operator-sdk/compare/v9.0.0-pre.1...v9.0.0-pre.2) (2024-03-13)
### Bug Fixes
* Watching resource with old version should restart ([#735](https://github.com/buehler/dotnet-operator-sdk/issues/735)) ([183c381](https://github.com/buehler/dotnet-operator-sdk/commit/183c3815164e9ba12f507067cf9f286d80a26c7e)), closes [#724](https://github.com/buehler/dotnet-operator-sdk/issues/724)
'