-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generator): add controller registrations (#623)
This generates `.AddController<T,T>` register calls for the operator builder to enable convenient registering.
- Loading branch information
Showing
55 changed files
with
3,836 additions
and
3,430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
using k8s.Models; | ||
|
||
namespace Operator.Entities; | ||
|
||
public class V1TestEntitySpec | ||
{ | ||
public string Spec { get; set; } = string.Empty; | ||
|
||
public string Username { get; set; } = string.Empty; | ||
|
||
public IntstrIntOrString StringOrInteger { get; set; } = 42; | ||
public string Email { get; set; } = string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ apiVersion: testing.dev/v1 | |
kind: TestEntity | ||
metadata: | ||
name: my-test-entity | ||
spec: | ||
username: my-username | ||
email: [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
todo: | ||
- finalizer | ||
- events | ||
- leadership election | ||
- requeue | ||
- build targets | ||
- other CLI commands | ||
- web: webhooks | ||
- cache? | ||
- try .net 8 AOT? |
32 changes: 16 additions & 16 deletions
32
src/KubeOps.Abstractions/Entities/CustomKubernetesEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
using k8s; | ||
using k8s.Models; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Base class for custom Kubernetes entities. The interface <see cref="IKubernetesObject{TMetadata}"/> | ||
/// can be used on its own, but this class provides convenience initializers. | ||
/// </summary> | ||
public abstract class CustomKubernetesEntity : KubernetesObject, IKubernetesObject<V1ObjectMeta> | ||
{ | ||
/// <summary> | ||
/// The metadata of the kubernetes object. | ||
/// </summary> | ||
public V1ObjectMeta Metadata { get; set; } = new(); | ||
} | ||
using k8s; | ||
using k8s.Models; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Base class for custom Kubernetes entities. The interface <see cref="IKubernetesObject{TMetadata}"/> | ||
/// can be used on its own, but this class provides convenience initializers. | ||
/// </summary> | ||
public abstract class CustomKubernetesEntity : KubernetesObject, IKubernetesObject<V1ObjectMeta> | ||
{ | ||
/// <summary> | ||
/// The metadata of the kubernetes object. | ||
/// </summary> | ||
public V1ObjectMeta Metadata { get; set; } = new(); | ||
} |
42 changes: 21 additions & 21 deletions
42
src/KubeOps.Abstractions/Entities/CustomKubernetesEntity{TSpec,TStatus}.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
using k8s; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Defines a custom Kubernetes entity. | ||
/// This entity contains a spec (like <see cref="CustomKubernetesEntity{TSpec}"/>) | ||
/// and a status (<see cref="Status"/>) which can be updated to reflect the state | ||
/// of the entity. | ||
/// </summary> | ||
/// <typeparam name="TSpec">The type of the specified data.</typeparam> | ||
/// <typeparam name="TStatus">The type of the status data.</typeparam> | ||
public abstract class CustomKubernetesEntity<TSpec, TStatus> : CustomKubernetesEntity<TSpec>, IStatus<TStatus> | ||
where TSpec : new() | ||
where TStatus : new() | ||
{ | ||
/// <summary> | ||
/// Status object for the entity. | ||
/// </summary> | ||
public TStatus Status { get; set; } = new(); | ||
} | ||
using k8s; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Defines a custom Kubernetes entity. | ||
/// This entity contains a spec (like <see cref="CustomKubernetesEntity{TSpec}"/>) | ||
/// and a status (<see cref="Status"/>) which can be updated to reflect the state | ||
/// of the entity. | ||
/// </summary> | ||
/// <typeparam name="TSpec">The type of the specified data.</typeparam> | ||
/// <typeparam name="TStatus">The type of the status data.</typeparam> | ||
public abstract class CustomKubernetesEntity<TSpec, TStatus> : CustomKubernetesEntity<TSpec>, IStatus<TStatus> | ||
where TSpec : new() | ||
where TStatus : new() | ||
{ | ||
/// <summary> | ||
/// Status object for the entity. | ||
/// </summary> | ||
public TStatus Status { get; set; } = new(); | ||
} |
34 changes: 17 additions & 17 deletions
34
src/KubeOps.Abstractions/Entities/CustomKubernetesEntity{TSpec}.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
using k8s; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Defines a custom kubernetes entity which can be used in finalizers and controllers. | ||
/// This entity contains a <see cref="Spec"/>, which means in contains specified data. | ||
/// </summary> | ||
/// <typeparam name="TSpec">The type of the specified data.</typeparam> | ||
public abstract class CustomKubernetesEntity<TSpec> : CustomKubernetesEntity, ISpec<TSpec> | ||
where TSpec : new() | ||
{ | ||
/// <summary> | ||
/// Specification of the kubernetes object. | ||
/// </summary> | ||
public TSpec Spec { get; set; } = new(); | ||
} | ||
using k8s; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Defines a custom kubernetes entity which can be used in finalizers and controllers. | ||
/// This entity contains a <see cref="Spec"/>, which means in contains specified data. | ||
/// </summary> | ||
/// <typeparam name="TSpec">The type of the specified data.</typeparam> | ||
public abstract class CustomKubernetesEntity<TSpec> : CustomKubernetesEntity, ISpec<TSpec> | ||
where TSpec : new() | ||
{ | ||
/// <summary> | ||
/// Specification of the kubernetes object. | ||
/// </summary> | ||
public TSpec Spec { get; set; } = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
using k8s; | ||
using k8s.Models; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Type for a list of entities. | ||
/// </summary> | ||
/// <typeparam name="T">Type for the list entries.</typeparam> | ||
public class EntityList<T> : KubernetesObject | ||
where T : IKubernetesObject | ||
{ | ||
/// <summary> | ||
/// Official list metadata object of kubernetes. | ||
/// </summary> | ||
public V1ListMeta Metadata { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// The list of items. | ||
/// </summary> | ||
public IList<T> Items { get; set; } = new List<T>(); | ||
} | ||
using k8s; | ||
using k8s.Models; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Type for a list of entities. | ||
/// </summary> | ||
/// <typeparam name="T">Type for the list entries.</typeparam> | ||
public class EntityList<T> : KubernetesObject | ||
where T : IKubernetesObject | ||
{ | ||
/// <summary> | ||
/// Official list metadata object of kubernetes. | ||
/// </summary> | ||
public V1ListMeta Metadata { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// The list of items. | ||
/// </summary> | ||
public IList<T> Items { get; set; } = new List<T>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
using k8s; | ||
using k8s.Models; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Method extensions for <see cref="IKubernetesObject{TMetadata}"/>. | ||
/// </summary> | ||
public static class Extensions | ||
{ | ||
/// <summary> | ||
/// Sets the resource version of the specified Kubernetes object to the specified value. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The type of the Kubernetes object.</typeparam> | ||
/// <param name="entity">The Kubernetes object.</param> | ||
/// <param name="resourceVersion">The resource version to set.</param> | ||
/// <returns>The Kubernetes object with the updated resource version.</returns> | ||
public static TEntity WithResourceVersion<TEntity>( | ||
this TEntity entity, | ||
string resourceVersion) | ||
where TEntity : IKubernetesObject<V1ObjectMeta> | ||
{ | ||
entity.EnsureMetadata().ResourceVersion = resourceVersion; | ||
return entity; | ||
} | ||
|
||
/// <summary> | ||
/// Sets the resource version of the specified Kubernetes object to the resource version of another object. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The type of the Kubernetes object.</typeparam> | ||
/// <param name="entity">The Kubernetes object.</param> | ||
/// <param name="other">The other Kubernetes object.</param> | ||
/// <returns>The Kubernetes object with the updated resource version.</returns> | ||
public static TEntity WithResourceVersion<TEntity>( | ||
this TEntity entity, | ||
TEntity other) | ||
where TEntity : IKubernetesObject<V1ObjectMeta> | ||
{ | ||
entity.EnsureMetadata().ResourceVersion = other.ResourceVersion(); | ||
return entity; | ||
} | ||
} | ||
using k8s; | ||
using k8s.Models; | ||
|
||
namespace KubeOps.Abstractions.Entities; | ||
|
||
/// <summary> | ||
/// Method extensions for <see cref="IKubernetesObject{TMetadata}"/>. | ||
/// </summary> | ||
public static class Extensions | ||
{ | ||
/// <summary> | ||
/// Sets the resource version of the specified Kubernetes object to the specified value. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The type of the Kubernetes object.</typeparam> | ||
/// <param name="entity">The Kubernetes object.</param> | ||
/// <param name="resourceVersion">The resource version to set.</param> | ||
/// <returns>The Kubernetes object with the updated resource version.</returns> | ||
public static TEntity WithResourceVersion<TEntity>( | ||
this TEntity entity, | ||
string resourceVersion) | ||
where TEntity : IKubernetesObject<V1ObjectMeta> | ||
{ | ||
entity.EnsureMetadata().ResourceVersion = resourceVersion; | ||
return entity; | ||
} | ||
|
||
/// <summary> | ||
/// Sets the resource version of the specified Kubernetes object to the resource version of another object. | ||
/// </summary> | ||
/// <typeparam name="TEntity">The type of the Kubernetes object.</typeparam> | ||
/// <param name="entity">The Kubernetes object.</param> | ||
/// <param name="other">The other Kubernetes object.</param> | ||
/// <returns>The Kubernetes object with the updated resource version.</returns> | ||
public static TEntity WithResourceVersion<TEntity>( | ||
this TEntity entity, | ||
TEntity other) | ||
where TEntity : IKubernetesObject<V1ObjectMeta> | ||
{ | ||
entity.EnsureMetadata().ResourceVersion = other.ResourceVersion(); | ||
return entity; | ||
} | ||
} |
Oops, something went wrong.