Skip to content

Commit bcd1f52

Browse files
author
Christoph Bühler
committed
feat(abstractions): add custom kubernetes entity helper
1 parent e0625f0 commit bcd1f52

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using k8s;
2+
using k8s.Models;
3+
4+
namespace KubeOps.Abstractions.Entities;
5+
6+
/// <summary>
7+
/// Base class for custom Kubernetes entities. The interface <see cref="IKubernetesObject{TMetadata}"/>
8+
/// can be used on its own, but this class provides convenience initializers.
9+
/// </summary>
10+
public abstract class CustomKubernetesEntity : KubernetesObject, IKubernetesObject<V1ObjectMeta>
11+
{
12+
/// <summary>
13+
/// The metadata of the kubernetes object.
14+
/// </summary>
15+
public V1ObjectMeta Metadata { get; set; } = new();
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using k8s;
2+
3+
namespace KubeOps.Abstractions.Entities;
4+
5+
/// <summary>
6+
/// Defines a custom Kubernetes entity.
7+
/// This entity contains a spec (like <see cref="CustomKubernetesEntity{TSpec}"/>)
8+
/// and a status (<see cref="Status"/>) which can be updated to reflect the state
9+
/// of the entity.
10+
/// </summary>
11+
/// <typeparam name="TSpec">The type of the specified data.</typeparam>
12+
/// <typeparam name="TStatus">The type of the status data.</typeparam>
13+
public abstract class CustomKubernetesEntity<TSpec, TStatus> : CustomKubernetesEntity<TSpec>, IStatus<TStatus>
14+
where TSpec : new()
15+
where TStatus : new()
16+
{
17+
/// <summary>
18+
/// Status object for the entity.
19+
/// </summary>
20+
public TStatus Status { get; set; } = new();
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using k8s;
2+
3+
namespace KubeOps.Abstractions.Entities;
4+
5+
/// <summary>
6+
/// Defines a custom kubernetes entity which can be used in finalizers and controllers.
7+
/// This entity contains a <see cref="Spec"/>, which means in contains specified data.
8+
/// </summary>
9+
/// <typeparam name="TSpec">The type of the specified data.</typeparam>
10+
public abstract class CustomKubernetesEntity<TSpec> : CustomKubernetesEntity, ISpec<TSpec>
11+
where TSpec : new()
12+
{
13+
/// <summary>
14+
/// Specification of the kubernetes object.
15+
/// </summary>
16+
public TSpec Spec { get; set; } = new();
17+
}

0 commit comments

Comments
 (0)