-
-
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(abstractions): add custom kubernetes entity helper
- Loading branch information
Christoph Bühler
committed
Sep 29, 2023
1 parent
e0625f0
commit bcd1f52
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
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 |
---|---|---|
@@ -0,0 +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(); | ||
} |
21 changes: 21 additions & 0 deletions
21
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 |
---|---|---|
@@ -0,0 +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(); | ||
} |
17 changes: 17 additions & 0 deletions
17
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 |
---|---|---|
@@ -0,0 +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(); | ||
} |